DHT11 / DHT22 shows nan, 0 or -999
- DHT11
- DHT22
You may see
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
- Check the pin:
#define DHTPINmust match the wire. - Check the type: blue is usually DHT11, white is usually DHT22.
- Add
delay(2000);between readings. - Bare sensor: put a 10 kΩ resistor between DATA and VCC.
- 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.
Tutorials where it can happen
- DHT11 Temperature and Humidity Sensor with Arduino
- Air Quality and HVAC Control with Arduino, DHT11 and MQ-135
- Arduino Greenhouse: Temperature and Humidity Control with LCD
- ESP32 DHT11 Web Server: Show Temperature and Humidity
- Log DHT11 Data to Firebase Realtime Database: the Code
- Mini Weather Station with Arduino, DHT11 and 16x2 LCD
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.

