I have a SparkFun VL53L1X (Qwiic) breakout, connected via a Qwiic cable to a Qwiic pHAT V2.0 for RaspPi, which is attached to a RaspPi 4. I’m using the SparkFun Python library - Qwiic_VL53L1X_Py - to interact with the sensor.
Using the Example1 code - Example1_ReadDistance.py - I am able to get distance readings for some time. However, periodically, perhaps after a few minutes, or sometimes a couple of hours, the sensor stops responding. If I exit the code, and restart it, the sensor initialization fails. I updated the code to return the output from sensor_init, and it returns a -7. Restarting the RaspPi with a reboot (not a powercycle) doesn’t correct the issue. If I wait for a few minutes or longer, it sensor will then correctly initialize and return readings. A powercycle of the RaspPi works.
I’ve checked physical connections of the pHAT to the RaspPi, and the cable to the sensor breakout. Any suggestions for what else to try?
How long is your Qwiic cable and have you tried shortening it? Are there any other sensors attached to the Pi. Also, have you tried the sensor with an Arduino and does it behave the same way there?
Expected output: continuous output of distance reading until program is stopped
Actual output: continuous output of distance reading which eventually sticks to a value and no longer responds to changing distances. The system seems to fail faster when running example 2 (short distance mode), but that could just be due to a relatively small sample size.
Executing the script after this has occurred causes `sensor_init()` to fail with error code -7, which is (by my understanding) a time-out error, but the script will still output the same value that it got stuck on the previous run. The only exception to this rule is that the *first time* the script is run after the first failure, `sensor_init()` will return "NONE" but the output will still be stuck.
Executing the `boot_state()` method returns "3", which is not listed as a possibility in the package documentation (this also holds for the caveat listed above). Digging through ST's documentation, this seems to be a "VL53L1_ERROR_UNDEFINED", which is remarkably helpful.
Any thoughts on where to go from here?
Try increasing the delay in the examples. That was the fastest that I could consistently get reliable results on a Pi.
I only tested the sensor briefly with the Jetson (when it first came out) to make sure the package operated. However, since the Jetson runs a little quicker, my guess is increasing the delay would help.
Here are a few other options to consider:
- You could be stuck at an interrupt state and try clearing the interrupt.
- You could try re-configuring the sensor (not guaranteed to work).
- It's been a while since I ported that package over from the Arduino library; but it but there might be a method that can be called to re-initialize the sensor with the default configuration. If not, you'd have to manually write a script to do that.
- Otherwise, the only way to restart the device is with an external pin, not controlled over I2C (i.e. you 's have to unplug the sensor or toggle that pin low).