-
Notifications
You must be signed in to change notification settings - Fork 10
hasValue
a non-blocking function that asks for a new value.
bool hasValue(bool forceSensor = false);
true if a new value is measured.
If true, a physically read to the sensor is executed.
If false (default), the function returns immediately if the calculated conversion time is not reached.
After the calculated conversion time has expired, always a true read is done, until timeout is reached.
Why you don't should use forceSensor = true
?
If you ask hasValue()
, with a calibrated sensor, normally only one true reading is done to the sensor.
This is much faster than do a physically read.
With a ESP8266, you can execute hasValue(false)
more than 62000 calls per second.
If you force true readings, you only will get 2000 calls per second.
if you have a busy application, you can make good use of the extra time.
A true reading consumes (1/2000) = 0.5 milliseconds.
This is the maximum resolution you can get.
Please refer to timing for more information