ESP32 DHT22 / AM2302 Temperature and Humidity Sensor

DHT22 / AM2302 Temperature and Humidity Sensor image

DHT22 / AM2302

Protocol: Analog

Overview

The DHT22 is a versatile and affordable sensor for measuring temperature and humidity. It provides calibrated digital output and is easy to interface with microcontrollers. With a temperature measurement range of -40°C to 80°C and humidity range of 0% to 100%, the DHT22 is suitable for a variety of applications, including environmental monitoring and HVAC systems.

About DHT22 / AM2302 Temperature and Humidity Sensor

The DHT22, also known as AM2302, is a low-cost digital sensor designed for precise temperature and humidity measurement. It uses a capacitive humidity sensor and a thermistor for reliable data collection and communicates via a single-wire digital interface, ensuring easy integration with ESP32, Arduino, and other microcontrollers.

Key Features

  • Improved Accuracy & Range – More precise than DHT11, with a wider measurement range.
  • Single-Wire Communication – Simple interfacing with microcontrollers.
  • Capacitive Humidity Sensing – Ensures stable and long-term performance.
  • Ideal for Demanding Applications – Used in weather stations, HVAC systems, and industrial monitoring.

With its affordability and high accuracy, the DHT22 is a great choice for climate monitoring and smart home applications. 🚀

Where to Buy

DHT22 / AM2302 Temperature and Humidity Sensor

Starting from

$5 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

Operating Voltage 3.3V to 5.5V
Temperature Range -40°C to 80°C
Humidity Range 0% to 100% RH
Temperature Accuracy ±0.5°C
Humidity Accuracy ±2% RH
Sampling Rate 0.5 Hz (once every 2 seconds)
Dimensions 15.1mm x 25mm x 7.7mm

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 DHT22 pinout is as follows:

  • Pin 1 (VCC): Connect to 3.3V or 5V power supply.
  • Pin 2 (DATA): Outputs digital signal; connect to a digital input on your microcontroller.
  • Pin 3 (NC): Not connected; leave unconnected.
  • Pin 4 (GND): Connect to the ground of the microcontroller.

Wiring with ESP32

To interface the DHT22 with an ESP32:
  • Connect Pin 1 (VCC) to the 3.3V or 5V pin on the ESP32.
  • Connect Pin 4 (GND) to the ground (GND) of the ESP32.
  • Connect Pin 2 (DATA) 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

❄️ Incorrect Readings at Sub-Zero Temperatures

⏸️ Sensor Stops Responding After Prolonged Use

⚡ Interference with Other I2C Devices

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 DHT22 / AM2302 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.