No, it's the GPIO pin on the breakout board.
According the the documentation for the VL53L4CX, the XSHUT is used for initialization and didn't seem necessary.
Here's my initialization code...
Code: Select all
VL53L4CX *sensor; // Actually allocate this in setup()
// this is in setup()
// Initialize I2C bus.
DEV_I2C.setPins(SDA1, SCL1);
DEV_I2C.begin();
pinMode(A2, INPUT_PULLUP);
sensor = new VL53L4CX(&DEV_I2C, A2);
sensor->begin();
sensor->VL53L4CX_Off();
// I've tried all settings for this
sensor->VL53L4CX_SetDistanceMode(VL53L4CX_DISTANCEMODE_LONG);
// Not sure why this is 0x12, but its what the example code had and that worked
sensor->InitSensor(0x12);
// I've tried playing with this, but the documentation doesn't really say why you'd want to change it.
// I ended up leaving it commented out.
// sensor->VL53L4CX_SetMeasurementTimingBudgetMicroSeconds(66666);
sensor->VL53L4CX_StartMeasurement();
sensor->VL53L4CX_PerformXTalkCalibration();
in loop()
Code: Select all
uint8_t newDataReady = 0;
sensor->VL53L4CX_GetMeasurementDataReady(&newDataReady);
if (newDataReady) {
VL53L4CX_MultiRangingData_t multiRangingData;
float mr = 99999; // I had to change this for the post because my actual variable name is apparently a banned spam word?
for (int j = 0; j < multiRangingData.NumberOfObjectsFound; j++) {
VL53L4CX_TargetRangeData_t *target = &multiRangingData.RangeData[j];
if (target->RangeStatus == 0) {
float range = target->RangeMilliMeter;
if (range < mr) mr = range;
}
}
sensor->VL53L4CX_ClearInterruptAndStartMeasurement();
Serial.println(mr);
}
Now, I know what you're going to say. It returns multiple values and I keep the minimum valid value.
But in reality, there's never more than one valid value. The others all have non-zero RangeStatus.