Expected: Doing a getDistance() with the VL53L1x sensor towards an empty room results in a large distance reading.
Observed: Sometimes the getDistance() towards an empty room results in values close to the sensor (500 mm or less.)
work-around: Check the quality of the measured value by doing a getRangeStatus() over the observed reading. If it's not 0 or 1, then discard the de read distance.
note: This has taken me more than a day to figure out. It would help if the default example would also show the getRangeStatus() of the sensor to help people get their application going. See the example below.
distanceSensor.startRanging(); // Write configuration bytes to initiate measurement
while (!distanceSensor.checkForDataReady()) {
delay(1);
}
distance = distanceSensor.getDistance(); // Get the result of the measurement from the sensor
sensor_state = distanceSensor.getRangeStatus(); // Check if the sensor actually sees an object.
distanceSensor.clearInterrupt();
distanceSensor.stopRanging();
}
if (sensor_state > 0) { // If no object is seen then return an status value.
distance = -1;
}
return distance;
Expected: Doing a
getDistance()
with the VL53L1x sensor towards an empty room results in a large distance reading. Observed: Sometimes thegetDistance()
towards an empty room results in values close to the sensor (500 mm or less.) work-around: Check the quality of the measured value by doing agetRangeStatus()
over the observed reading. If it's not 0 or 1, then discard the de read distance.Reference: St forum discussion here. https://community.st.com/s/question/0D50X00009sUiJUSA0/out-of-range-readings-of-vl53l1x
note: This has taken me more than a day to figure out. It would help if the default example would also show the
getRangeStatus()
of the sensor to help people get their application going. See the example below.