Home CodeCircuitpython Raspberry Pi Pico and VL53L0X Time-of-Flight Sensor circuitpython example

Raspberry Pi Pico and VL53L0X Time-of-Flight Sensor circuitpython example

by rp2040guy71

In this article we connect a VL53L0X Time-of-Flight to a Raspberry Pi Pico running Circuitpython

Sensor Information

The VL53L0X is a new generation Time-of-Flight (ToF) laser-ranging module housed in the smallest package on the market today, providing accurate distance measurement whatever the target reflectances unlike conventional technologies. It can measure absolute distances up to 2m, setting a new benchmark in ranging performance levels, opening the door to various new applications.

The VL53L0X integrates a leading-edge SPAD array (Single Photon Avalanche Diodes) and embeds ST’s second generation FlightSense™ patented technology.

The VL53L0X’s 940 nm VCSEL emitter (Vertical Cavity Surface-Emitting Laser), is totally invisible to the human eye, coupled with internal physical infrared filters, it enables longer ranging distance, higher immunity to ambient light, and better robustness to cover glass optical crosstalk.


  • Fully integrated miniature module
    • 940 nm laser VCSEL
    • VCSEL driver
    • Ranging sensor with advanced embedded micro controller
    • 4.4 x 2.4 x 1.0 mm
  • Fast, accurate distance ranging
    • Measures absolute range up to 2 m
    • Reported range is independent of the target reflectance
    • Advanced embedded optical cross-talk compensation to simplify cover glass selection
  • Eye safe
    • Class 1 laser device compliant with latest standard IEC 60825-1:2014 – 3rd edition
  • Easy integration
    • Single reflowable component
    • No additional optics
    • Single power supply
    • I2C interface for device control and data transfer
    • Xshutdown (reset) and interrupt GPIO
    • Programmable I2C address

Parts Required


Name Link
Pico Raspberry Pi Pico Development Board
VL53L0X VL53L0X laser ToF time-of-flight sensor module
Connecting cables Aliexpress product link

Amazon.com link

Ebay link



I used the Adafruit vl53l0x sensor

Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

rp2040 and vl53l0x

rp2040 and vl53l0x

Code Example

I used Thonny for development

The following is based on a library , I copied the adafruit_vl53l0x.mpy library for this device to the lib folder on my Feather M0 Express – https://circuitpython.org/libraries

This is the basic example which comes with the library

import time
import board
import adafruit_vl53l0x
import busio
# Create sensor object, communicating over the board's default I2C bus
i2c = busio.I2C(scl=board.GP1, sda=board.GP0) # uses board.SCL and board.SDA
vl53 = adafruit_vl53l0x.VL53L0X(i2c)
# Optionally adjust the measurement timing budget to change speed and accuracy.
# See the example here for more details:
#   https://github.com/pololu/vl53l0x-arduino/blob/master/examples/Single/Single.ino
# For example a higher speed but less accurate timing budget of 20ms:
# vl53.measurement_timing_budget = 20000
# Or a slower but more accurate timing budget of 200ms:
# vl53.measurement_timing_budget = 200000
# The default timing budget is 33ms, a good compromise of speed and accuracy.
# Main loop will read the range and print it every second.
while True:
    print("Range: {0}mm".format(vl53.range))


Here is what I saw in Thonny REPL window

Range: 40mm
Range: 23mm
Range: 21mm
Range: 82mm
Range: 219mm
Range: 266mm
Range: 258mm



You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More