Hello everyone!
I had a project involving a distance sensor, I ended up choosing this TOF53400 which as far as I understand is identical to a VL53L1X. Using an ESP32 to send the data to a cellphone via bluetooth serial monitor
Using the Adafruit_VL53L1X (simpletest) exemple sketch I cannot get a valid reading, serial monitor just repeat "Couldn't get distance: 0" and if I try to display the value of distance I just get "-1" so an error value
#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"));
// Valid timing budgets: 15, 20, 33, 50, 100, 200 and 500ms!
vl53.setTimingBudget(50);
Serial.print(F("Timing budget (ms): "));
Serial.println(vl53.getTimingBudget());
/*
vl.VL53L1X_SetDistanceThreshold(100, 300, 3, 1);
vl.VL53L1X_SetInterruptPolarity(0);
*/
}
void loop() {
int16_t distance;
if (vl53.dataReady()) {
// new measurement for the taking!
distance = vl53.distance();
if (distance == -1) {
// something went wrong!
Serial.print(F("Couldn't get distance: "));
Serial.println(vl53.vl_status);
return;
}
Serial.print(F("Distance: "));
Serial.print(distance);
Serial.println(" mm");
// data is read out, time for another reading!
vl53.clearInterrupt();
}
}
As a troubleshooting step, I ran this L2C adress scanner, but instead of giving me just 1 address, the one of my device, it would give me many, and not always the same ones, but 0x29 would be there at least, which is the one used by the sketch
Scanning...
I2C device found at address 0x03
I2C device found at address 0x06
I2C device found at address 0x09
I2C device found at address 0x0D
I2C device found at address 0x11
I2C device found at address 0x14
I2C device found at address 0x16
I2C device found at address 0x17
I2C device found at address 0x1B
I2C device found at address 0x1C
I2C device found at address 0x20
I2C device found at address 0x21
I2C device found at address 0x25
I2C device found at address 0x26
I2C device found at address 0x29
I2C device found at address 0x2A
I2C device found at address 0x2B
I2C device found at address 0x2F
I2C device found at address 0x30
I2C device found at address 0x34
I2C device found at address 0x35
I2C device found at address 0x39
I2C device found at address 0x3A
I2C device found at address 0x3E
I2C device found at address 0x3F
I2C device found at address 0x70
I2C device found at address 0x74
I2C device found at address 0x76
I2C device found at address 0x78
I2C device found at address 0x7C
I2C device found at address 0x7D
done
I also tried setting the SDA and SCL pins to 32 and 33 on the ESP32, but it gave me the same results both with the scanner sketch and the adafruit vl53l1x sketch
So is this a bad sensor? am I doing something wrong?

