You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 30, 2019. It is now read-only.
Adafruit_DHT_Driver incorrect reading on long wires.
I had a problem reading the temperature and humidity from the DHT11 connected to the Raspberry Pi using wires of 10 meters. The temperature reading was way too small and the humidity was in the 120-150% ranges. Various DHT11 was tested all with the same problem.
I then used Saleae Logic 16 logic analyser to inspect the signals coming into the rapberry pi. The signals coming from the DHT11 was correct. Due to a very short pulse high created by the DHT11 after the 500ms high and 20ms low and timing issues in the current driver software the error occurs. The code appends a high bit (1) to the data stream and drops the last bit which causes the error. The short high pulse is 19us for the long wires and 12us for the DHT11 directly connected to the raspberry pi.
I was able to correct the problem by adding 7 usec sleep to Adafruit_DHT.c:
…
data[0] = data[1] = data[2] = data[3] = data[4] = 0;
// inserted to compensate for long driving lines
usleep(7);
// wait for pin to drop?
while (bcm2835_gpio_lev(pin) == 1) {
usleep(1);
}
…
I hope that the above information might be helpful to others experiencing the same issue. If the above solution can be tested, adjusted and verified for the DHT22 and AM2302 it might even be included in the source.