---
# System prepended metadata

title: 'How-to: make your own outside temperature-reading device with Arduino Uno'

---

# How-to: make your own outside temperature-reading device with Arduino Uno

### 
Rodan Uca, ro22bn


## Project Description

We will with the use of Arduino Uno read the temperature outside and then send that data to the site dweet.io, where it would be more palatable to read. 

Estimated time for completion of project: 30 hours.



## Objective

### Why you chose the project
This project was chosen because of its application aiding one's laziness and wanting to make sure of the temperature outside before deciding, for example, what clothes would best fit the weather and not to either overdress or underdress depending on how cold/warm it is outside. I wanted to see if i could, with the help arduino and dweet.io, send and display data without much upkeep(aka, database and front-end overhead). With this project, i would only need to place the arduino outside and make sure that everything works as planned, and check the specific URL in order to know the temperature outside.

### What purpose/insight does it serve/give

This project, would serve as a first step into the varied world of IoT. You would then from there, without much effort, scale this project to maybe measure the temperature and humidity inside, in your room, of your car, etc. The first step into automating daily tasks and worries with some code and a small microcontroller.



## List of Materials

Arduino uno wifi rev3

This is the microcontroller we are going to use for this project, it will work as our tiny computer that will then run the code we write.This package also includes a usb cable that you would use to flash firmware and flash/re-flash the code you write to the arduino controller, **Kjell & Kompany, 249 kronor.**

These items, down below, were bought in a bundle offered by the site, electrokit.com, where it is offered as: **LNU – 1DT305 Tillämpad IoT – Sensors only bundle, 129 kronor**


**Jumper Wires**

These wires are used in order to connect the sensor we are using to our arduino board without the need of soldering and other more complicated electronics' practices.


**Breadboard**

These are, just as the wires, used to connect different components together without the need of soldering.

**MCP9700 Sensor**

The Sensor we are going to use to measure the temperature outside.


## Computer Setup

As for the setup, we can start by connecting the arduino card to our computer with the help of the added usb-cable. After that, we can go to Windows Devivce Manager(Control panel > Hardware) and find the arduino listing and right click to update driver.

We then download the newest version of Arduino IDE, from the site arduino.cc.

We then open the Arduino IDE and navigate to File > Preferences:

![](https://i.imgur.com/YgYGZfu.png)

You will add, to the field "Additional Boards Manager URLS," the link provided here:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Once that's done, traverse to Tools > Board > Boards Manager and select/type esp8266 and install that bundle, this bundle will include the wifi library we are going to use later on.

### Chosen IDE

### How the code is uploaded


We will upload the code by first connecting the usb cable to our computer, and then open Arduino IDE and navigate to our sketch with all of our code. we will then select the board type and the port(in our case port COM3, it is likely the right port, to try to find the right one you can disconnect the board and re-open the menu and try the different ports.)

![](https://i.imgur.com/7eiNh1W.png)


Board Selection shown here.


![](https://i.imgur.com/vUFqCs6.png)

Port Selection shown here.


We now, given that we have opened the sketch with all the code, press the upload button on the left-hand side at the top of the IDE and wait for arduino IDE to compile and upload/flash the code to our arduino board.

![](https://i.imgur.com/wYLXXU1.png)

the Upload button.


![](https://i.imgur.com/NRDqjze.png)

What is shown when the process is done compiling and the upload has been completed successfully.


## Electronics and Circuit Diagram


I will start this section by sharing a tinkercad circuit, it will help the eligibility/readability of the circuit and the wiring setup for this project and then go through the how-to of connecting the sensor to the arduino:

![](https://i.imgur.com/oCcH8GJ.png)

We will use 3 jumping wires, but first we will need to connect our sensor to the breadboard, by slightly bending the 3 legs until it fits right in, when that is done, is when we begin connecting our 3 wires.

First wire(red wire): will help us power the sensor, and we will connect the power wire to arduino's 5VDC pin and running it to the sensor's first pin, which is the one to the left(aka the red wire).

Second wire(yellow wire): We will run a wire through one of arduino's analog input pins - i chose A0(you can choose whichever one you like) - and connect it to our sensors output pin, the middle one.

Third wire(black wire): We will run a wire trough one of arduino's ground pins to the sensors ground pin, third pin to the right. 



## Platform Choice

The platform that i chose for this project is, dweet.io. It is a fleeting cloud-based storage/visualization alternative and saves me time not having to worry about the back-end or the front-end- it saves me from the engineering overhead(for a quite simple IoT application, i couldn't be bothered with the upkeep of both the front-end and back-end) and constant worrying and i can instead focus on the arduino code. This is a bit different from, say, firebase, where the storage here is finite and lasts for about 24 hours, if you don't plan to lock said dweet(which costs 1.99 $ per dweet and lasts for a month). You'll use its REST API in order to send GET or POST requests back-and-forth, it is really straightforward and basic, which is perfect for this project. For more, check this out:

https://dweet.io/play/

As for the scalability of dweet.io, is it, ugh, rather limited, given that they store data in 24 hour-intervals if you don't pay for each dweet, aka each POST  request that you make. If you are willing to pay, it will roughly stay up for a month before deletion by the site. There is no permanent-storage option, I am afraid. I would advice people looking into something more long-term to check out firebase, or AWS.

## The Code

Here is the code of the project, with added comments:
```
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

#include <avr/io.h> 
#include <avr/delay.h> 



const char* ssid = "#"; 
const char* password = "#"; 

const char* fungibleSite = "#";
const char* host  ="dweet.io"; // The dweet.io website, where we will send our data to



int sensorPin = A0; // pins that reads sensor output
int sensorInput;
double temp; 
int period = 1000;

WiFiClient client;
const int httpPort = 80;

void setup() {
 
  pinMode(sensorPin, INPUT);


    Serial.begin(9600); // starts to read 

      //Connection to the Wifi Network after a slight delay
    
  		delay(1000);

  WiFi.begin(ssid, password);
  
    Serial.println("Connection succeded..   Address:");
    Serial.println( WiFi.localIP());
    Serial.println("Setup ready");
  }

void loop(){
    
  postDweet();
   delay(period);

}


void postDweet(){ // send data to your page
  
  client.stop();

  if(client.connect(host, httpPort)){
   Serial.println("Connected...");
    
sensorInput = analogRead(sensorPin); // read from the sensor and store it in our variable sensorInput


  temp = (double)sensorInput/ 1024; // find percentage of input
      temp = temp * 5; // multiply it by 5 to get the voltage
      temp = temp - 0.5; //subract the offset
      temp = temp * 100; // convert to degrees
    
    //Our POST Request and using concat operations to compile said request
    
    String s = "POST /dweet/for/";
    s.concat(fungibleSite); //the temporary site name that is generated
    s.concat("?temperature="); // page name for each value of data, aka temperature reading
    s.concat(temp);
    Serial.print(s);
    client.println(s);

    client.println("Host: dweet.io");
    client.println("Connection: running");
    client.println();
    

  }else{

 Serial.println("Connection Failed...");

  }

}

```

## Transmitting the data/connectivity

### How often is the data sent?

The data, which can be sort of inferred from the code-section, is sent around once each second, with added delay if the connection is busy or not. This is more than enough of an overhead, i won't be checking the site each second.



### Which wireless protocols did you use(WiFI, LoRa, etc)?

Since, i am not planning on moving the device or keeping it with me through travel, i opted for the WiFi protocol. 

The device range, given the short range of my WiFi at home, and this would also show it self problematic in terms of power consumption( typically a Wi-Fi module's power consumption is 50-200 mA). I could have opted to use the LoRa protocol instead, which would have rendered the power-issue redundant, it doesn't consume nearly as much energy as the WiFi protocol. this was however, thought of quite late in the process and i couldn't switch back then.

As for the transmission protocol, the module that comes with arduino is the ESP8266 wifi module, which uses TCP/UDP communication protocol stack that connects to a server/client.



## Presentation of Data and Final Results

### Provide Visual Examples of the dashboard



![](https://i.imgur.com/yvD6xY9.jpg)


This is what the presentation looks when data is presentated to the dweet.io site. This is another bonus with using dweet.io, no need to play with visualization or the dashboard if you are not interested in how your data will displayed.


The data, as mentioned above, is saved every other second, and is then discarded within 24 hours, if you have not payed for the dweet/data to be locked.


This type of approach was used in order to cut costly anticipated overheads, front-end and back-end-wise, that is. How the data is stored and kept is decided by dweet.io, as I mentioned before.

As, for the triggers/automation of when the data is sent, it is arbitrarily based by me(1 second) and if the connection is being bogged down with other on-going requests that have not reached dweet.io yet.


Here is the last photos, of the actual arduino board sitting quietly on the balcony window:


![](https://i.imgur.com/ee2LHrL.jpg)



![](https://i.imgur.com/hsuvxQv.jpg)




##

### Final thoughts

The project was very interesting and eye-opening as to the different use-cases and possibilities with arduino and the myriad of IoT-applications that could use this combo(garden temperature, car temperature, etc.)

However, i would be remiss, not to mention some of the shortcomings using this approach. One, dweet.io showed it self cumbersome to intergrate with the arduino code. Mainly due to the dearth of documentation on their site using their API and its commands.

Another issue was to setup the wifi-module, it is not plug-and-play as I first thought. You had to find the write port to use, baud rate and play around with different libraries that would gel with your version of arduino or the wifi-module.

Short of those, well, shortcomings, this was a pleasurable and a perspective broadening experience. 10/10. Would do it again.