Adafruit VL53L0X high accuracy with Adafruit_VL53L0X libray

Hello to the community,
I am using the Adafruit VL53L0X with Adafruit_VL53L0X library and I would like to increase accuracy. According to data-sheet, there is a "high accuracy mode" but I can not find a way to use this mode.

Do you know what should I do? Maybe use another library instead?

Thanks in advance!

I used this library from Pololu. It makes choosing long range, high speed or high accuracy pretty easy.

1 Like

groundFungus thanks for the reply, I just tried this lib, indeed it is very easy to use high acc. but after some mins the serial monitor stops to load values.

Did you have such problems when you used this lib?


No, but I never used it for long periods.

Post your code and I will look at it and maybe try it on my system.

Read the forum guidelines to see how to properly post code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

I am testing both sample code from Adafruit_VL53L0X and VL53L0X-arduino using Arduino nano 33 iot.

The Adafruit_VL53L0X library is working for some minutes and afterwards serial monitor displays "65529" or "42820" or "0" or serial monitor freezes.

The code is from the example of the lib:

#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

void setup() {

  // wait until serial port opens for native USB devices
  while (! Serial) {
  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
  // power 
  Serial.println(F("VL53L0X API Simple Ranging example\n\n")); 

void loop() {
  VL53L0X_RangingMeasurementData_t measure;
  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");

When I am using the VL53L0X_Arduino lib (I use this in high accuracy mode), it is working for several minutes and afterwards serial monitor freezes.

The code is from the example of the same lib:

/* This example shows how to get single-shot range
 measurements from the VL53L0X. The sensor can optionally be
 configured with different ranging profiles, as described in
 the VL53L0X API user manual, to get better performance for
 a certain application. This code is based on the four
 "SingleRanging" examples in the VL53L0X API.
 The range readings are in units of mm. */

#include <Wire.h>
#include <VL53L0X.h>

VL53L0X sensor;

//#define LONG_RANGE
//#define HIGH_SPEED

void setup()

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

#if defined LONG_RANGE
  // lower the return signal rate limit (default is 0.25 MCPS)
  // increase laser pulse periods (defaults are 14 and 10 PCLKs)
  sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
  sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);

#if defined HIGH_SPEED
  // reduce timing budget to 20 ms (default is about 33 ms)
#elif defined HIGH_ACCURACY
  // increase timing budget to 200 ms

void loop()
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }


I can find in forums that also previous users had similar problems, someone found the solution by changing parameters in the cpp files, but probably this was in an older version because the cpp in my lib differs a bit.

All that I have to run the code on is my Uno and VL53L0X sensor. I loaded the single example from the vl53l0x-arduino-master library over 40 minutes ago and it is still going.

I will load your code and see what happens.
So far so good. I will let it run.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.