-
Notifications
You must be signed in to change notification settings - Fork 62
Reading DHT failing: "Checksum did not validate." #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
what if you measure a few times? like in a loop, does it ever work? |
(note it may not work because of ESP8266's RTOS, its not great at precision timing stuff) |
It seems to fail reliably. I tried it in a loop like this: import board
import adafruit_dht
import time
d = adafruit_dht.DHT22(board.GPIO4)
def checkdht():
for i in range(10):
try:
d.measure()
t = d.temperature
print('got temp:', t)
except RuntimeError:
print('Failed')
time.sleep(3) It fails every time. It seems to work reliably under micropython |
I see the same behavior on another board as well. |
FWIW - I just tried a DHT22 on an Adafruit Feathere Huzzah ESP8266 with the current CP master build
Here is a test script I use
I also tried you r test code (added a call to checkdht)
I am used to seeing occasional bad reading -- failed checksums with the dht22 but it usually works - most of the time - I just catch the erros and continue on. For the tests I ran this morning I had not errors at all. |
just to be sure- I re-updated my repo and rebuilt - now have same build as OP -- all still works.
|
Where should we go with this - I was not able to reproduce it on an ESP8266 ? |
I don't know. I can reproduce it on multiple boards, but they're all the same sort of Wemos D1 mini clone. They work fine both with micropython 1.9.3 and with the esp-open-rtos example code. I'm not sure what it is about recent CircuitPython/MicroPython that changed. Since this isn't impacting the adafruit boards I understand that this isn't going to be a priority. You can go ahead and close this if you think we've hit a wall in terms of diagnostics. I'll try to poke at it a bit in my spare time. If I ever do figure it out I'll submit a PR. |
Have you tried it with MicroPython 1.9.4? That is the release CircuitPython has merged. Still does not identify the root cause but it is consistent. |
Also, there have been some probably unrelated updates since that version of the DHT library. It might be worth trying the latest release. edited to add -- likely irrelevant -- now that I understand that is doesn't to work on MP 1.9.4 it looks like the focus should be on that but it appears to only impact the WEMOS D1 -- no idea why. |
@larsks What DHT sensor are you using -- It was not clear from the linked discussions fi you have a pullup resistor on the DHT22 data line. I use a 10K resistor on mine. |
FYI - I tried a DHT22 on my Feather Huzzah ESP8266 with Micropython 1.9.4 and it works:
This does appear to be specific to the WEMOS D1 and I don't have one to experiment with. |
The plot thickens: I have a number of boards that the wired version of the DHT22 sensor soldered on. These are the ones experiencing a problem. They don't have an external pullup attached, although in theory the internal pullups on the esp should be sufficient. I have a few spares of the pin version of the DHT22 sitting around, so I grabbed one of those so I could try with and without an external pullup...and I was unable to reproduce the problem regardless of how I wired it. I'm going to close this issue for now as having too many unknowns. Frustrating! But at this point I think I don't know enough about what's going on. Maybe some quality time with an oscilloscope would shed some light on the situation. |
puzzling -- I just saw that the guide https://learn.adafruit.com/dht/connecting-to-a-dhtxx-sensor now says that both the dht22 and am2302 have internal pullups! I don't know if that was changes since I first started using these or I just missed it ... I tried it on Micropython 1.9.4 as above without the pull-up and it still works. |
I just measured the resistance between Vin and Data on the DHT22 and it is 4.7K ohms !! |
This has been fixed upstream in micropython/micropython#4415. |
@larsks Why reopen? That fix is in micropython, not a Python library. |
Will, it was a fix to the problem of dht modules not working correctly. If you don't think it's relevant to this issue, close it back up! |
Closing. |
I'm running CircuitPython (adafruit/circuitpython@2933451) on a Wemos D1 Mini, using revision da125e7 of the DHT module. When I run this code:
If I add a
print(pulses)
around line 178, I see:This works correctly with upstream micropython v1.9.3 (but fails in
v1.9.4 apparently due to micropython/micropython#4233).
The text was updated successfully, but these errors were encountered: