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 voltage | 3.3V – 6V DC |
| Operating current | 1–1.5 mA (measuring), 40–50 µA (standby) |
| Temperature range | -40°C to 80°C |
| Temperature accuracy | ±0.5°C |
| Humidity range | 0% to 100% RH |
| Humidity accuracy | ±2% RH |
| Resolution | 16-bit (0.1°C / 0.1% RH steps) |
| Sampling rate | 0.5 Hz max (once every 2s recommended) |
| Interface | Single-wire digital (proprietary, not I2C/SPI) |
DHT22 Pinout
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power, 3.3V–6V DC |
| 2 | DATA | Single-wire digital I/O — needs a 4.7kΩ–10kΩ pull-up to VCC |
| 3 | NC | Not connected — leave floating |
| 4 | GND | Ground |
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)
Wiring
| Component pin | Arduino Uno pin | Note |
|---|---|---|
| VCC | 5V | — |
| DATA | D2 | Add 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. |
| GND | GND | — |
Example code
- 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

Arduino Uno R3 Pinout: Every Pin Explained (Digital, Analog, PWM, Power)
Complete Arduino Uno R3 pinout reference: all 14 digital pins, 6 analog inputs, PWM, UART, SPI, I2C, AREF, and power rails explained with wiring tips and common mistakes.

Ultimate Arduino Mega 2560 Pinout Guide: Complete Power & I/O Reference
Master the Arduino Mega 2560 pinout. Detailed reference for all 54 digital pins, 16 analog inputs, PWM, UARTs, SPI, I2C, interrupts, and power. Includes a printable table and practical wiring tips.

Interfacing HC-SR04 Ultrasonic Sensor with Arduino
Measure distance accurately using ultrasonic sound waves and an Arduino Uno — no complex math, no expensive hardware.
HC‑SR04 Ultrasound Distance Measurement with Arduino – Parking Alert (LCD & Buzzer)
Learn HC‑SR04 ultrasound distance measurement with Arduino Uno. Build a parking alert system with 16x2 LCD and buzzer – shows distance and beeps faster as you approach.