Hello!
I’ve been having some issues getting the PiicoDev VL53L1X laser distance sensor to connect to a Pi Pico and was wondering if I could get any input on something I might have overlooked or am obviously getting wrong:
- The VL53L1X is connected to I2C0 on the Pico, GP20 for SDA and GP21 for SCL, 3.3v for 3.3v and ground for ground.
- I have the latest PiicoDev python files and no upload/issues with other scripts running on the Pico itself
- Using the following code, I can see the device at address 0x41 and the device power LED is lit:
from PiicoDev_VL53L1X import PiicoDev_VL53L1X
from time import sleep
from machine import I2C
i2c = machine.I2C(0, scl=21, sda=20, freq=400000)
output = i2c.scan()
print("I2C Scan addresses:")
print(output)
Returns:
I2C Scan addresses:
[41]
But when passing this config into the constructor for the VL53L1X (either with the specified address or just leaving the constructor blank), I receive the following:
from PiicoDev_VL53L1X import PiicoDev_VL53L1X
from time import sleep
from machine import I2C
i2c = machine.I2C(0, scl=21, sda=20, freq=400000)
output = i2c.scan()
print("I2C Scan addresses:")
print(output)
print("Starting Distance Sensor:")
distSensor = PiicoDev_VL53L1X(0, 400000, 20, 21, 0x41)
while True:
dist = distSensor.read() # read the distance in millimetres
print(str(dist) + " mm") # convert the number to a string and print
sleep(0.1)
Starting Distance Sensor:
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
File "PiicoDev_VL53L1X.py", line 112, in __init__
File "PiicoDev_VL53L1X.py", line 136, in reset
File "PiicoDev_VL53L1X.py", line 125, in writeReg
OSError: [Errno 5] EIO
I’ve checked for any connectivity issues with a basic multimeter and everything seems to be fine, even though the error showing seems to point at that. I’m using a 4pin cable to connect the VL53L1X back to the pico with a cable distance of <76cm but am unsure if this is an issue.
Any ideas on anything I may have missed?
Thanks for any advice in advance!
James.