DHT11 / DHT22 shows nan, 0 or -999

  • DHT11
  • DHT22

You may see

Failed to read from DHT sensor!
Temperature: nan
nan
-999.00

Why it happens

  • The data wire is on another pin than the code says.
  • DHT11 is chosen in the code but you have a DHT22, or the other way round.
  • It's being read too often.
  • A bare 4-pin sensor has no pull-up resistor.
  • Loose power or a long wire.

How to fix it

  1. Check the pin: #define DHTPIN must match the wire.
  2. Check the type: blue is usually DHT11, white is usually DHT22.
  3. Add delay(2000); between readings.
  4. Bare sensor: put a 10 kΩ resistor between DATA and VCC.
  5. Check the pin order printed on your module: some are + out −, others are S + −.

It worked if: Breathe on it: the humidity rises within a few seconds.

From the official documentation. "nan" read in the Adafruit library source; −999 is DHTlib's invalid value. Sources: Adafruit DHT library.

Didn't help? Search another error or ask us.