DHT22 Not Working
Your DHT22 temperature and humidity sensor is not detected or shows no readings. The dashboard shows "-" or "ERROR" for temperature/humidity. This guide covers wiring issues, pull-up resistor requirements, timing problems, and common DHT22 failures on ESP32, ESP8266, and Pico W.
Last updated: April 22, 2026 | 10 min read
Symptoms
- Dashboard shows no temperature or "-" for DHT22 sensor
- Serial Monitor shows "[SENSOR] DHT22 read failed - sending error code -999"
- Temperature reading stuck at -999C
- Humidity reading stuck at -999%
- Sensor works sometimes but not consistently
- Readings are 0C or 0% humidity
- Compilation error: "DHT.h: No such file or directory"
Common Causes
- Missing or Incorrect Pull-up Resistor Most common issue. DHT22 requires 10k pull-up between DATA and VCC
- Wrong GPIO Pin Using pin that doesn't support digital input or incorrect pin number in code
- Power Supply Issues DHT22 needs stable 3.3V-5V power; brownouts cause read failures
- DHT Library Not Installed Missing "DHT sensor library" by Adafruit in Arduino IDE
- Wiring Errors Loose connections, wrong pins, or damaged sensor
- Reading Too Frequently DHT22 needs at least 2 seconds between reads
- Faulty Sensor DHT22 may be damaged from moisture or over-voltage
DHT22 Pinout
| Pin | Name | Connect To | Notes |
|---|---|---|---|
| 1 | VDD () | 3.3V or 5V | 3.3V works well, 5V also acceptable |
| 2 () | DATA () | GPIO pin | Add 10k pull-up to VCC |
| 3 () | NC () | Leave unconnected () | Not used () |
| 4 | GND () | GND () | Common ground with ESP |
Pin 1 and Pin 4 are on opposite corners. Double-check orientation!
Correct Wiring Diagrams
ESP32 with DHT22
ESP32 DHT22
3.3V VDD
10k resistor
GPIO15 DATA
GND GND
// Recommended GPIO pins: 4, 5, 15, 16, 17
// Avoid GPIO0, GPIO2, GPIO12
ESP8266 with DHT22
ESP8266 DHT22
3.3V VDD
10k resistor
D2 DATA
GND GND
// D1 Mini pinout: D1=GPIO5, D2=GPIO4, D3=GPIO0, D4=GPIO2
// D2 is recommended for DHT22
Pico W with DHT22
Pico W DHT22
3.3V VDD
10k resistor
GPIO15 DATA
GND GND
// Pico W GPIO options: 0-22 are safe
// GPIO15 works well
Step-by-Step Fixes
1. Add Pull-up Resistor
DHT22 requires a 10k pull-up resistor between DATA and VCC:
- Connect 10k resistor between DATA pin and VCC
- Without this resistor, readings will fail or be intermittent
- Use 1/4 watt resistor
- Color code: Brown-Black-Orange-Gold
- Place resistor as close to the DHT22 as possible
// After adding pull-up resistor, test with this code:
#include <DHT.h>
#define DHTPIN 15 // Your GPIO pin
#define DHTTYPE DHT22
DHT dht;
void setup() {
Serial.begin;
dht.begin();
delay;
}
void loop() {
float temp = dht.readTemperature();
float hum = dht.readHumidity();
if || isnan) {
Serial.println;
} else {
Serial.print; Serial.print;
Serial.print; Serial.println;
}
delay;
}
2. Install DHT Library in Arduino IDE
Missing library causes compilation errors:
- Open Arduino IDE Sketch Include Library Manage Libraries
- Search for "DHT sensor library"
- Install "DHT sensor library by Adafruit"
- It will also install "Adafruit Unified Sensor" dependency
- Restart Arduino IDE after installation
3. Verify Wiring Connections
Check all connections with multimeter:
- Use continuity mode to verify VCC3.3V/5V connection
- Verify GNDGND connection
- Verify DATAGPIO pin connection
- Check for cold solder joints or loose jumper wires
- Ensure pull-up resistor is connected correctly
4. Test with Different GPIO Pin
Some pins may have issues:
- Try different GPIO pin
- Avoid GPIO0, GPIO2, GPIO12 on ESP32
- Avoid GPIO0, GPIO2, GPIO15 on ESP8266 (boot strapping pins)
- On Pico W, GPIO0-22 all work for DHT22
- Update OceanRemote firmware with new pin and re-flash
5. Check Read Interval
DHT22 requires at least 2 seconds between reads:
// WRONG - Reading too fast
void loop() {
float temp = dht.readTemperature(); // Will fail
delay;
}
// CORRECT - 2 seconds between reads
void loop() {
float temp = dht.readTemperature();
delay; // Minimum 2 seconds
}
// OceanRemote firmware uses 2-second read interval automatically
// Check if your custom code respects this timing
6. Test with Known Working DHT22
Isolate sensor vs board issue:
- Test with a different DHT22 sensor (known working)
- If new sensor works, original sensor is faulty
- If new sensor also fails, issue is wiring or board
- Test same sensor on different board
7. Check Power Supply Stability
DHT22 needs stable power:
- Measure voltage at DHT22 VCC pin
- If voltage fluctuates, add 100F capacitor between VCC and GND near DHT22
- Use separate 3.3V regulator for DHT22 if shared with relays/motors
- Avoid long wires to DHT22
DHT22 Specifications
| Parameter | Value | Note |
|---|---|---|
| Temperature Range | -40C to +80C | -40C to +125C |
| Temperature Accuracy | 0.5C | 2C for DHT11 |
| Humidity Range | 0% to 100% RH | 20-80% recommended |
| Humidity Accuracy | 2% RH | 5% for DHT11 |
| Supply Voltage | 3.3V to 5.5V | 3.3V recommended for ESP boards |
| Current Consumption | 1-2 mA | 2.5mA max |
| Sampling Period | 2 seconds minimum | Reads faster cause errors () |
Prevention Tips
- Always use 10k pull-up resistor between DATA and VCC critical for reliable readings
- Keep DHT22 away from ESP32/ESP8266 board
- Use 2-second minimum delay between reads
- Use 3.3V power for ESP32/ESP8266 compatibility
- Keep wires under 5 meters to prevent signal degradation
- For outdoor use, protect DHT22 from direct sunlight and rain
- Test with simple sketch before integrating into OceanRemote firmware
Related Issues
Frequently Asked Questions
Q: Can I use DHT22 with 5V on ESP32/ESP8266?
A: Yes, DHT22 can run on 5V. However, the DATA pin will output 5V which may damage ESP32/ESP8266 . Use a level shifter or power DHT22 at 3.3V. 3.3V works perfectly.
Q: DHT22 vs DHT11 which is better?
A: DHT22 is superior: wider temperature range , better accuracy , and higher resolution . DHT11 is cheaper but less accurate. For OceanRemote, DHT22 is recommended.
Q: Why does my DHT22 work for a few minutes then stop?
A: Most likely power supply issue or reading too fast. Ensure 2-second delay between reads. Also check that 3.3V/5V is stable. Add 100F capacitor near DHT22 if voltage fluctuates.
Still having DHT22 issues? Contact Support or return to the Troubleshooting Hub.