Now a days measuring temperature and humidity is not a difficult job. Because lot of sensor are available in the market. DHT11 and DHT22 are very familiar from others. DHT11 Module is very low cast and available in market long days. In this tutorial you will learn how to interface DHT11 with ESP8266 module using NodeMCU Firmware. In this project I’m used Espressif’s ESP8266X of Ai-thinger’s ESP-12F module with Aosong DHT11 module using NodeMCU DHT Module in windows system. You can also use any other ESP8266 Modules for this project.
Required
- Required Hardware Components : ESP8266 Any Module( Used Ai-Thingers ESP-12F) – 1Nos, DHT11 Temperature and Humidity Sensor (eBay) – 1Nos, 4R7 Kilo Ohm Resistor-0.25W (eBay) – 1Nos, ESP8266 Programmer (FDTI chip or use your Arduino board) – 1Nos, Wires
- Required Software and Tools : NodeMCU Flasher , Any version of ESPlorer by 4refr0nt (Used v0.2.0-rc5), DHT11 Firmware (Build your custom firmware),
- Save the code name as “AEW_DHT11.lua” in your system
- Flash DHT11 NodeMCU Firmware to ESP8266 Module using NodeMCU firmware flasher, Follow below connection details
ESP8266 chip – FDTI Programmer
Vcc – 3.3v
Gnd – Gnd
TX – Rx
Rx – Tx
GPIO-0 – Low
- Connect ESP8266 Module GPIO-5 pin to DHT11 Data pin with 4.7K ohm pull-up resistor
ESP8266 chip – FDTI Programmer
Vcc – 3.3v
Gnd – Gnd
TX – Rx
Rx – Tx
- Upload the above lua code to esp module using ESPlorer(Use baud rate 115000), follow above connection details
- Do-file (AEW_DHT11.lua)
Circuit Diagram
Code
pin = 23 status, temp, humi = dht.read11(pin) if status == dht.OK then print("DHT Temperature:"..temp..";".."Humidity:"..humi) elseif status == dht.ERROR_CHECKSUM then print( "DHT Checksum error." ) elseif status == dht.ERROR_TIMEOUT then print( "DHT timed out." ) end
Result