winlinvip / SimpleDHT

Simple, Stable and Fast Arduino Temp & Humidity Sensors for DHT11 and DHT22. http://learn.adafruit.com/dht
MIT License
145 stars 61 forks source link

Reading errors #15

Closed tomiisp closed 6 years ago

tomiisp commented 6 years ago

DHT22 with ESP8266 producing in my case a lot of repeating read errors (sample rate 5sec), error rate was about 9:1 (error:success). Little looking in code and here seems was that issue:

int SimpleDHT::confirm(int pin, int us, byte level) {
...  
      delayMicroseconds(10);
...
}

changing delayMicroseconds(10); to delayMicroseconds(20); fix this problem, 0 errors after 2hours of testing

winlinvip commented 6 years ago

It may fix the problem, but I think it's not the right answer. I think we must find out why delay(10us) caused the error, right?

vitamins commented 6 years ago

I tried to apply this and it didn't help, the number of errors increased. The adafruit library is working fine for me. https://github.com/adafruit/DHT-sensor-library

winlinvip commented 6 years ago

I think the confirm function, which split us to pieces of 10us, causes deviation.

glewellyn commented 6 years ago

Again, no root cause, but increasing the delayMicroseconds to 20 did solve my problem as well.

winlinvip commented 6 years ago

Please test 1.0.9