VL53L1x out of range problem

I'm trying to use the VL53L1x to measure distances between 0.10cm and 200cm. I am having a problem here. In open space or if there is an object at 2.5m the readings I get in long measurement mode with 500ms timing budget are jittering between 210cm and 150cm and sometimes dips of 0.9cm. Because of this I am unable to decide whether there is an object or not when there is nothing in front of the sensor. Does anybody know why this is happening, or from my testing the sensor has a huge limitation. How can I fix this?

What Arduino is the sensor connected to, and what code is running on it?

Hello Aarg
Arduino Nano, sample code from Adafruit. Do you think it is necessary to put the code here?

At a minimum, please link to the sensor library. Have you tested using the sensor library examples?

I'm assuming you haven't written a custom sensor driver, since you seem to not be considering a problem there. If you are using an Adafruit example sketch, unmodified, you could just link to that as well...

Hi aarg,
the original source code is:

#include "Adafruit_VL53L1X.h"
#define IRQ_PIN 2
#define XSHUT_PIN 3
Adafruit_VL53L1X vl53 = Adafruit_VL53L1X(XSHUT_PIN, IRQ_PIN);
//------------------------------------------------------------------------------------------------------------------------
void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);
   Serial.println(F("Adafruit VL53L1X sensor demo"));
      Wire.begin();
      if (! vl53.begin(0x29, &Wire)) {
        Serial.print(F("Error on init of VL sensor: "));
        Serial.println(vl53.vl_status);
  while (1) delay(10);
      }
  Serial.println(F("VL53L1X sensor OK!"));
  Serial.print(F("Sensor ID: 0x"));
  Serial.println(vl53.sensorID(), HEX);
  if (! vl53.startRanging()) {
    Serial.print(F("Couldn't start ranging: "));
    Serial.println(vl53.vl_status);
    while (1) delay(10);
  }
  Serial.println(F("Ranging started"));
  
  vl53.setTimingBudget(500);                                  // Valid timing budgets: 15, 20, 33, 50, 100, 200 and 500ms!
  Serial.print(F("Timing budget (ms): "));
  Serial.println(vl53.getTimingBudget());

//   vl53.VL53L1X_SetDistanceThreshold(100, 300, 3, 1);
//   vl.VL53L1X_SetInterruptPolarity(0);

}
//---------------------------------------------------------------------------------------------------------------------------
void loop() {
  int16_t distance;
  if (vl53.dataReady()) {
    distance = vl53.distance();                     // new measurement for the taking!
    if (distance == -1) {
      Serial.print(F("Couldn't get distance: "));   // something went wrong!
      Serial.println(vl53.vl_status);
      return;
    }
    Serial.print(F("Distance: "));
    Serial.print(distance);
    Serial.println(" mm");
    delay(350);
    // data is read out, time for another reading!
    vl53.clearInterrupt();
  }
}Texto pré-formatado

Adafruit VL53L1x Library

Thanks, please apply code tags to the first one...

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

You can go back and fix your original post by highlighting the code and clicking the </> in the menu bar.
code tags new

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