Cloud Temperature Logger with the ESP8266

The ESP8266 is an amazingly cheap & small WiFi chip that can be used for several home automation applications. In this project, we are going to use it to automatically log temperature (and humidity) measurements in the cloud, and display these measurements inside an online dashboard.

By following this tutorial, you will be able to build a small & cheap measurement platform that logs data in the cloud. Of course, this can be applied to several type of sensors, like motion detectors. Let’s dive in!

Hardware & Software Requirements

For this project, you will of course need an ESP8266 chip. You can for example use an Olimex ESP8266 module.

You will also need a temperature sensor. I used a DHT11 sensor, which is very easy to use & that will allow us to measure the ambient temperature & humidity.

You will also need a 3.3V FTDI USB module to program the ESP8266 chip. Finally, you will also need some jumper wires & a breadboard.

This is a list of all the components that will be used in this guide:

On the software side, I will let you see my guide on how to set up the ESP8266 for a first use:

At the end, you will need to have an ESP8266 chip ready to be used with the ESP8266 Arduino IDE.

Hardware Configuration

Again, for most of the hardware configuration I will redirect you to the article I wrote on setting up your ESP8266 chip:

Once this is done, simply put the DHT11 sensor on the breadboard. Then, connect the left pin to VCC (red power rail), the right pin to GND (blue power rail), and the pin next to VCC to the GPIO5 pin on your ESP8266 chip. This is the final result, not showing the USB-to-Serial FTDI cables:

Testing the Sensor

We are now going to test the sensor. Again, remember that we are using the modified version of the Arduino IDE, so we can code just like we would do using an Arduino board. Here, we will simply print the value of the temperature inside the Serial monitor of the Arduino IDE.

This is the complete code for this part:

// Libraries
#include "DHT.h"

// Pin
#define DHTPIN 5

// Use DHT11 sensor
#define DHTTYPE DHT11

// Initialize DHT sensor

void setup() {

 // Start Serial 
 // Init DHT 

void loop() {

 // Reading temperature and humidity
 float h = dht.readHumidity();
 // Read temperature as Celsius
 float t = dht.readTemperature();

 // Display data
 Serial.print("Humidity: "); 
 Serial.print(" %\t");
 Serial.print("Temperature: "); 
 Serial.println(" *C ");
 // Wait a few seconds between measurements.


Let’s see the details of the code. You can see that all the measurement part is contained inside the loop() unction, which makes the code inside it repeat every 2 seconds.

Then, we read data from the DHT11 sensor, print the value of the temperature & humidity on the Serial port.

Note that the complete code can also be found inside the GitHub repository of the project:

You can now paste this code in the Arduino IDE, and upload it to your board. Then, open the Serial monitor. You should immediately see that the temperature & humidity readings inside the Serial monitor. My sensor was reading around 24 degrees celsius when I tested it, which is a realistic value.

Logging Data to

We are now going to see how to log these measurements in the cloud. This will be really easy to do as our chip is already connected to the web. We will once more use the cloud service that I used in several articles of this website:

As the code for this part is very long, we will only see the important parts here. You can of course get all the code from the GitHub repository for this project. Again all the measurements are done inside the loop() function of the sketch, which makes the code repeat every 10 seconds, using a delay() function.

Inside this loop, we connect to the server with:

WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
  Serial.println("connection failed");

Then, we read the data from the sensor with:

int h = dht.readHumidity();
int t = dht.readTemperature();

After that, we send data to the server with:

client.print(String("GET /dweet/for/myesp8266?temperature=") + String(t) + "&humidity=" + String(h) + " HTTP/1.1\r\n" +
  "Host: " + host + "\r\n" + 
  "Connection: close\r\n\r\n");

You might want to replace the ‘myesp8266’ here, which is your device name on Use a complicated name (just like a password) to make sure you are creating an unique device on

We also print any received data on the serial port with:

  String line = client.readStringUntil('\r');

Note that the complete code can also be found inside the GitHub repository of the project:

Note that you also need to modify the code to insert your own WiFi network name & password. You can now upload the code to the ESP8266 board, and open the Serial monitor. You should see that every 10 seconds, the request is sent to the server, and you get the answer back:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json
Content-Length: 147
Date: Mon, 16 Mar 2015 10:03:37 GMT
Connection: keep-alive

{“this”:”succeeded”,”by”:”dweeting”,”the”:”dweet”,”with”:{“thing”:”myesp8266″,”created”:”2015-03-16T10:03:37.053Z”,”content”:{“temperature”:24, “humidity”:39}}}

If you can see the ‘succeeded’ message, congratulations, you just logged data in the cloud with your ESP8266 chip!

Display Data Using

Now, we would like to actually display the recorded data inside a dashboard that can be accessed from anywhere in the world. For that, we are going to use a service that I love to use along with Freeboard. You can create an account there by going to:

Then, also create a new dashboard, and inside this dashboard, create a new datasource. Link this datasource to your ‘thing’ that you defined in the ESP8266 code:

Then, create a new ‘Gauge’ widget, that we will use to display the temperature. Give it a name, and link it to the temperature field of our datasource:

This is the final result:

You should see that the temperature data coming from the ESP8266 is logged every 10 seconds and is immediately displayed inside the panel. Congratulations, you should built a very small & cheap temperature sensor that logs data in the cloud! You can then do the same with the humidity measurements & also display them on this dashboard.

How to Go Further

Let’s summarise what we did in this project. We built a simple & cheap WiFi temperature sensor based on the ESP8266 chip. We configured it to automatically log data on the service, and we displayed these measurements inside a dashboard.

There are many ways to improve this project. You can simply add more sensors to the project, and display these measurements as well inside the dashboard. You can also for example completely change the project, by connecting a motion sensor to the ESP8266 board. You can then configure this sensor to automatically send you an alert when motion is detected, for example via email or using Twitter. The possibilities are endless!

What about you, did you also built cloud-connected projects using the ESP8266 chip? Please share in the comments!