Skip to content

hasValue

Starmbi edited this page Jan 27, 2020 · 7 revisions

hasValue

a non-blocking function that asks for a new value.

 bool hasValue(bool forceSensor = false);

result Boolean

true if a new value is measured.


Parameter bool forceSensor = false

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.


Hints:

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

Clone this wiki locally