Skip to content
My Account

Reference

VL53L0X / VL53L1X Time-of-Flight Distance Sensor Complete Guide

The VL53L0X and VL53L1X laser distance sensors: real range and accuracy numbers from the ST datasheets, pins, I2C address, several sensors on one bus, code and the traps that give wrong distances.

  • Up to 2 m or 4 m
  • Laser ToF
  • Class 1
  • I2C address 0x29
No ratings yet, be the first.

The VL53L0X and VL53L1X are laser distance sensors from STMicroelectronics. They are Time-of-Flight (ToF) sensors: they send a short pulse of invisible 940 nm laser light and time how long it takes to come back. Unlike the HC-SR04 ultrasonic sensor they have a narrow beam, they work on small and soft targets, and they are only a few millimetres in size. Both are Class 1 laser devices, safe for the eye in normal use.

This guide compares the two chips with the real numbers from the ST datasheets, shows the pins, the I2C address and how to run several sensors on one bus, gives code for both, and lists the traps that give wrong distances. The data comes from the ST datasheets for the VL53L0X (DocID029104 Rev 2) and the VL53L1X (DocID031281 Rev 3). Breakout boards differ from seller to seller, so check the labels on your own board.

VL53L0X or VL53L1X

VL53L0XVL53L1X
Maximum range2 m (long range profile). Typically 120 cm to 200 cm indoors on a white target4 m (long distance mode, in the dark)
Ranging speedAbout 33 ms per range at the default timing budgetUp to 50 Hz
Field of view25°, fixed27° typical, programmable down by choosing a smaller region of interest (4 × 4 up to 16 × 16 SPADs)
Distance modesDefault and long range profileShort, medium and long
Size4.4 × 2.4 × 1.0 mm4.9 × 2.5 × 1.56 mm
Operating temperature−20 to 70 °C−20 to 85 °C
I2C address0x29 (the datasheet writes it as 0x52)0x29 (written as 0x52)
PinsPin-to-pin compatible with the VL53L1XPin-to-pin compatible with the VL53L0X

The chips look alike and have the same pins, but the software is not the same, and a library for one does not drive the other. Take the VL53L1X when you need more than about a metre, a faster rate, or a narrower field of view. The VL53L0X is enough for obstacle detection and proximity up to about one metre.

Source: ST datasheets VL53L0X (DocID029104 Rev 2) and VL53L1X (DocID031281 Rev 3).

Getting started

1. What you needA breakout with a VL53L0X or VL53L1X, an ESP32 or Arduino, four jumper wires and a breadboard.
2. Wire it upVIN to 3.3 V, GND to GND, SDA to GPIO21 and SCL to GPIO22 on a classic ESP32. Leave XSHUT and GPIO1 open for now.
3. Upload the sketchInstall the Adafruit VL53L0X (or VL53L1X) library, upload the example and hold your hand in front of the sensor.

Specifications

Electrical (both chips)

Supply voltage (AVDD)2.6 to 3.5 V, 2.8 V typical. Absolute maximum 3.6 V
I/O voltage1.8 V by default (1.6 to 1.9 V), or 2.8 V mode (2.6 to 3.5 V) after a software setting
Standby current3 to 7 µA in hardware standby (XSHUT low), 4 to 9 µA in software standby
Active current (VL53L0X)19 mA on average at the 33 ms timing budget, peaks of 40 mA
Power at 10 Hz (VL53L0X)20 mW with a 33 ms ranging sequence
I2CUp to 400 kHz, address 0x29 (0x52 as an 8-bit write address)
XSHUTActive-low shutdown, 10 kΩ pull-up recommended
GPIO1Interrupt output, 10 kΩ pull-up recommended
ESD2 kV (human body model), 500 V (charged device model)

VL53L0X ranging performance (33 ms timing budget, full field of view)

TargetIndoor, typicalIndoor, minimumOutdoor, overcast
White target, 88 %200 cm and more (long range profile)120 cm minimum80 cm typical, 60 cm minimum outdoors
Grey target, 17 %80 cm typical70 cm minimum50 cm typical, 40 cm minimum outdoors

Accuracy at a 33 ms budget is about 4 % on a white target at 120 cm indoors and about 7 % on a grey target at 70 cm. Outdoors in sunlight these numbers fall and the error rises to 7 % to 12 %.

VL53L1X distance modes (100 ms timing budget, white target)

ModeMaximum distance in the darkUnder strong ambient light
Short136 cm135 cm
Medium290 cm76 cm
Long360 cm73 cm

Strong ambient light, for example sun through a window, cuts the long and medium range drastically. Short mode is the most immune to light.

Source: ST datasheets for the VL53L0X (tables 6 to 12) and the VL53L1X (tables 4, 13 to 16).

Dimensions

The VL53L0X chip is 4.4 × 2.4 × 1.0 mm. The VL53L1X is 4.9 × 2.5 × 1.56 mm. Breakout boards come in many sizes, so measure your own board before you design a case. If the sensor sits behind a cover window, the datasheet asks for a specific glass or plastic and a small air gap, so test the window before you rely on it.

Source: package data in the ST datasheets.

Pins

PinTypeFunction
VIN / AVDDPowerSupply. Many breakouts have a regulator, so they take 3.3 V to 5 V, but the bare chip takes 2.6 to 3.5 V
GNDPowerGround
SDAI2CData, needs a pull-up
SCLI2CClock, needs a pull-up
XSHUTInputActive-low shutdown. Pull it low to put the chip to sleep or to reset it. Also used to give each sensor its own address
GPIO1OutputInterrupt output, goes active when a new measurement is ready or a threshold is crossed

The order of the header pins differs between boards, so read the print on yours.

Source: pin descriptions in the ST datasheets.

Wiring

Sensor pinESP32Arduino Uno / NanoRaspberry Pi
VIN3.3 V3.3 V3.3 V (pin 1)
GNDGNDGNDGND (pin 6)
SDAGPIO21A4GPIO2 (pin 3)
SCLGPIO22A5GPIO3 (pin 5)
XSHUTAny free GPIO (optional)Any free pin (optional)Any free GPIO (optional)
GPIO1Any free GPIO (optional)D2 (optional)Any free GPIO (optional)

The chip itself runs at 2.8 V and is not 5 V tolerant, but breakouts from Adafruit and Pololu have a regulator and level shifting, so they work on 5 V logic too. A bare, unbranded board may not: check with your seller before you connect 5 V.

Several sensors on one bus

All chips start at address 0x29, so two on one bus conflict. The solution is the XSHUT pin: hold all sensors in reset, wake them one by one, and give each a new address in software before you wake the next.

  • Connect XSHUT of every sensor to its own GPIO.
  • Pull all XSHUT pins low at start-up.
  • Release the first one, set its address (for example 0x30), release the second, set 0x31, and so on.
  • The new address is lost when the sensor loses power, so do this at every start-up.

This is what makes arrays of proximity sensors on robots possible. The datasheet says the address is programmable and the default is 0x52 as an 8-bit address.

Source: ST datasheets, control interface and pin descriptions.

Software setup

PlatformWhat to do
Arduino IDEInstall Adafruit VL53L0X or Adafruit VL53L1X from the Library Manager (they also install Adafruit BusIO). Pololu has its own libraries for both chips
PlatformIOAdd adafruit/Adafruit VL53L0X or adafruit/Adafruit VL53L1X to lib_deps
ESP-IDFUse ST’s API for the chip or a port of the Pololu driver

Example code

#include <Wire.h>
#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);
  if (!lox.begin()) {
    Serial.println("Failed to find VL53L0X");
    while (1) delay(10);
  }
}

void loop() {
  VL53L0X_RangingMeasurementData_t measure;
  lox.rangingTest(&measure, false);
  if (measure.RangeStatus != 4) {
    Serial.print("Distance (mm): ");
    Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println("Out of range");
  }
  delay(200);
}

For the VL53L1X the Adafruit library looks like this:

#include <Wire.h>
#include "Adafruit_VL53L1X.h"

Adafruit_VL53L1X vl53 = Adafruit_VL53L1X();

void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);
  if (!vl53.begin(0x29, &Wire)) {
    Serial.println("VL53L1X not found");
    while (1) delay(10);
  }
  vl53.startRanging();
  vl53.setTimingBudget(50);        // ms
}

void loop() {
  if (vl53.dataReady()) {
    int16_t mm = vl53.distance();
    if (mm != -1) Serial.printf("%d mmn", mm);
    vl53.clearInterrupt();
  }
}

I did not run these sketches on a board, they follow the library examples.

Getting good readings

  • Keep the lens clean. A fingerprint or dust on the window shifts the distance.
  • Mind the target. A white wall reads far, a black or glossy surface reads short or not at all. Mirrors and glass confuse the sensor.
  • Avoid sunlight. The sensors lose range in strong infrared light. Indoors with a lamp is fine, outdoors it is not.
  • Use the right distance mode on the L1X. Short mode for robust and bright places, long mode for the dark.
  • Choose the timing budget. A longer budget (66 ms, 100 ms) is more accurate. A short budget is faster but noisier.
  • Narrow the field of view. On the L1X choose a smaller region of interest to aim at one object in a box or bin.
  • Calibrate the offset. Measure a flat target at 10 cm and correct the offset, as the datasheet does. A window on top of the sensor needs a new calibration.
  • Average a few readings and ignore range status errors.

Real gotchas

  • The two chips need different libraries. A VL53L0X library does not run a VL53L1X.
  • The address is not 0x52. The datasheet says 0x52, but that is the 8-bit write address. In the Arduino world use the 7-bit address 0x29.
  • Two sensors, one address. Use XSHUT to give each its own address at every start-up.
  • 3.6 V is the limit. The bare chip must not see more than 3.6 V on any pin. Check your breakout before you use 5 V logic.
  • Range depends on light and target. The figures in the datasheet are for white and grey test targets, in the dark or in overcast light. Your project will see less.
  • Out-of-range values. Many libraries return a status code or a fixed number (for example 8190 or 65535) when nothing is in range. Check it.
  • A window is not free. Cover glass, tape or a 3D-printed lid cause crosstalk. Keep a small air gap and calibrate.
  • The beam is cone shaped. A 25° to 27° field means the beam is wide at a distance. Objects at the edge of the field return a short distance.
  • Laser safety. It is Class 1 and safe for the eye, but do not look into it through magnifying optics.

Compared with other distance sensors

SensorPrincipleRangeGood forWeak point
VL53L0XLaser ToFUp to 2 mSmall, narrow beamWeak in sunlight
VL53L1XLaser ToFUp to 4 mLonger, fast, adjustable fieldWeak in sunlight, different library
HC-SR04UltrasonicAbout 2 to 400 cmCheap, works in sunlightWide beam, 5 V, misses soft targets
IR distance sensor (Sharp type)Infrared, analogShortCheapAnalog, nonlinear

See the HC-SR04 guide for the ultrasonic option. The HC-SR04 range is from its own guide, and the Sharp row is general knowledge and not from a datasheet read for this guide.

What to build with it

  • Robotics obstacle avoidance: narrower beam than ultrasonic, less prone to false readings off soft/angled surfaces.
  • Liquid level sensing: measuring distance down to a surface through open air.
  • Gesture/proximity detection: fast enough ranging rate for hand-wave detection.
  • Tank/bin fill-level monitoring: the VL53L1X’s longer range suits larger containers.
  • A garage parking assistant that lights up as the car gets closer.
  • A touchless switch that reacts to a hand a few centimetres away.
  • A robot with a row of sensors that sees obstacles from the front and the sides.

Safety notes

Before you wire anything up

  • Keep the supply at 3.3 V (or the range your breakout states). The bare chip must never see more than 3.6 V.
  • The sensors are Class 1 laser devices. They are safe for normal use, but do not stare into the emitter through optics.
  • Never connect the board to mains voltage. Keep it on a low-voltage supply.
  • Disconnect the power before you change the wiring.
  • A distance sensor is not a safety device. Do not use it as the only protection for people or machines.

Conclusion

The VL53L0X and VL53L1X give you precise distances with a narrow laser beam over I2C. Take the VL53L0X for proximity and obstacle detection up to about a metre or two, and the VL53L1X for up to four metres, a faster rate and an adjustable field of view. Use XSHUT for several sensors, keep the lens clean and expect less range in the sun.

Chip data is from the ST datasheets for the VL53L0X (DocID029104 Rev 2) and the VL53L1X (DocID031281 Rev 3).

Advertisement
All guides

More guides

Keep building.

From ESP32 HomeKit accessories to Arduino and ATtiny reference guides, there’s more where this came from.

All guides