Skip to content
Go back

DHT11 vs DHT22: Differences, Accuracy and Which to Pick

Updated:  at  04:00 PM

Quick summary

The DHT11 is fine for a simple first test indoors, when modest accuracy is enough. The DHT22, also known as AM2302 in some versions, offers a wider range and better temperature and humidity specifications, although it is still a relatively slow sensor.

If all you want to know is which one to buy for a home project, I would choose the DHT22 unless the lowest price and the simplicity are the absolute priority. If you need a fast response, professional-grade measurement or a sensor for a damp environment, it’s worth looking at other sensors.

DHT11 vs DHT22

DHT11DHT22
Temperature0–50 °C−40–80 °C
Humidity20–80 %0–100 %
Typical accuracy±2 °C / ±5 % RH±0.5 °C / ±2–5 % RH
Resolution1 °C / 1 % RH0.1 °C / 0.1 % RH
Recommended max read rate1 reading per second1 reading every 2 seconds
CommunicationOwn digital protocolOwn digital protocol

These are indicative values for the sensor families. Before publishing a buying comparison, check the manufacturer’s datasheet and the quality of the specific module: compatible boards exist with different resistors, connectors and silkscreen labels.

Which one should you pick?

Choose the DHT11 when:

Choose the DHT22 when:

Neither is the best choice for everything. To measure only temperature over a long cable, a DS18B20 may fit better. For temperature, humidity and pressure over an I2C bus, a BME280 offers a different approach. The decision depends on the environment, the distance, the speed and the maintenance, not just on the price.

Wiring with the ESP32

Both sensors come in two common formats: the bare four-pin sensor and a three-pin module with the pull-up resistor already fitted. On the four-pin version the unconnected pin is normally left alone. Always check the silkscreen on your module, because the pin order shouldn’t be taken for granted.

For a typical test with the ESP32:

  1. Connect VCC to a supply compatible with the sensor. With the ESP32 it is usually better to work at 3.3 V if the module allows it.
  2. Connect GND to the board’s ground.
  3. Connect DATA to a free GPIO, for example GPIO4, as long as it doesn’t interfere with booting or with another peripheral.
  4. If you use the bare sensor, add the pull-up resistor specified by its documentation between VCC and DATA. Many modules already include it.

Never connect a 5 V signal straight to an ESP32 GPIO. The supply voltage the module accepts doesn’t mean its signals tolerate 5 V.

Reading with ESPHome

ESPHome includes the dht component. This example shows a DHT22 reading on GPIO4; for a DHT11 you change the model. The 30-second interval avoids querying too often and lets the sensor settle.

sensor:
  - platform: dht
    pin: GPIO4
    model: DHT22
    temperature:
      name: "Living room temperature"
    humidity:
      name: "Living room humidity"
    update_interval: 30s

The DHT22 name must match the installed sensor. If the device compiles but the values are impossible, check the model, the pin, the power and the ground first. Then check the pull-up resistor and the cable length. Keep your WiFi credentials in ESPHome secrets, not in an article or a public repository.

How to interpret erratic readings

A NaN, frozen or clearly impossible reading doesn’t by itself prove the sensor is broken. Work through the problem in this order:

  1. Power and ground: measure the voltage at the module itself, not only at the supply.
  2. Pin and model: the declared GPIO must be the one you wired, and the model must match the sensor.
  3. Pull-up: the bare sensor needs the right resistor; a module usually includes it, but you have to check.
  4. Interval: don’t request readings faster than the sensor allows.
  5. Wiring: shorten the cable for the test and avoid running it next to loads or cables that introduce noise.
  6. Condensation: neither sensor is designed to sit exposed to water or constant condensation without proper protection.

To compare two sensors, place them together over a stable period and don’t expect them to match to the last decimal. What matters is whether they respond consistently to known changes, such as ventilating the room or bringing a source of humidity closer without wetting the sensor.

Conclusion

The DHT11 is valid for learning and for simple indications. The DHT22 is the more balanced option if you want more range and resolution without moving to a sensor from another family. In both cases, the wiring, the reading interval and the power supply matter as much as the specification table.

If you still haven’t chosen the board, check ESP32: what it is, what it’s for and how to get started. To see how this setup fits into a complete automation, go back to the home automation for beginners guide.

External sources

The homeiotguide editorial team

Editorial lead: Néstor Espuch


Suggest changes
Share this article on:

Previous article
How Much Water Each Plant Needs: The Real Calculation
Next article
Home Automatic Irrigation: A Complete Starter Guide