Adafruit Feather M0 and VL53L0X Time-of-Flight laser-ranging module circuitpython example

In this example we connect a VL53L0X Time-of-Flight laser-ranging module to an Adafruit Feather M0 running Circuitpython

First lets look at some information about the sensor from the manufacturer

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.

Key Features

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

This was my sensor of choice that I used

Parts Required

 

Name Link
Adafruit Feather M0 Express Adafruit (PID 3403) Feather M0 Express – Designed for CircuitPython – ATSAMD21 Cortex M0
VL53L0X VL53L0X Time-of-Flight (ToF) Laser Ranging Sensor Breakout
Connecting cables Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

 

Schematic/Connection

feather and vl53l0x layout
feather and vl53l0x layout

Code Example

I used Mu for development

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

# Simple demo of the VL53L0X distance sensor.
# Will print the sensed range/distance every second.
import time
 
import board
import busio
 
import adafruit_vl53l0x
 
# Initialize I2C bus and sensor.
i2c = busio.I2C(board.SCL, 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))
    time.sleep(1.0)

Output

Here is what I saw in Mu REPL window, I moved my closer to the sensor and away from the sensor to change the values

Range: 22mm
Range: 82mm
Range: 19mm
Range: 78mm
Range: 44mm
Range: 23mm
Range: 210mm
Range: 23mm
Range: 105mm

Links

https://www.st.com/resource/en/datasheet/vl53l0x.pdf

LEAVE A REPLY

Please enter your comment!
Please enter your name here