Temperature logging to ThingSpeak using ESP8266 and DHT22

The GPIO pins of the ESP8266 makes it possible to create a very simple temperature logger, which logs the data directly to the free cloud of ThingSpeak. By using only a DHT22 temperature/humidity sensor, and an ESP8266, it is possible to create a realtime feed of temperature and humidity by using your own wifi network.

This post is mainly based on the original tutorial by Arduinoesp.com, but was upgraded to be able to use a DHT22 instead of the older DHT11, and uses the Arduino IDE to program the ESP8266.

The setup contains just four parts. The ESP8266 as microcontroller and for the connectivity, a DHT22 temperature/humidity sensor, a 5v-3.3v step down converter, and a micro-USB pcb which is used to provide easy powering for the project by any compatible micro-usb adapter. This could be an micro-USB cable or the charger that most likely came with your smartphone.

Error: Item no longer available or API problems.

Error: Item no longer available or API problems.

Error: Item no longer available or API problems.

The schematic view of this project is not very difficult. The micro usb pcb gives 5V to the step down converter. The output of 3.3v can be used for powering the ESP8266 (VCC and CH_PD) and the DHT22 (VCC). The data port of the DHT22 (OUT) should be connected to the GPIO0 port of the ESP8266. Then all there is left are the gounds of all the parts, connect them all together and your ready.

Best practice is to try this setup on a breadboard, as seen below. This way you can fix any errors, and it makes it easy to program the ESP8266 using the Arduino IDE.


I’ve changed the original software to the example below. It requires the DHT_Adafruit and the ESP8266Wifi libraries. The instructions how to program an ESP8266 using the Arduino IDE can be found in the ESP8266 Wifi LED Dimmer post.

You need to configure the wifi credentials to your own settings. Also the API key should be entered. This can be created on the ThingSpeak website, and can be found under ‘Account’ (upper right corner) and select ‘My Account’.

As an example of how this all works together, I’ve created this for myself and it is currently running from inside my house. The results can be viewed on my public ThingSpeak profile, and I’ve also embedded the graphs below.

For me this was just an example of what the ESP8266 is capable of, combining it with a few simple sensors. I used ThingSpeak because it is a fast and easy way to publish sensor data to the public, without the need to create a webservice by myself. I’m not planning on using ThingSpeak for anything similar in the future. I’dd rather keep the data to myself and use self-hosted (or self created) webservices.