VL53L1X & a Raspberry Pico
[2021-09-03 Fri] update: as you’ll see here (reddit link) someone has ported the CircuitPytohn driver to MicroPython for some reason i never found it when i started this but his github driver can be found here: https://github.com/truckershitch/micropython-vl53l0x
I’ve had an idea for checking the height of a equipment during its movement for some time now and thought the small form factor of the pico + the VL53L1X sensor would be an ideal candidate. So after much searching and trial/error it seemed it wasnt possible until i stumbled across a few threads in the micro-python forum and the openmv github site and i now have a working setup;
The sensor is wired as follows;
GP num | pin num | |
---|---|---|
SDA | GP4 | pin 6 |
SCL | GP5 | pin 7 |
GND | GND | pin 8 |
+ve | 3v3out | pin 36 |

In order to get it working you’ll need to copy the vl53l1x.py
file from;
then edit it and replace
- search & replace all
pyb
withmachine
- search & replace all
delay
withlightsleep
Or you can download the version from my github page https://github.com/drakxtwo/vl53l1x_pico/tree/main
You can test to see if a device is found by;
python code snippet start
from machine import I2C
from vl53l1x import VL53L1X
import time
sda=machine.Pin(4)
scl=machine.Pin(5)
i2c=machine.I2C(0,sda=sda,scl=scl,freq=400000)
print('scanning bus..')
devices = i2c.scan()
if len(devices) == 0:
print("No i2c device !")
else:
print('i2c devices found:',len(devices))
for device in devices:
print("Decimal address: ",device," | Hexa address: ",hex(device))
python code snippet end
Assuming we can found a sensor then the code to read from it is;
python code snippet start
from machine import I2C
from vl53l1x import VL53L1X
import time
i2c = I2C(0)
distance = VL53L1X(i2c)
while True:
print("range: mm ", distance.read())
time.sleep_ms(50)
python code snippet end
with output as follows;
python code snippet start
MicroPython v1.14 on 2021-02-05; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> %Run -c $EDITOR_CONTENT
range: mm 174
range: mm 174
range: mm 172
range: mm 172
range: mm 172
range: mm 172
python code snippet end
Thats as far as i have got, the original pimoroni library allowed for multiplexing the sensors, changing range etc i dont know if thats possible, i’m pleased i got this far!