ESP32 DHT11 Temperature and Humidity Sensor

DHT11 Temperature and Humidity Sensor image

DHT11

Protocol: Analog

Overview

The DHT11 is a low-cost digital sensor for measuring temperature and humidity. It provides calibrated digital outputs and is easy to interface with microcontrollers. With a temperature measurement range of 0-50°C and humidity range of 20-90%, it's suitable for basic environmental sensing applications.

About DHT11 Temperature and Humidity Sensor

The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and outputs a digital signal on the data pin (no analog input pins needed). It’s fairly simple to use, but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds.

Where to Buy

DHT11 Temperature and Humidity Sensor

Starting from

$2 per unit

Amazon com
Amazon.com Ships worldwide
View Price
Amazon de
Amazon.de Ships to EU
View Price
Aliexpress
AliExpress Best value
View Price

Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.

Technical Specifications

Interface Single-Wire Digital
Temperature Range 0°C to 50°C
Humidity Range 20% to 90% RH
Temperature Accuracy ±2°C
Humidity Accuracy ±5% RH
Operating Voltage 3.3V to 5.5V
Sampling Rate Once every 2 seconds

Pinout Configuration

The VCC pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND pin is the ground connection and must be connected to the ground of your ESP32.

The DHT11 pinout is straightforward:

  • VCC (Power): Connect to 3.3V or 5V power supply.
  • DATA: Outputs digital signal; connect to a digital input on your microcontroller.
  • NC (Not Connected): No connection required.
  • GND (Ground): Connect to the ground of the microcontroller.

Wiring with ESP32

To interface the DHT11 with an ESP32:
  • Connect the VCC pin to the 3.3V or 5V pin on the ESP32.
  • Connect the GND pin to the ground (GND) of the ESP32.
  • Connect the DATA pin to a digital GPIO pin on the ESP32 (e.g., GPIO 4).
  • Place a 10kΩ pull-up resistor between the DATA pin and VCC to ensure reliable communication.

Troubleshooting Guide

Common Issues

❌ Failed to Read from DHT Sensor

⚠️ Inaccurate Humidity Readings

🔋 Power-Related Issues

❌ Sensor Not Detected on I2C Bus

Debugging Tips

🔍 Serial Monitor

⚡ Voltage Checks

Code Examples

Arduino Example

C++
🔧

ESP-IDF Example

C++
🏠

ESPHome Example

YAML
🛠️

PlatformIO Example

C++
🐍

MicroPython Example

Python

Conclusion

The ESP32 DHT11 Temperature and Humidity Sensor is a powerful environment sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.

For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.

Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.