Pages: [1]   Go Down
Author Topic: DHT22 Sensor - sync timeout  (Read 1561 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 145
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 145
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Typical - just after I post this I find a fix. smiley

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)
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14024
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Rob Tillaart

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

0
Offline Offline
Shannon Member
****
Karma: 220
Posts: 12702
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looking at the data sheet I'd suggest:
Code:
— 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...
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: