Summary
Learn how the VL53L1X time-of-flight sensor measures distance up to 4 metres and how it compares with the VL53L0X and HC-SR04. Follow the wiring guide, Arduino code example, and practical tips for improving ranging performance on different surfaces and in outdoor lighting.
Theย VL53L1X is a laser time-of-flight sensor that measures distance up to 4 m by timing reflected infrared light. It talks over I2C at up to 400 kHz. Compared with the VL53L0X, it can reach farther and supports a programmable field of view.
This guide covers how the VL53L1X works, how it compares with the VL53L0X and HC-SR04, how to wire it to Arduino or ESP32, and how to read distance measurements in code.
What Is a ToF Sensor?
A time-of-flight (ToF) sensor measures distance by calculating how long light takes to travel to an object and return to the sensor. The VL53L1X uses an infrared laser emitter and a receiver to measure this travel time, then reports the calculated distance digitally.
Unlike an ultrasonic sensor, which measures the travel time of sound, a ToF sensor uses light. This allows the VL53L1X to fit into compact projects that need non-contact distance measurements, such as robotics, obstacle detection, object sensing, and interactive devices.
The VL53L1X integrates the emitter, receiver, and ranging circuitry in a small module. A microcontroller communicates with it using I2C, so it does not require a separate trigger and echo connection like the HC-SR04.
Its maximum advertised range is up to 4 m under suitable conditions. Actual results depend on the target's reflectivity, ambient light, sensor configuration, and operating environment.
VL53L1X vs VL53L0X vs HC-SR04
These three sensors can all measure distance, but they use different technologies and have different wiring and performance characteristics.
|
Feature |
VL53L1X |
VL53L0X |
HC-SR04 |
|---|---|---|---|
|
Measurement technology |
Infrared laser time-of-flight |
Infrared laser time-of-flight |
Ultrasonic sound |
|
Advertised maximum range |
Up to 4 m |
Up to 2 m |
Commonly specified around 4 m |
|
Communication |
I2C |
I2C |
Trigger and echo digital signals |
|
Typical interface pins |
VIN, GND, SDA, SCL, XSHUT, GPIO1 on many breakout boards |
VIN, GND, SDA, SCL, XSHUT, GPIO1 on many breakout boards |
VCC, GND, TRIG, ECHO |
|
Measurement speed |
Configurable timing budget and ranging mode |
Configurable measurement timing |
Depends on trigger interval and echo timing |
|
Field of view |
Programmable region of interest on supported configurations |
Generally wider and less configurable |
Determined by the ultrasonic transducers and beam pattern |
|
Main advantage |
Longer range and flexible sensing region |
Compact optical ranging for shorter distances |
Low cost and simple interface |
|
Main limitation |
Performance can vary with target and lighting conditions |
Shorter maximum range than VL53L1X |
Can be affected by target shape, soft materials, and acoustic interference |
Specifications vary between manufacturers and breakout boards. The HC-SR04's commonly quoted 4 m range is a nominal specification, not a guarantee of reliable measurements at that distance.
Which should you choose?
-
Choose the VL53L1X when you need compact optical ranging, a longer potential range than the VL53L0X, or control over the sensing region.
-
Choose the VL53L0X for shorter-range optical distance measurement when its range and features are sufficient.
-
Choose the HC-SR04 for budget projects where ultrasonic sensing is suitable and the larger module is not a problem.
Neither optical sensor is guaranteed to outperform ultrasonic sensing in every environment. Test the sensor with the actual objects, distances, and lighting conditions of your project.
VL53L1X Pinout and Quick Connector Guide
The VL53L1X sensor chip uses a low-voltage supply, but many breakout boards include voltage regulation and level shifting to simplify connections. Check your exact board's documentation before applying 5V. A bare sensor and a breakout board may have different power requirements.
ย
|
Pin |
Function |
Connection |
|---|---|---|
|
VIN |
Board power input |
Compatible voltage specified for your breakout |
|
GND |
Ground |
Arduino or ESP32 GND |
|
SDA |
I2C data |
Controller SDA |
|
SCL |
I2C clock |
Controller SCL |
|
XSHUT |
Hardware shutdown |
Optional GPIO, if used |
|
GPIO1 |
Interrupt output |
Optional GPIO, if used |
The four essential connections for a basic setup are VIN, GND, SDA, and SCL. XSHUT and GPIO1 are not required for a simple distance-reading sketch.
Wiring the VL53L1X With Arduino Uno
For a compatible breakout board, connect the sensor to an Arduino Uno as follows:
|
VL53L1X breakout |
Arduino Uno |
|---|---|
|
VIN |
5V, only if the breakout supports 5V input |
|
GND |
GND |
|
SDA |
A4 (SDA) |
|
SCL |
A5 (SCL) |
The Uno uses A4 for SDA and A5 for SCL. On boards with dedicated SDA and SCL pins, those pins can also be used as documented by the board manufacturer.
Keep the I2C wires reasonably short for reliable communication. If the sensor is not detected, check the supply voltage, ground connection, SDA/SCL wiring, and breakout compatibility before troubleshooting the code.
Wiring the VL53L1X With ESP32
The ESP32 uses 3.3V logic, making it important to check the voltage levels on the sensor breakout's I2C pins.
|
VL53L1X breakout |
Typical ESP32 DevKit |
|---|---|
|
VIN |
3V3 or the board's specified input voltage |
|
GND |
GND |
|
SDA |
GPIO 21 |
|
SCL |
GPIO 22 |
GPIO 21 and GPIO 22 are common default I2C pins on many ESP32 DevKit boards, but they are not universal. Check your board's pinout and change the I2C configuration if needed. Ensure the breakout's SDA and SCL pull-up voltages are compatible with the ESP32.
Arduino Code for VL53L1X Distance Measurement
One beginner-friendly option is the Pololu VL53L1X Arduino library. Install it through the Arduino IDE Library Manager by searching for VL53L1X and selecting the Pololu library. The library provides functions for initializing the sensor and reading distance in millimetres.
ย
Upload this example after completing the wiring:
#include <Wire.h>
#include <VL53L1X.h>
VL53L1X sensor;
void setup() {
Serial.begin(115200);
Wire.begin();
sensor.setTimeout(500);
if (!sensor.init()) {
Serial.println("VL53L1X not detected. Check wiring.");
while (1) {
delay(10);
}
}
sensor.setDistanceMode(VL53L1X::Long);
sensor.setMeasurementTimingBudget(50000);
sensor.startContinuous(50);
Serial.println("VL53L1X ready");
}
void loop() {
uint16_t distance = sensor.read();
if (sensor.timeoutOccurred()) {
Serial.println("Sensor timeout");
delay(100);
return;
}
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" mm");
delay(100);
}
How the code works
-
Wire.begin()starts I2C communication. -
sensor.init()initializes the VL53L1X. If initialization fails, the program reports an error. -
setDistanceMode(VL53L1X::Long)selects long-distance mode. Actual range still depends on the target and environment. -
setMeasurementTimingBudget(50000)sets a 50,000-microsecond timing budget. -
startContinuous(50)requests continuous measurements at 50 ms intervals. -
sensor.read()returns the measured distance in millimetres. -
sensor.timeoutOccurred()checks whether the read operation timed out.
Open the Serial Monitor and set its baud rate to 115200. Move a flat object in front of the sensor and watch the reported distance change.
If initialization fails, verify the wiring and power first. Also check that the intended VL53L1X library is installed and that the I2C bus is configured correctly for your board.
Short, Medium and Long Distance Modes
The VL53L1X supports short, medium, and long distance modes through its software interface. These modes change the sensor configuration to suit different measurement conditions. They do not guarantee a particular range in every environment.
-
Short mode: Useful for nearby targets and conditions where limiting ambient-light effects is important.
-
Medium mode: A practical option when you need a balance between range and measurement conditions.
-
Long mode: Intended for applications that need greater distance, potentially reaching the advertised 4 m under suitable conditions.
The best mode depends on the target surface, ambient light, measurement timing budget, and desired update rate. Test the sensor with your actual setup before choosing a final configuration.
ย
VL53L1X Accuracy in Sunlight and on Dark Surfaces
The VL53L1X can measure objects with different colours and reflectivity, but real-world conditions affect measurement reliability.
Does sunlight affect the VL53L1X?
Strong ambient infrared light, including direct sunlight, can reduce ranging performance. If measurements become unstable outdoors, try reducing the distance, changing the sensor angle, shielding it from direct light where practical, or adjusting the measurement configuration.
Can it detect black or dark objects?
Dark surfaces often reflect less infrared light than light-coloured surfaces. The sensor may still detect them, but the reliable measurement range can be shorter. Test the exact material and distance required by your project.
How can I improve measurement stability?
-
Mount the sensor securely so it does not move during readings.
-
Avoid placing reflective objects or surfaces close to the sensor's optical path.
-
Select a suitable distance mode and measurement timing budget.
-
Test in the lighting conditions in which the project will operate.
-
Filter occasional outliers in software if the application can tolerate a small amount of delay.
For applications that need dependable measurements, evaluate not just the displayed distance but also whether readings are valid and stable under expected conditions.
VL53L1X Project Ideas
The sensor's compact size and I2C interface make it useful in a range of electronics projects.
1. Robot obstacle detection
Mount the sensor at the front of a mobile robot and use distance readings to slow down, stop, or change direction when an obstacle gets too close.
2. Non-contact object detection
Use a distance threshold to detect when an object enters a defined area. This can be useful in small automation projects and interactive installations.
3. Distance-based control
Connect the sensor to an Arduino or ESP32 and use the measured distance to control an LED, display, buzzer, or other output.
4. People and proximity sensing
The sensor can support presence-related applications, but a single distance reading does not identify a person or reliably distinguish people from other objects. Design the detection logic around the actual application.
5. Multizone distance experiments
The programmable region of interest (ROI) lets supported configurations focus on different parts of the sensor's receiving array. This can help with directional sensing experiments and more advanced detection systems. Access to ROI features depends on the software library and API used.
ย
Get the VL53L1X ToF Distance Sensor
If you are building an Arduino or ESP32 project that needs compact, non-contact distance measurement, check the VL53L1X ToF Distance Sensor (7 m variant).
Check the product listing for the exact board version, supported input voltage, pinout, and current availability before connecting it to your controller. The sensor's nominal range is not a guarantee of reliable detection at every distance or under all lighting conditions.
Conclusion
The VL53L1X is a compact time-of-flight sensor designed for distance measurement up to 4 m under suitable conditions. Its I2C interface makes it straightforward to connect to compatible Arduino and ESP32 boards, while its configurable distance modes and programmable sensing region support a range of projects.
Compared with the VL53L0X, it offers greater potential range and more flexible region-of-interest control. Compared with the HC-SR04, it uses infrared light instead of ultrasound and has a different interface and set of environmental limitations.
For reliable results, check the breakout board's voltage requirements, wire SDA and SCL correctly, install a compatible library, and test the sensor with the actual targets and lighting conditions in your project.
Excerpt
Frequently Asked Questions
1. What is the range of the VL53L1X?
The VL53L1X has an advertised maximum ranging distance of up to 4 m and a ranging frequency of up to 50 Hz. Actual performance depends on ambient light, target reflectivity, sensor configuration, and other environmental conditions.
2. Is the VL53L1X suitable for robotics?
Yes. It can be used for obstacle detection, proximity sensing, and distance-based control in robotics projects. Test the sensor's range and response time in the robot's actual environment before relying on it for navigation or collision avoidance.
3. Does the VL53L1X work outdoors?
It can work outdoors, but strong sunlight may affect measurement performance. Test it in the intended lighting conditions and adjust the sensor configuration or mounting if readings become unreliable.
4. Can I use multiple VL53L1X sensors on one I2C bus?
Yes. Multiple sensors can share an I2C bus, but they normally start with the same default address, 0x29. Hold each sensor in shutdown using its XSHUT pin, enable the sensors one at a time, and assign each a different I2C address during startup. The assigned addresses are typically lost after a reset or power cycle, so the setup must be repeated.
5. What is the I2C address of the VL53L1X?
The default 7-bit I2C address is 0x29. If using multiple sensors on the same bus, configure unique addresses during initialization and ensure each sensor is enabled at the appropriate time.
0x29. Hold each sensor in shutdown using its XSHUT pin, enable the sensors one at a time, and assign each a different I2C address during startup. The assigned addresses are typically lost after a reset or power cycle, so the setup must be repeated.0x29. If using multiple sensors on the same bus, configure unique addresses during initialization and ensure each sensor is enabled at the appropriate time.