Go Down

Topic: DHT22 Sensor - sync timeout (Read 1 time) previous topic - next topic

GregM

I've wired up a DHT22 Sensor and am using Arduino 1.0 with ringerc's library
https://github.com/ringerc/Arduino-DHT22

I've loaded up the example and although it works - its very intermittent. Any idea where I'm going wrong? I"m powering it from a 5V stable source.

Quote
Integer-only reading: Temperature 27.2 C, Humidity 41.5 % RH
Requesting data...Sync Timeout
Requesting data...Sync Timeout
Requesting data...Sync Timeout
Requesting data...Sync Timeout
Requesting data...Sync Timeout
Requesting data...Sync Timeout
Requesting data...Got Data 27.20C 41.60%
Integer-only reading: Temperature 27.2 C, Humidity 41.6 % RH
Requesting data...Sync Timeout
Requesting data...Got Data 27.20C 41.70%
Integer-only reading: Temperature 27.2 C, Humidity 41.7 % RH

GregM

Typical - just after I post this I find a fix. :)

Found this on Sparkfun - works like a bomb now!

Quote
I was using NetHoncho's library, and was getting only maybe one out of ten readings correct. The rest were sync timeout errors.
I modified his library to retry up to 70 times instead of 35 times, and that did the trick. Look for this line in his lib:
if (retryCount > 35) //(Spec is 50 us, 352 == 70 us)
-- and change it to this --
if (retryCount > 70) //(Spec is 50 us, 352 == 70 us)

robtillaart

Did some dhtlib too, you might give it a try. Interface is (of course) quite similar - http://arduino.cc/playground/Main/DHTLib -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

MarkT

Looking at the data sheet I'd suggest:
Code: [Select]

-- and change it to this --
if (retryCount > 50) //(Spec is 80 us, 50x2 == 100 us)


(There are no mentions of 50us in the datasheet - looks like a misreading of "80" as "50")
Also all of the timing is a bit off in that library as the assumption of 2us round each loop is a poor one (each loop has several other tests in it, not just a call to delayMicroseconds(2) - probably more like 2.5 to 3us round each loop, and worse on an 8MHz board like the Lilypad...
[ I won't respond to messages, use the forum please ]

Go Up