Temperature logger with NodeMCU and DHT22

Here I will describe how to do a temperature logger using the NodeMCU and the DHT22 temperature and humidity reader.

The hardware


I used a NodeMCU board (ESP8266) like below:



And a DHT22 sensor like below:



The wiring


You need to connect these pins:

DHT22 OUT pin >> NodeMCU D2
DHT22 + pin >> NodeMCU 3V
DHT22 - pin >> NodeMCU GND

The code


I used Arduino IDE to make the code. You need to setup the IDE to use a NodeMCU board. You can see more details here.

The NodeMCU code is very simple:



Then you need to create two files. One to push the values to the MySQL database, and other to show the values on the web:





Finally, we need to create the MySQL tables:


Live demo


You can see a live demo here. This device is located at Rio de Janeiro, Brazil.

I hope that you enjoy. If you want, contact-me.