Home Code Raspberry Pi and VL53L0X Time-of-Flight example

Raspberry Pi and VL53L0X Time-of-Flight example

by shedboy71

In this article we will connect a VL53L0X Time-of-Flight sensor to an Raspberry Pi

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 FlightSenseTM patented technology.

Here is a typical module

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 distances, higher immunity to ambient light, and better robustness to cover glass optical crosstalk.


Parts List

Name Link
Raspberry Pi Zero Aliexpress product link

Amazon link

ebay link

VL53L0X ToF Sensor Aliexpress product linkAmazon link

ebay link

Connecting wire Aliexpress product link

Amazon.com link

Ebay link


We chose a Pi Zero for this example, any Raspberry Pi should work just fine.

pi and VL53L0X

pi and VL53L0X


The example library and code examples come from https://github.com/johnbryanmoore/VL53L0X_rasp_python

sudo apt-get install build-essential python-dev

Then use following commands to clone the repository and compile:

cd your_git_directory
git clone https://github.com/johnbryanmoore/VL53L0X_rasp_python.git
cd VL53L0X_rasp_python

I used the VL53L0X_example.py example


import time
import VL53L0X

# Create a VL53L0X object
tof = VL53L0X.VL53L0X()

# Start ranging

timing = tof.get_timing()
if (timing &lt; 20000):
    timing = 20000
print ("Timing %d ms" % (timing/1000))

for count in range(1,101):
    distance = tof.get_distance()
    if (distance &gt; 0):
        print ("%d mm, %d cm, %d" % (distance, (distance/10), count))



you can run this by typing the following in the terminal

sudo python VL53L0X_example.py


In the terminal you should see something like this

VL53L0X output

VL53L0X output

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