Auto Detect (DHT11 vs DHT22) not reliable
liwenyip opened this issue · 1 comments
liwenyip commented
See below - this is the output I get using the example sketch with a DHT22 connected.
Each blank line indicates when I've pressed the reset button on the Arduino.
NB I'm using a modified version of the example sketch that checks dht.getModel()
after dht.setup()
is called - see liwenyip@ff1c976
Auto-detected DHT11
Status Humidity (%) Temperature (C) (F)
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
Auto-detected DHT22
Status Humidity (%) Temperature (C) (F)
OK 54.4 27.8 82.0
OK 54.2 27.8 82.0
OK 54.7 27.8 82.0
Auto-detected DHT11
Status Humidity (%) Temperature (C) (F)
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
Auto-detected DHT22
Status Humidity (%) Temperature (C) (F)
OK 54.7 27.8 82.0
OK 54.5 27.8 82.0
OK 54.8 27.8 82.0
OK 54.7 27.8 82.0
OK 54.6 27.8 82.0
Auto-detected DHT22
Status Humidity (%) Temperature (C) (F)
OK 54.7 27.8 82.0
OK 55.0 27.8 82.0
Auto-detected DHT22
Status Humidity (%) Temperature (C) (F)
OK 55.0 27.8 82.0
OK 54.5 27.8 82.0
Auto-detected DHT22
Status Humidity (%) Temperature (C) (F)
OK 54.9 27.8 82.0
OK 54.9 27.8 82.0
OK 54.8 27.8 82.0
OK 54.3 27.9 82.2
Auto-detected DHT11
Status Humidity (%) Temperature (C) (F)
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
OK 2.0 1.0 33.8
Auto-detected DHT22
Status Humidity (%) Temperature (C) (F)
OK 54.3 27.9 82.2
OK 54.0 28.0 82.4
OK 53.9 28.0 82.4
panigrc commented
I've solved it by hard-coding the sensor type for example:
#define DHT_DATA_PIN 3
#define DHT_TYPE DHT::AM2302
void setup()
{
dht.setup(DHT_DATA_PIN, DHT_TYPE);
}