cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO use of VL53L0X

CGiov
Associate

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

1 REPLY 1
John E KVAM
ST Employee

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?


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question. It helps the next guy.