Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Nodemcu Esp8266-12E Wifi module interfaced with DHT-11 Temperature & Humidity sensor

By EG Projects May 11, 2019

In this tutorial i will teach you how to interface dht-11 temperature and humidity sensor with nodemcu esp8266-12e WiFi module and monitor temperature of an area. One can see the temperature and humidity level of a room or a particular place in his desktop or mobile browser by making this diy project. Their are also other family members of DHT-11 temperature & humidity sensor available in market such as DHT-21 and DHT-22. The same code of this tutorial can be utilized to interface other dht family members with nodemcu WiFi module with slight modifications in dht library. 

DHT-11 Temperature and Humidity Sensor

Like old methods of measuring temperature DHT-11 also uses thermistor with high accuracy to measure the temperature of surroundings. For humidity measurement it uses capacitive humidity sensor. Its a low cost temperature and humidity sensor. Power requirements of the sensor is between 3 volts to 5 volts and needs continuous 25 mA of direct current. It outputs data in digital form. It can measure temperature between 0 degree to 50 degree Celsius with 2% margin of error. Humidity level it can measure lies between 20% to 80% with 5% margin of error. DHT-11 can update its data after every 2 seconds so its a pretty low speed sensor. DHT-11 outputs default temperature in Celsius.   
DHT-11 sensor has 3 or 4 pins depending on the manufacturer. Normally it has four pins. Two pins a power pins. Gnd and Vcc respectively. The third one is data_out pin. At this pin sensor outputs the temperature and humidity values. Fourth pin is void. Data_out pin requires a pull up resistor. The sensor i am using has a build in pull up resistor.           

Project circuit diagram

Nodemcu esp8266-12e works on 3.3 volts and dht-11 can also work on 3 volts. So i am going to power the dht-11 with nodemcu output power pins. For data input to nodemcu i am using D3 or GPIO-0 of nodemcu. Project circuit diagram is given below.  
Interfacing DHT-11 temperature and humidity sensor with nodemcu wifi module

Interfacing DHT-11 temperature and humidity sensor with nodemcu wifi module

Coming to the code portion. First i included the necessary libraries for nodemcu and dht-11 working. ESP8266WiFi header file deals with the nodemcu module and DHT header is for initializing and working with DHT sensor.  After libraries i defined the macros for dht sensor and the pin to which it will be connected with nodemcu. After it enter the SSID and Password of WiFi network to which you want to connect your nodemcu.

const char* ssid = “Your SSID”;
const char* password = “Your Wifi Password”;

In the setup loop nodemcu requests the router for an IP. After IP allotment it starts its server. In the loop function nodemcu is checking for any client request. If a request arrives nodemcu fetches data from dht-11 and send back a reply in the form of an HTML page to client.   
Nodemcu is working as a server. It is serving a web page. Web page contains the temperature and humidity values of room or a place. Your client desktop, mobile, laptop or notebook must be on the same WiFi network to which nodemcu is connected. If one of them the client/mobile or server/nodemcu is connected to other network then you will be unable to load and see the web page on which temperature and humidity data is served.
Just build the circuit and upload the above code in your nodemcu. After uploading enter the serial monitor from arduino ide. You will see nodemcu starting its WiFi and server status. After server startup a link will be displayed containing an IP. This IP or HTTP address is link on which nodemcu is displaying temperature and humidity values. Enter this address in your browser for page load.   
If you are unable to see any thing on the serial monitor or raw numbers and figures. It might be due the wrong bps settings. Change the communication rate to 9600 bps. If still you cant see any thing check the nodemcu and PC connection. Check for all possible errors.      
Picture

Final page displayed in the browser will be some thing like below. It contains the temperature and humidity values. Temperature will be displayed in both scales Celsius and Fahrenheit.  A button with text “Update Temperature & Humidity” is present on the page. When ever user needs an updated value he has to press this button. This button press notifies the nodemcu that client needs an updated temperature value.   
Nodemcu measuring temperature and humidity using dht11 sensor over WiFi

Nodemcu measuring temperature and humidity using dht11 sensor over WiFi

Download the project code. Folder contains arduino ide .ino file. Please provide us your feed back on the project. For comments and queries us the below comments section.
Code/Files


Filed Under: Electronic Projects, ESP8266, Microcontroller Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • High Side current sensing
  • Multiple DC/DC converters and a single input source
  • MOSFET thermal noise in Weak vs Strong inversion
  • Xiaomi Mijia 1C Robot problem of going backwards while working
  • Will this TL084C based current clamp circuit work?

RSS Electro-Tech-Online.com Discussions

  • Curved lines in PCB design
  • using a RTC in SF basic
  • Parts required for a personal project
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz
  • PIC KIT 3 not able to program dsPIC

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection
  • Convection-cooled power controller integrates EtherCat connectivity

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe