Skip to content

getTime

Stefan Armborst edited this page Jan 27, 2020 · 10 revisions

getTime

returns the last conversion time in milliseconds.

unsigned int getTime();

result unsigned int

Time in milliseconds since the last measurement was started.

On communication error, the time will be 999.


Hints:

Unfortunately this sensor has no possibility to tell us the conversion time.
I you need this time, you have to poll the sensor as fast as possible to get a exact result.
This library tries to minimize the polls.
So, only if a command for polling the sensor is executed, this is used to count the time.

Let's assume, that the sensor has a conversion time of 500 milliseconds.
You initiates a measurement and after this, you do a time consuming operation of 1000 milliseconds.
After this, you ask for a value and also for the sampling time.
With the ask for the value you do the first poll after starting the measurement.
So your time will be 1000 milliseconds!

The solution is to keep your loop responsive.
How this can be achieved is shown at working principles.
Also have a look at the sketch TestSuite.ino in the folder examples.
(File -> Examples -> hp_BH1750 -> TestSuite.ino)

Clone this wiki locally