nethoncho / Arduino-DHT22

Arduino library for the DHT22 humidity and temperature sensor
http://goo.gl/uy1fV
120 stars 123 forks source link

demo not working #12

Open nailgilaziev opened 7 years ago

nailgilaziev commented 7 years ago
DHT22 Library Demo
Requesting data...Polled to quick 
Requesting data...Sync Timeout 
Requesting data...Sync Timeout 
Requesting data...Sync Timeout 
...

adafruit library works fine and sensor is good too

jpenner64 commented 7 years ago

Ran into the same problem when porting all my work to a new laptop. During this process I upgraded Arduino IDE from 1.6.1 to 1.6.13. Compiling/Uploading on old IDE works fine, on newer version results in Sync Timeout errors.

I have ensured I am using the same project Hardware, Code, and DHT22 library, only two differences are the physical laptops, and the IDE versions. Rule out laptop immediately, but suspected that either A) some compiler settings or updates not applied, and/or B) inherently this compiler versions results AVR performance changes not compatible with the current version of the DHT22 library.

Same project hardware

Other libraries tried with success, but would like to see if there is something with this library that can be tweaked. I'll take a look and begin to understand AM2302 (DHT22) better, the DHT22 library, and other posts. However, I may he to result to using/integrating another available library.

We will see how it goes....

junwoo091400 commented 7 years ago

Yeah, I currently have my updated version of DHT22 Library on my repository named 'myCODES'. After some experiment, I found out that delayMicroseconds(2) in the .cpp file didn't actually delay 2 Microseconds but rather delayed about 1.6 us or so. So I changed all the timing settings (if(retryCount>SOMETHING)) => 'changed SOMETHING' and it worked fine. And also, the 'Sync Timeout' would likely to be caused by that too. Since the Library looks at the ACK pulse as one of those bits. However I think this is a wrong approach. This is because ACK pulse and DATA signals are completely different! ACK pulse_LOW is 80us. Which is much longer than correct pre_bitSending LOW pulse. That is probably why you get the 'Sync Timeout' . So I added 2-part ACK perceiving in my code too. If you are interested, come and check it out! I mostly changed the 'readData()' function!

mandria commented 7 years ago

i've got the same problem,

the sensor used with this library seems to give always the sync error,

i'm using arduino uno rev3 ide - arduino 1.6.10 or arduinostudio or stino2017 ST3 (same error) @junwoo091400 i'll try your version of the library, thanks for the share

nadin2 commented 6 years ago

hi how are you i am sonia kadiri please contact me here let talk sonia274898@gmail.com

SOS-Bob commented 6 years ago

Thank you junwoo091400! Wrestled with this for a while and then found this post. In DHT22.cpp file changing all the values of 'delayMicroseconds(2)' value from 2 to 5 fixed it and my gear shows now temperature and humidity values. Arduino model Genuino, DHT22 SEN0137, using guide: DHT22 Temperature and humidity module SKU:SEN0137, the only sensor library used: Arduino-DHT22-master

junwoo091400 commented 6 years ago

@SOS-Bob I'm glad to hear that I helped! Actually, after that post, I got 'sync_timeout' using my library. So I thought my modification isn't good as it should be.

So do you mean that you changed the 'original DHT22' library's delayMicroseconds(2) to delayMicroseconds(5) and it worked fine?

I will ditch my modification and try your method.

pfichtner commented 6 years ago

Got the same problem and changing the delay from 2 to 5 micros did fix it.

mrLieto commented 5 years ago

Same problem ,getting _sync_timeout. Changing 2 to 5 helped. GREAT. Thank you all.

ASDBigmac commented 5 years ago

Also worked for me using an Attiny84 @ 8Mhz for a Lorawan Project