Sub topic 2
Meet the DHT11 and DHT22
Assume you know the basic Arduino setup() and loop() structure, can upload a sketch, use the Serial Monitor, and connect components on a breadboard. This chapter focuses on choosing between the DHT11 and DHT22 before wiring and programming them.
A DHT sensor measures two related conditions:
- Temperature is how hot or cold the air is.
- Relative humidity is the amount of water vapor in the air compared with the maximum amount the air could hold at that temperature.
Relative humidity is expressed as a percentage. For example, 50% relative humidity means the air contains about half the water vapor it could hold at its current temperature. Warmer air can hold more water vapor, so the same amount of vapor can produce a different humidity reading at different temperatures.
DHT11 and DHT22 compared
The DHT11 is inexpensive and suitable for simple demonstrations or indoor projects with a moderate climate. The DHT22, also called the AM2302, has a wider measurement range and generally better resolution and accuracy.
| Characteristic | DHT11 | DHT22 |
|---|---|---|
| Temperature range | 0 to 50 °C | -40 to 80 °C |
| Temperature accuracy | About ±2 °C | About ±0.5 °C |
| Humidity range | 20 to 80% RH | 0 to 100% RH |
| Humidity accuracy | About ±5% RH | About ±2 to 5% RH |
| Humidity resolution | 1% RH | 0.1% RH |
| Minimum read interval | About 1 second | About 2 seconds |
| Typical cost | Lower | Higher |
The exact specifications can vary by manufacturer and module version. Check the sensor's datasheet when the project depends on a particular accuracy or operating limit.
The DHT22 is usually the better choice for outdoor monitoring, rooms with changing humidity, or projects that need decimal readings. The DHT11 is reasonable when low cost matters more than precision and the expected conditions remain within its narrower range.
Why the sensor needs both readings
Temperature and humidity affect comfort, condensation, plant growth, and electronics. A humidity value without temperature provides incomplete information because relative humidity changes when temperature changes. A room can show a lower relative humidity after heating even if no water vapor left the room.
The two sensors use an internal humidity element, a temperature element, and a small controller. The controller converts those measurements into digital data. Your Arduino receives the result rather than measuring a changing analog voltage directly.
Important operating limits
A DHT sensor is not a fast instrument. It stores or processes a measurement and needs time before the next valid conversion. Reading it repeatedly in a tight loop can produce stale or failed results. The DHT22 normally requires at least two seconds between readings. The DHT11 is often specified for about one second.
The sensor's range is also a hard limit. A DHT11 should not be selected for freezing conditions, and neither sensor should be treated as a laboratory reference. Condensation, direct sunlight, poor airflow, long wires, and electrical noise can make readings less reliable.
Choosing a sensor
Use the DHT11 when:
- The project is a low-cost indoor demonstration.
- Whole-number readings are sufficient.
- Temperature will stay between 0 and 50 °C.
- Humidity will usually stay between 20% and 80%.
Use the DHT22 when:
- The project may encounter cold or hot conditions.
- Decimal resolution is useful.
- You need a wider humidity range.
- You can wait at least two seconds between samples.
Both devices use a single digital data line, but they are not interchangeable in software. The library configuration must identify the correct sensor type. The following chapters cover the wiring, library setup, and reading code.
Exercise
You need to monitor a greenhouse that may reach 55 °C and whose humidity can range from 10% to 95%. Which sensor is the safer choice, and why?
Show answer
Choose the DHT22. Its rated temperature range includes 55 °C, and its humidity range includes both 10% and 95%. The DHT11 is outside its rated range in both cases.