VL53L0X TimeOfFlight sensor problem

Hi,

I have some troubles with an VL53L0X. Tested both on Nano and an Uno board.

#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(true)) {
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.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
} else {
Serial.println(" out of range ");
}

delay(100);
}

brings the following output and then the program hangs.

11:57:08.163 -> Adafruit VL53L0X test
11:57:08.198 -> VL53L0X Info:
11:57:08.198 -> Device Name: VL53L0X ES1 or later, Type: VL53L0X, ID: VL53L0CXV0DH/1$1
11:57:08.198 -> Rev Major: 1, Minor: 1
11:57:08.198 -> VL53L0X: StaticInit
11:57:08.266 -> VL53L0X: PerformRefSpadManagement

Any ideas?

Thanks
Tom

if (!lox.begin(true)) {

Are you using the newest version of the library? In the most current version there is no single boolean parameter version of the begin() method.

It appears you have another sketch running than the one you posted. The output you gave does not match what that code should produce.

@wvmarie:

The output you gave does not match what that code should produce.

Was my first thought too but the library has a debug mode that can be activated which prints about what OP posted.

Hi,

the output was produced from the debug mode.

I tried different version of the library, the newest one does not show the output I mentioned above and just hangs during the lox.begin(). So I tried older versions in which the output was generated in debug mode.

Thanks
Tom

The Adafruit library with the example code works for me on a Nano.

If it doesn't work for you:

  • check wiring: make sure all are connected well (measure this with your multimeter! Take the solder joints of the pin on the PCB, you must find a direct connection between those), SCL/SDA not swapped or so.
  • check whether sensor is not broken: take another one, see if that one does work.

I tried different version of the library, the newest one does not show the output I mentioned above and just hangs during the lox.begin(). So I tried older versions in which the output was generated in debug mode.

Sure because other versions need other sketch code. Did you adapt the sketch code to match the newest version? If yes, post that code!