ToF sensor VL53L1X stops reading on Raspberry pi

Hello,

I have a VL53L1X ToF sensor hooked up to a raspberry pi using the soldering holes. The sensor reads fine using the sample code for about a minute then freezes. Rebooting it has no effect but if I let it cool off for a bit it works again for about 60 seconds which makes me think it is heating up or something. This has happened on all three different units I tested.

Should I use a resistor somewhere or something? How many ohms and where should it be located if so?

It is wired like this:

  • sda to gpio2 (the sda pin)

  • scl to gpio3 (listed as scl pin)

  • 3.3v to gpio 1 (3.3v)

  • ground to gpio 14 (ground)

The other two pins are not hooked up. The unit is a Raspberry pi 4B on Debian.

Also this line of example code:

if (ToF.sensor_init() == None):

does not return True even when the unit is obviously hooked up and taking readings - if that is of any help.

Thanks for any help you can provide.

There was a complain about VL53L1X’s I2C address being Reset. Kindly check if the same thing is happening in your setup.

I searched but can’t find the article you are recommending. I don’t understand why it would do that anyway midstream. Here is the code I am running (straight out of sparkfun’s examples):

import qwiic

import time

ToF = qwiic.QwiicVL53L1X()

if (ToF.sensor_init() == None):

print(“Sensor online!\n”)

else:

print(“nope”)

ToF = qwiic.QwiicVL53L1X()

ToF.set_distance_mode(1) # Sets Distance Mode Short (Long- Change value to 2)

while True:

try:

ToF.start_ranging() # Write configuration bytes to initiate measurement

time.sleep(.005)

distance = ToF.get_distance() # Get the result of the measurement from the sensor

time.sleep(.005)

ToF.stop_ranging()

distanceInches = distance / 25.4

distanceFeet = distanceInches / 12.0

print(“Distance(mm): %s Distance(ft): %s” % (distance, distanceFeet))

except Exception as e:

print(e)

Hi everyone,

Turns out the solution for me was to get a voltage regulator and turn it way down to just 2v coming in. Now it works perfectly and has been going strong for over two hours now.