You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: