Your Cart
Loading cart...
Items 0
Sub-Total USD 0.00
Sensors & IoT Beginner 25 min read 5 steps

Reading a DHT22 Temperature / Humidity Sensor with Arduino

Wire a DHT22 to an Arduino UNO, install the library, read temperature and humidity to the Serial Monitor. ~25 minutes including time to find a clean reading.

Published Jun 26, 2026 Updated Jun 26, 2026 5 views

The DHT22 (AM2302) is the most popular maker-grade temperature + humidity sensor. ±0.5 °C accuracy, ±2 % humidity, single-wire digital interface. Perfect first sensor project, especially for Zimbabwean greenhouse / weather-station builds.

1

Parts list

- Arduino UNO (or any 5 V Arduino)
- DHT22 sensor (BlitzTech: SEN-DHT22)
- 10 kΩ pull-up resistor
- Breadboard + 3 jumper wires
- The DHT22 comes in two flavours: bare sensor (3 pins) and module-on-a-PCB (3 pins, pull-up already on board). If you have the module, you can skip the external resistor.

2

Wiring

Looking at the DHT22 with the grille facing you, pins from left to right:

1. VCC → Arduino 5 V
2. DATA → Arduino digital pin 2 (also connect via 10 kΩ pull-up resistor to 5 V)
3. (skip, not used on 3-pin variant)
4. GND → Arduino GND

If your DHT22 is a 4-pin bare-sensor, pin 3 is unused.

3

Install the library

In Arduino IDE: Tools → Manage Libraries → search 'DHT sensor library' by Adafruit. Install both 'DHT sensor library' and its dependency 'Adafruit Unified Sensor'.

4

The sketch

Paste this into a new sketch, save it, upload, then open Tools → Serial Monitor (set baud rate to 9600). You should see a fresh reading every two seconds. DHT22 can't be polled faster than every 2 seconds, that's a hardware limit, not the code.

#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
}

void loop() {
  delay(2000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  if (isnan(h) || isnan(t)) {
    Serial.println(F("Sensor read failed!"));
    return;
  }
  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.println(F("°C"));
}
5

Troubleshooting

- All NaN readings → pull-up resistor is missing or the data pin is wrong
- Frozen at one reading → wiring is loose or the DHT22 is faulty (try a second one)
- Wildly wrong humidity → the sensor was stored in a humid box; let it acclimatise for 30 min

Community Q&A

Questions about this guide

No questions yet — be the first to ask!

Ask a question

Questions are reviewed before appearing.
Maker Gallery

People who built this

No builds shared yet — yours could be the first!

Share your build

Reviewed before publishing.

Got stuck on this guide?

Drop us a message. We'd rather hear that a step is unclear than have you give up.