NodeMCU ESP8266 Devkit ESP12 with DHT11

Posted by

This post is to understand the DHT11 sensor working  with Node MCU board. Pseudo code is also provided for better understanding . I am using DHT11 mounted in Blynk board.

Setup Requirements

1: ESP8266 Node MCU board

2: Blynk Board for IoT

I have also provided link to purchase both the boards.

What is NodeMCU ?

Here  is overview about NodeMCU (Node MicroController Unit).

The NodeMCU  is an open source software and hardware development environment that is built around a very inexpensive System-on-a-Chip (SoC) called the ESP8266. The ESP8266, designed and manufactured by Espressif Systems, contains all crucial elements of the modern computer: CPU, RAM, networking (wifi), and even a modern operating system and SDK.


What is DHT11 ?

DHT11 is a low cost humidity and temperature sensor which generates calibrated digital output. This sensor includes a resistive-type humidity measurement component and an NTC (Negative Temperature Coefficient) temperature measurement component, Most humidity sensors use capacitive measurement to determine the amount of moisture in the air.

DHT11 datasheet provides  parameters such as operating temperature range, voltage, current, accuracy , resolution etc . I have provided datasheet of one particular device as reference. It provides relative humidity (RH) of accuracy +/- 5% and temperature measurement of accuracy +/-2 degree Centigrade.

I opened one faulty DHT11 sensor for inspection.

Connection Diagram is very simple. Only three connections are required to be made to use the sensor – Vcc, Gnd and Output.Pin 3 of DHT11 is NC(Not Connected) . Pin2 provides the digital output.

DHT11 is already mounted in Blynk board. Just plug-in the Node MCU board to Blynk board . Then connect USB cable to PC where Arduino IDE is installed

How data transmission starts ?

MCU sends a start signal to start communication. This wakes up the sensor from sleep mode and  sensor sends a response  followed by a burst of 40 bits data .

How data 0 is encoded?

How data 1 is encoded ?

You may notice the bit is high for longer duration in case of data 0. This can be found in device data sheet.

Frame transmission :

The data format consists of five bytes(40 bits) as follows

 integral  RH decimal RH integral T decimal T  check sum

Pseudo code:

  • Send Start pulse
    • PinMode=output
    • PinData=0
    • Delay for Low duration
    • PinMode=input
    • delay for 40 microsec
  • Wait for ACK Low duration
  • Wait for ACK High duration
  • Read 40 bits in buffer with monitoring the timeout for data 0 or data 1.
  • Check the data received with checksum
  • Check status flag ,data buffer and act accordingly



DHT11 data sheet 

NodeMCU Doc 


Please SUBSCRIBE to YouTube channel Embedkari  for additional embedded related stuff.


Leave a Reply
