VL53L0X Time-of-Flight sensor and ESP32

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.

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.

Shopping List

Should be able to pick up one of these sensors from $3 to $4

Amount Part Type
1 VL53L0X
1 Wemos Lolin 32




esp32 and VL53L0X
esp32 and VL53L0X


Again we use a library and again its an adafruit one – https://github.com/adafruit/Adafruit_VL53L0X

The default example worked fine, so here it is

#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

void setup()

// wait until serial port opens for native USB devices
while (! Serial)

Serial.println("Adafruit VL53L0X test");
if (!lox.begin())
Serial.println(F("Failed to boot VL53L0X"));
// power
Serial.println(F("VL53L0X API Simple Ranging example\n\n"));

void loop()
VL53L0X_RangingMeasurementData_t measure;

Serial.print("Reading a measurement... ");
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

if (measure.RangeStatus != 4)
{ // phase failures have incorrect data
Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
Serial.println(" out of range ");




Open the serial monitor – this is what I saw. I moved an object closer to the sensor hence the readings decreasing

Reading a measurement… Distance (mm): 399
Reading a measurement… Distance (mm): 394
Reading a measurement… Distance (mm): 394
Reading a measurement… Distance (mm): 394
Reading a measurement… Distance (mm): 389
Reading a measurement… Distance (mm): 39
Reading a measurement… Distance (mm): 42
Reading a measurement… Distance (mm): 51





VL53L0X Time-of-Flight (ToF) Laser Ranging Sensor Breakout

Previous articleVEML6075 ultraviolet (UV) light sensor and ESP32
Next articleADS1115 analog-to-digital converter and ESP32