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"));
}
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.
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.
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!