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

sleep(pause_secs) in __read() in DHTXX blocks the thread #4

Open
Blindfreddy opened this issue Jun 24, 2020 · 0 comments
Open

sleep(pause_secs) in __read() in DHTXX blocks the thread #4

Blindfreddy opened this issue Jun 24, 2020 · 0 comments

Comments

@Blindfreddy
Copy link

This is not strictly a defect but I would suggest to simply return the last reading if the delay has not been reached.
So acquire first reading and store it internally. Next time read() is called check if delay has been reached, as you already do, but don't sleep. Instead, if delay has not been reached return the previous reading; if it has been reached actually acquire a new reading, store it in the internal variable and return it.

Also, the delay could be a class attribute, 1s for DHT22 and 2s for DHT11 because all sensors of a given type have the same characteristic.

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

1 participant