Vl53l1x Spurious Signal Returns?

Hi. Background: Using Uno, Adafruit vl53l1x, and Adafruit's library for the vl53l1x. I modified that program to send a beep if TOF is within a range. That's working ok. However, when tested outdoors, it will send spurious beeps when pointed to a distance object or the sky.

Are spurious signals normal? Or do I have a defective VL53L1X?

I tested changing vl53.setTimingBudget() without any improvement. Even added a "trap" to compare the current distance to the prior distance.
Here is my code:

/* Version D
Adapted from program made by Adafruit
Added buzzer on start up
Added buzzer if Distance is within a range.
>200 mm so does not measure too close
and <1200 mm appoximate 4 feet
TEST: detected through car window. but spurious beeps, including when pointed to empty sky.

Added line to set distance variable to 0, before new ping.
Changed: vl53.setTimingBudget();//originally was 50

To stop spurious, added spurcount counter to only beep if >1
Change logic to simply compare old and new distances.
Added a range of values to the old distance.

VIN Voltage In = RED = Arduin 5V
GRN ground = BLACK = Arduino GRN
SDA = BLUE = Arduino A4
SCL = YELLOW = Arduino A5

  SPEAKER Arduino Pin 5 and Grn    


#include "Adafruit_VL53L1X.h"

#define IRQ_PIN 2
#define XSHUT_PIN 3

const int Speaker = 5; // speaker-buzzer is connected to pin 5

// uses Counter= spur_count to prevent single spurious signal triggering a beep
int spur_count = 0; // used to trap one-time spurious signals
int spur_past = 0; // prior distance measurement

Adafruit_VL53L1X vl53 = Adafruit_VL53L1X(XSHUT_PIN, IRQ_PIN);

void setup() {

// Beep on startup to tell driver that Lidar is turned on
tone(Speaker,1500); // 1000 = 1 KHz sound
delay(500); // fyi500 = 0.5 seconds
noTone(Speaker); // stop sound
tone(Speaker,500); // 1000 = 1 KHz sound
delay(800); // 500 = 0.5 seconds
noTone(Speaker); // stop sound

Serial.begin(9600); // originally Serial.begin(115200);
while (!Serial) delay(10);

Serial.println(F("Adafruit VL53L1X sensor demo"));

if (! vl53.begin(0x29, &Wire)) {
Serial.print(F("Error on init of VL sensor: "));
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: "));
while (1) delay(10);
Serial.println(F("Ranging started"));

vl53.setTimingBudget(100);//original program from Adafruit = 50 & said valid numbers are: 15, 20, 33, 50, 100, 200 and 500ms
Serial.print(F("Timing budget (ms): "));

vl.VL53L1X_SetDistanceThreshold(100, 300, 3, 1);

void loop() {
int16_t distance;

if (vl53.dataReady()) {

distance =0; // added: set to zero to reduce spurious beeps

// new measurement for the taking!
distance = vl53.distance();

if (distance == -1) {
  // something went wrong!
  Serial.print(F("Couldn't get distance: "));

// For testing...
Serial.print(F("Distance: "));
Serial.println(" mm");
Serial.print(F("Past distance: "));
Serial.println(" mm");

if (distance >= 300 and distance <1200){ // the range for warnings. mm=roughly 1 to 4 feet.

  //Spurious trap: if new distance is near to old past, 
  if ((distance > spur_past - 20) and (distance < spur_past + 20)) { 
     spur_count = spur_count+ 1;
        Serial.print(F("spur_count: "));

 //  if (spur_count> 1){  // spurious trap: must be prior signal with similar distance

      tone(Speaker,1200); // 1100 = 1 KHz sound
      delay(100); // sets duration of tone. fyi 1000 = 1 seconds
      noTone(Speaker); // stop sound
      spur_count = 0;  

 //   }
spur_past = (distance); // Spurious: store for next comparison 

// data is read out, time for another reading!

with up to 50Hz update rate.

Are you following this rule?

Please forgive my ignorance.
What is the 50Hz update rule?
Does that relate to this setting? vl53.setTimingBudget(100)

The documentation states the maximum rate for the device is 50 Hz. Meaning that is the maximum frequency you can trigger it.

Hi Paul.
I have now tried using 50 ; vl53.setTimingBudget(50)
Sadly, with 50, it still creates false returns when outside pointed to empty sky.
It works great inside our home. That is no false, spurious signals inside our home. So maybe, outside, ambient light triggers it?

Or maybe there is some other way to limit the VL43L1X to 50 Hz?

Thanks for your interest.

What did you change to ensure you did not ask the device for a distance more than 50 times per second?