Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
      • Power Electronics & Programmable Power
  • Women in Engineering

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

By EG Projects

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: ESP8266, Microcontroller Projects

 

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.

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!


Featured Tutorials

  • What AI can bring to PCB manufacturing
  • battery types
    What are the different battery types for specific applications?
  • battery configurations
    Battery configurations (series and parallel) and their protections
  • Choosing Batteries for Robots
  • battery cycles
    How rechargeable batteries, charging, and discharging cycles work
  • battery selection low power design
    What are the battery-selection criteria for low-power design?

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • STMicroelectronics offers multi-connectivity development kit for asset tracking
  • Renesas launches new MPUs for advanced industrial Ethernet communication
  • STMicroelectronics releases TouchGFX 4.20 for advanced graphics
  • Infineon’s new HYPERRAM memory chip doubles bandwidth
  • Vishay receives R&D grant for WATT4FRED project

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Measuring a 1GHZ Signal
  • Question about LO leakage cancellation for upconverter
  • Need help in finding distributor having components
  • Phase aliasing ambguity and simulation in MatLab?
  • A 3-stage can work correctly but 4-stage ring vco can't work

RSS Electro-Tech-Online.com Discussions

  • How to power up two stereo audio amplifiers from a single source of power supply
  • Need help for diy ups project
  • Is there a discord for this forum?
  • cadence transient and pss simulation
  • Digital Display Information
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
      • Power Electronics & Programmable Power
  • Women in Engineering