PinLab › Components › DHT22 / AM2302
AM2302 VCCDATNCGND

DHT22 / AM2302

temperature and humidity sensor

A digital sensor that measures temperature (−40…+80 °C) and relative humidity (0–100 %) and sends them over one pin. Its little brother DHT11 is cheaper but less accurate.

Open the course →

How it works

Inside is a capacitive humidity sensor and a thermistor, plus a small chip that digitises them. The ESP32 "asks" with a short pulse on the DATA line, and the sensor replies with 40 bits (humidity, temperature, checksum) using its own single-wire protocol. The Adafruit DHT.h library does all of that. Reading is allowed every 2 seconds.

Pins and wiring

PinWhat it isWhere it connects / why
VCC (pin 1)Power→ 3V3 (works at 5 V too, but 3.3 V is safer for the ESP32).
DATA (pin 2)Single-wire digital signal→ GPIO (e.g. 4). A 10 kΩ pull-up between DATA and VCC is needed on the bare sensor. The 3-pin module has it built in.
NC (pin 3)Not connectedLeave empty.
GND (pin 4)Ground→ GND.

Specifications

Temperature−40 … +80 °C, ±0.5 °C
Humidity0 – 100 % RH, ±2 %
Power3.3 – 6 V
Current1.5 mA while measuring
Periodmax 1 reading / 2 s
LibraryAdafruit DHT sensor library + Adafruit Unified Sensor

Tips and typical mistakes

Used in projects