Skip to content
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

Getting error SimpleDHTErrStartLow unnecessarily #35

Open
timcharper opened this issue Feb 22, 2019 · 2 comments
Open

Getting error SimpleDHTErrStartLow unnecessarily #35

timcharper opened this issue Feb 22, 2019 · 2 comments

Comments

@timcharper
Copy link

timcharper commented Feb 22, 2019

In my DHT sensor, I'm consistently seeing a low time of 23-24us measured here:

https://github.com/winlinvip/SimpleDHT/blob/1.0.12/SimpleDHT.cpp#L220

I'm not sure if it's because the microcontroller I'm using has timing issues, or it's an odd DHT sensor, but simply reducing the threshold from 30 to 20 is the difference between the sensor failing continuously, and consistently reading successfully.

Would it make sense to allow this threshold to be customizable? Will it break things to allow slightly faster values?

@timcharper
Copy link
Author

@winlinvip I experimented with this and found the issue; pinMode can take a variable amount of microseconds to complete. Further, per the spec, you're supposed to leave the pin HIGH for 25 microseconds, and then read (and expect a high value from the sensor within 80 microseconds).

I rewrote the timing code to use a stop-watch style approach and it made things much more stable; allowing the pinMode change to be included in the 80 microseconds for which we're waiting for the high signal from the sensor has completely erased the non-determinism I was seeing and I'm getting significantly more stable readings.

https://github.com/timcharper/UniversalDHT/blob/master/UniversalDHT.cpp#L132

@winlinvip
Copy link
Owner

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants