The DHT22 is a low-cost digital sensor that measures air temperature and relative humidity, and it is the part most people meet first. Sold for a few dollars, often on a small breakout or as the wired AM2302, it gives a usable reading over a single data wire with almost no fuss. It is not the most accurate sensor here, but for learning and hobby climate monitoring it is hard to beat for the price.
What it is.
The DHT22 pairs a capacitive humidity element with a thermistor and a small chip that does the conversion for you, so it hands the microcontroller a finished digital reading rather than a raw voltage. That makes it easy to use and noise-resistant. The trade-offs are its speed and its accuracy: it returns only about one reading every two seconds, its humidity figure can drift a few percent as the element ages, and it is not weatherproof. The wired AM2302 is the same sensor in a cabled housing.
Key facts.
How to wire it.
Three connections, sometimes four. Power to VCC (3.3 or 5 V), ground to GND, and the DATA line to any GPIO on your microcontroller. The data line needs a pull-up resistor (about 10 kΩ to VCC); many breakout boards already include one, so check before adding your own. In code, a DHT library (built into ESPHome, and a one-line install in the Arduino IDE) reads it. Because it answers slowly, read it on a timer of a few seconds, not in a tight loop.
Where it fits, and where it doesn’t.
Where it fits
- A first sensor, to learn on.
- Cheap hobby climate monitoring in a tent or room.
- Many nodes where one odd reading is averaged out.
- Indoor use, away from sun and rain.
Where it doesn’t
- Readings you act on; the accuracy is loose.
- Fast changes; it answers only every couple of seconds.
- Outdoors unprotected; it is not weatherproof.
- Long-term humidity precision; it drifts as it ages.
A better option?
If the reading is going to drive a decision, spend a few dollars more on an SHT31, which is markedly more accurate and reads over the tidy I²C bus. If you also want barometric pressure, the BME280 adds it. The temperature and humidity overview compares them all. Keep the DHT22 for learning and for cheap, forgiving jobs.
Datasheet & where to buy.
DHT22 datasheet (PDF) Where to buy Compare temp & humidity sensors
Frequently asked questions.
What is a DHT22 used for?
It measures air temperature and relative humidity and sends a digital reading to a microcontroller. It is a common, cheap first sensor for hobby climate monitoring in a tent, room, or small greenhouse.
How accurate is the DHT22?
About plus or minus 0.5 degrees C on temperature and 2 to 5 percent on humidity, per the datasheet, and the humidity figure drifts as the element ages. It is fine for a rough sense of the climate; for readings you act on, an SHT31 is markedly more accurate.
What is the difference between the DHT22 and the AM2302?
They are the same sensor. The AM2302 is the DHT22 in a wired housing with a cable, which is handier for mounting. Both behave identically and use the same one-wire digital protocol.
Does the DHT22 need a pull-up resistor?
Yes, the data line needs a pull-up of about 10 kilohms to the supply. Many breakout boards already include one, so check your board before adding another; the bare three-pin sensor usually needs you to add it.
Can I use the DHT22 outdoors?
Not directly; it is not weatherproof. Outdoors it needs a vented radiation shield to keep sun and rain off the element while still sampling the air. For temperature in wet spots, a sealed DS18B20 probe is the better tool.