Skip to content
A

Temperature & Humidity

Interfacing DHT22 Temperature & Humidity with Arduino Uno

What is the DHT22?

The DHT22 (also sold as the AM2302) is a digital temperature and humidity sensor built around a capacitive humidity element and a precision NTC thermistor, both read out over the same single-wire digital bus used by the rest of the DHT family. It's the sensor to reach for once a project outgrows the DHT11 — it holds calibration well, covers a genuinely wide operating range, and drops into the exact same code and wiring most makers already know.

The tradeoffs are modest: it samples at roughly half the rate of the DHT11 (about once every 2 seconds) and costs a couple of dollars more. In exchange you get ±0.5°C temperature accuracy, ±2% RH humidity accuracy, and reliable operation from -40°C up to 80°C — cold enough for an outdoor winter enclosure and hot enough for most indoor equipment bays. If your project only needs a rough indoor reading and you want a faster refresh, the pin- and library-compatible DHT11 is the cheaper, quicker option — see the variants table below.

Specifications

Operating voltage3.3V – 6V DC
Operating current1–1.5 mA (measuring), 40–50 µA (standby)
Temperature range-40°C to 80°C
Temperature accuracy±0.5°C
Humidity range0% to 100% RH
Humidity accuracy±2% RH
Resolution16-bit (0.1°C / 0.1% RH steps)
Sampling rate0.5 Hz max (once every 2s recommended)
InterfaceSingle-wire digital (proprietary, not I2C/SPI)

DHT22 Pinout

PinNameDescription
1VCCPower, 3.3V–6V DC
2DATASingle-wire digital I/O — needs a 4.7kΩ–10kΩ pull-up to VCC
3NCNot connected — leave floating
4GNDGround

Most breadboard-friendly DHT22 modules (often labeled AM2302) expose only 3 pins (VCC, DATA, GND) because the pull-up resistor and a decoupling capacitor are already built onto the breakout PCB. If you're wiring the bare 4-pin sensor directly, add a 4.7kΩ–10kΩ resistor between DATA and VCC yourself — without it the data line floats and reads fail intermittently or return NaN. Longer cable runs (a few meters) tend to be more reliable with a stronger pull-up toward the 4.7kΩ end of that range.

Setting Up DHT22 with Arduino Uno

Library

DHT sensor library by Adafruit

Arduino IDE → Tools → Manage Libraries → search "DHT sensor library" by Adafruit → Install (accept the prompt to also install the "Adafruit Unified Sensor" dependency)

Library guide

Wiring

Component pinArduino Uno pinNote
VCC5V
DATAD2Add a 4.7kΩ–10kΩ pull-up resistor between DATA and VCC if you are using the bare 4-pin sensor — most 3-pin AM2302 breakout modules already have one built in.
GNDGND

Example code

C++
  • The very first read after power-up is often invalid — that's normal, not a wiring fault. Give it a couple of seconds.
  • Keep the sensor lead under a few meters unless you're using shielded cable and a stronger pull-up; the single-wire protocol has no error correction and is sensitive to noise on long runs.
  • dht.readTemperature(true) returns Fahrenheit directly if you'd rather not convert yourself.
  • Because the DHT22 reports 0.1° / 0.1% resolution, don't round your Serial prints too aggressively if you want to see the improvement over a DHT11.

Related Components

Related Guides & Projects