VL53L0X GPIO Interrupt did frequent / irregulary not trigger and unexpected trigger when no target present
I have invested a lot of time and find no solution: I use two VL53L0X sensors in a custom board design with an ESP32 and use of the ST-Library functions.
The usage of the GPIO Interrupts did not work as expected, because frequently / irregulary they did not trigger even if they should, because the detected object hit the trigger condition. I have written a check function where I can see, that the sensor measures and reports the correct distance, the correct DeviceMode (Continous), the correct trigger condition (TresholdLow or High), correct PalState (Running), no error.... , but did not raise the GPIO Interrupt (ClearInterruptMask was executed before...).
In general I know, that my design and functions are working, because in 60 -80% of the trigger situations everything works as expected:
- the system is configured with VL53L0X_DEVICEMODE_CONTINUOUS_RANGING, LOW and HIGH-triggers are set and everything is cleared
- usually the system waits for a VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW with 100mm Treshold.
- after trigger detection the trigger is NOT cleared and nothing changed
- after 100ms a manual re-check ("debouncing") of the trigger condition is carried out with VL53L0X_GetRangingMeasurementData
- if the trigger condition is still ok - the measurement is stopped, Interrupt mask cleared, VL53L0X_SetGpioConfig(...VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH..) with the predefined Treshold_high 150 mm and the measurement is started again to detect the leaving of the object.
- after the next trigger the procedure goes the same way only with "reverse signs"
If the problem with the not firing trigger occurs it's mostly in the Threshold_Crossed_High condition, but also in the ..Low.
I'm wondering especially, when I read all relevant data from the sensor in such a situation, that it shows the correct measurements and configuration, but did not set the GPIO and InterruptMask?!?? My actual workaround is to restart the sensor with XShut - but this cannot be the way ...
My second concern is the GPIO/Interrupt-behaviour when there is no target present, because the trigger fires as he wants with no comprehensible method - so it is useless. To clarify - in my test setup I have added a wall behind my sensors - so that the maximum distance and readings are about 400mm , but this is also a limitation I don't want to have ...
I hope for some help because I have invested a lot of time and I'm at the end of my skills and patience ...
