VL53L0X GY-530 laser distance

using this basic code for measuring distance

#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

void setup() {
  Serial.begin(115200);

  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }
  
  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }
  // 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.println("Distance (mm): "); 
    Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }
    
  delay(1000);
}

it returned failed to boot vl53lox

Does the library need the address of the VL53L0X in lox.begin()? (default 0x29 says Adafruit)

in adufruit class i found this line

#define VL53L0X_I2C_ADDR 0x29 ///< Default sensor I2C address

Try it in the function call.

thanks man, I really appreciate your help)))
everything works correctly finally

1 Like

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