VL53L0X — ToF rangefinder initialization (vl53l0x_init)¶
What it does: Initializes the laser ToF rangefinder VL53L0X on the I2C bus, sets the measurement budget and parameters of the VCSEL pulses.

Inputs¶
SDA: I2C SDA pin.SCL: I2C SCL pin.- Field
ID: rangefinder instance identifier.
Output¶
- None (statement block).
When to use it¶
- Once when starting the program before reading the distance.
Tips and pitfalls¶
- VL53L0X is a ToF sensor (940 nm) and in normal mode it is designed up to approximately 1 m.
- The quality of the measurement is affected by the reflectivity of the target, the ambient light, the cover glass and the height of the sensor from the pad.
Usage example¶

Generated Python example¶
from machine import Pin, SoftI2C
from vl53l0x import VL53L0X
if not "i2c_22_21" in globals():
i2c_22_21 = SoftI2C(scl=Pin(22), sda=Pin(21), freq=400000)
tof1 = VL53L0X(i2c_22_21)
tof1.set_measurement_timing_budget(50000)
tof1.set_Vcsel_pulse_period(tof1.vcsel_period_type[0], 16)
tof1.set_Vcsel_pulse_period(tof1.vcsel_period_type[1], 12)