ESP32, ESP8266 & Raspberry Pi, lesson 18 of 33

How to interface the Humidity Sensor DHT11 with the ESP32 (Web Server)

advanced6 min readFull course

Need the HTML? This lesson's web page uses HTML. Learn just the tags you need in HTML for Gadgets, or keep the cheat sheet open.

Measuring Temperature, humidity is become an important task in lives. As we monitor temperatures in various places for example a freezer or a cake shop. The Cake shop needs to maintain a low temperature else the icing on the cakes will substantially melt. In this project, we will build a system that will monitor the temperature and humidity with the ESP32 and will be able to monitor the same using a local webpage.

The ESP32 has an inbuilt temperature sensor, but it fails miserably considering that the ESP32 dissipates its own heat. In such cases we cannot accurately measure the temperature.

Few things you might need to know before we get going:

  1. Installation of the Arduino IDE for the ESP32
  2. Configuration of the ESP32
  3. How to create a Web Server using ESP32
  4. Basic HTML knowledge is recommended

In this tutorial you will learn how to measure the temperature and humidity. The DHT sensors have an on-board chip that converts the analog temperature to digital form. The DHT sensors are almost compatible to use with any microcontroller. We will be using the DHT11 in our project. (You can use any model of the DHT, but make sure the conversions in the code are done correctly.)

Components Required

  • ESP32 x 1
  • DHT11 x 1
  • 220Ω Resistor x 1
  • Breadboard
  • Jumper Cables

How does the DHT11 or Humidity Sensor Work?

The humidity sensing component of the DHT11 is a moisture holding substrate with the electrodes applied to the surface. When water vapor is absorbed by the substrate, ions are released by the substrate which increases the conductivity between the electrodes. The change in resistance between the two electrodes is proportional to the relative humidity. Higher relative humidity decreases the resistance between the electrodes while lower relative humidity increases the resistance between the electrodes.

Arduino: wake up! (pulls the wire LOW) A short HIGH pulse means 0, a long one means 1.

How to interface the Humidity Sensor DHT11 with the ESP32 (Web Server) | Electronics Simplified