Hi,
I have this project where I have 2 VL53L1X sensors and they get initialized one after the other. This works when powered from USB, and it used to work when powered from a battery, but now it seems like a the second sensor fails to initialize only when powered from a Lipo battery, when powered from USB 5V, it works fine…
I may think it has to do with the code, even though I dont recall changing it since it last worked? Here is my initialization function (on Arduino). This function basically fails @ sensor.init() but I can’t get why:
VL53L1X sensor;
int8_t init()
{
reboot();
_initCommunication();
if (!sensor.init(0))
{
PRINT("Tof Switch init failed");
return -1;
}
sensor.setTimeout(500);
sensor.setDistanceMode(VL53L1X::Long);
sensor.setMeasurementTimingBudget(50000);
sensor.startContinuous(50);
return 0;
}
void reboot()
{
pinMode(_shutPin, OUTPUT);
delay(100);
pinMode(_shutPin, INPUT);
}
int8_t _initCommunication()
{
PRINT("Initializing Wire for TOF sensor");
Wire.begin();
Wire.setClock(400000); // use 400 kHz I2C
return 0;
}