-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improvement: Not lock / hangs when DHT22 is still not ready. #176
Comments
i think this is important, i was working on my program using dht22 and i try to see what happen if sensor is not connected, to create an error condition and programs gets lock. it would be appreciated if it returned value -1 for humidity when there is no reading and avoid any possible lock. i tried to follow this program to manually correct it but can't find where the lockdown happens. |
After experimenting a bit more i get to the problem. maxcycles gets its value in: To check cycle time in my microcontroller i use the same function the library use --> ` while (true) |
just to add to the preview comment, now when i got no lecture it return float value nan, so i create de function:
To check if i have sensor readings or not. |
Arduino board: Bluepill STM32F103
Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.13
List the steps to reproduce the problem below (if possible attach a sketch or
copy the sketch code in too):
If I try to read the sensor before the two seconds delay after powering up the board, the library locks the entire program.
It may be of use if the library simply ignores the reading and do not lock the program flow.
The unlocking behaviour can help in situations where the sensors can get disconnected or can lost power or data conection randomly (or in a hot plug manner).
The actual behaviour of get locked on the read call can sometimes difficult debuging more complex applications. That was my situation where my applitacion worked while developing / programming but not on production (because I just powered the board some seconds before uploading the sketch, giving enouth time for the DHT being ready. But on production the program starts inmediately and don't give enough time for DHT being ready).
Of course, I must actually use a delay of two seconds before reading something from the sensor and it works for now.
Code example:
The text was updated successfully, but these errors were encountered: