danjperron / PicoDHT22

Micropython DHT22 class using PIO
MIT License
49 stars 12 forks source link

Checksum always 1 off #5

Closed jlnme closed 1 year ago

jlnme commented 2 years ago

Hey, I am using this with my Pico, but I keep getting "sensor error". After some checking I saw that the sum of my first 4 result bytes is always 1 higher than the parity byte (except for very few exceptions). For example: [3, 72, 2, 37, 113] with 3+72+2+37 = 114 ≠ 113 In regard to the consistency of this, I gather that my implementation cannot be so wrong, but still it is not right. Could it be that the pull-up resistor is too small? It has 9.8kΩ, which in my opinion is not too far off. Btw, without the resistor I have the same issue.

danjperron commented 2 years ago

Hi Jlnme,

Some DHT22 have the resistor build in. Maybe a timing issue. Do you have any kind of scope to check the pulse time? It is possible to use pigpio on a raspberry Pi to get some sort of oscilloscope. https://abyz.me.uk/rpi/pigpio/piscope.html

jlnme commented 2 years ago

Hi Daniel,

I checked it with another DHT22 - it works! So the first one might have a badly sized resistor built in - do you think this might be a possible cause for my error?

Thanks & greetings, Jan

danjperron commented 2 years ago

Hi Jan,

I don't think the resistor is the problem. Maybe this particular DHT22 has a drifting clock. Try to change the PIO clock to 550KHz or 450Khz and see if that works. Again, the best way is to check the signal using a scope.

Best regards, Daniel