Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

First results of VL53L1X are always inaccurate

I’m using this sensor with a microcontroller that goes into deepsleep after taking a measurement. Because I want it to take as minimal mAh as possible I thought it would be a good idea to switch from continuously operation (and cutting it after receiving 5 results) to single measurements without the continuously measurement in the background. However when doing this I noticed the first 2-3 results are always inaccurate. Any idea why this is the case?

#include <Wire.h>
#include <VL53L1X.h>

VL53L1X sensor;

void setup()
  Wire.setClock(400000); // use 400 kHz I2C

  if (!sensor.init(true))
    Serial.println("Failed to detect and initialize sensor!");
    while (1);


void loop()

  while (!sensor.dataReady())

  Serial.print("function output: ");
  Serial.print("\trange: ");
  Serial.print(" mm\tstatus: ");
  Serial.print("\tpeak signal: ");
  Serial.print("\tambient: ");
  Serial.print("\tb: ");


Serial output:

19:26:37.812 -> function output: 41	range: 41 mm	status: range valid	peak signal: 260.68	ambient: 0.21	b: 199426
19:26:39.233 -> function output: 97	range: 97 mm	status: range valid	peak signal: 39.15	ambient: 0.02	b: 199426
19:26:40.620 -> function output: 103	range: 103 mm	status: range valid	peak signal: 17.70	ambient: 0.01	b: 199426
19:26:42.040 -> function output: 103	range: 103 mm	status: range valid	peak signal: 17.69	ambient: 0.01	b: 199426
19:26:43.412 -> function output: 103	range: 103 mm	status: range valid	peak signal: 17.62	ambient: 0.02	b: 199426
19:26:44.848 -> function output: 104	range: 104 mm	status: range valid	peak signal: 17.80	ambient: 0.01	b: 199426
19:26:46.225 -> function output: 103	range: 103 mm	status: range valid	peak signal: 17.73	ambient: 0.02	b: 199426

Thanks in advance


Unfortunately, the first couple readings being inaccurate seems to be normal behavior, so you might consider just ignoring the first few readings.


Thank you! Would peak signal being lower than 20 the correct way to determin if its a good reading?

The peak signal being higher for the first few readings could be an indication that the sensor is getting too strong of a return signal and needs a few readings to adjust its sensitivity and start giving good results. You might be able to look at that value to decide whether the readings are good, but it might vary if your conditions or target distance will not always be consistent, so you will probably need to do some testing to make sure that works for you.

Alternatively, we generally find that discarding the first few readings is enough to get reliable measurements (though you might want to experiment to see how many readings you need to ignore).