2019-03-05 04:36 AM
Dear St, I'm using the VL53L0X to detect an object at a distance lower than 30cm. I need that the GPIO is activated (turned down to GND) if an object is present below that distance. If possible it would be better if the sensor is able to detect if the object is at a distance above 10cm and below 30cm. At a distance of 40cm I have a screen.
Once the VL53L0X has detected the object, it should turn off the port which will turn on the microprocessor that usually is off (in order to save energy).
The problem is that the GPIO is turned off everytime i put an object even at a distance of 50 cm or more. It's not turned off if there isn't any object.
Apart for this port, the object distance seems to be read correctly by the microprocessor.
What is wrong in the code?
The code I write work this way:
When I want to turn on the VL53L0X I call:
VL53L0X_SetLimitCheckValue - with VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE
VL53L0X_SetLimitCheckValue - with VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE
VL53L0X_SetMeasurementTimingBudgetMicroSeconds
VL53L0X_SetInterMeasurementPeriodMilliSeconds
VL53L0X_SetDeviceMode
VL53L0X_SetInterruptThresholds
VL53L0X_SetGpioConfig
VL53L0X_StartMeasurement
After I remain in a loop calling:
VL53L0X_GetMeasurementDataReady
When the measurement is ready I call
VL53L0X_GetRangingMeasurementData
VL53L0X_ClearInterruptMask
When I want to stop I call:
VL53L0X_StopMeasurement
After which i remain in a loop in which I call
VL53L0X_GetStopCompletedStatus
When the procedure telle me that the device is stopped I call:
VL53L0X_GetRangingMeasurementData
VL53L0X_ClearInterruptMask
The measures seems correct, But the GPIO is turned off everytime there is an object at any distance. I need the GPIO to be turned off only if the distance is below 30cm
On the terminal I report the value of VL53L0X_RangingMeasurementData_t read by VL53L0X_GetRangingMeasurementData.
What is wrong? Is something wrong in VL53L0X_SetLimitCheckValue?
Thanks,
Denti Cristian
2019-04-08 03:52 PM
I'm pretty sure the problem is the polarity of the interrupt. By default an interrupt is 'raised to 3.3V' when the threshold is reached.
To change the direction, look at VL53L0X_SetGpioConfig() in the api.
But there is a lmitation in the chip. The threshold was programmed as a byte not an integer. And it's in mm.
So if the threshold is less than 255, there is no issue. Above this the chip is kept alive to maintain the threshold. (so you don't get the best possible power consumption numbers.)
Can you use 255 instead of 300mm?