Skip to main content

ESP8266 + DHT22 + Arduino + Web Server

So here is a modified version of how to get a DHT22 working on ESP8266 NodeMcu board using the Arduino IDE (not Lua)

The project is based on:

  1. Get the components and assemble them. In India you can find these on
    1. NodeMcu ESP8266 | Link
    2. DHT22 | 
    3. Male-Male Jumper Wires | 
    4. Bread Board | Link
    5. MicroUSB cable | 
  2. Assemble the circuit as shown. Connect the Data pin of SHT22 to D2 of NodeMcu (which is referred to pin 4 in Arduino IDE)
  3. Install the driver for USB-Serial chip on your PC:
  4. Install Arduino on your computer and install support for ESP8266 Board, refer:
  5. Install the DHT-sensor-library-master library as outlined here:
  6. You would need to download and place Adafruit_Sensor.h in this same library folder as well. Get that file from:
    Click on "Raw" to get the file.
  7. Copy the code below, and download it into your ESP8266 NodeMcu board. Make sure to select the proper board and COM port.
To test:
  1. Connect your mobile to the WiFi hotspot created by ESP8266 : Temperature_Server
    Password is:
  2. Make sure to turn off the 3G data connection on your phone. Andorid will report that the wifi network "Temperature_Server" does not provide internet access. Ignore the message.
  3. Open chrome and punch in in the URL field and ESP8266 will serve you with the latest reading from the temperature sensor.