ESP32 VL53L1X Time-of-Flight Sensor
Overview
The VL53L1X is a high-accuracy long-distance laser-ranging sensor from STMicroelectronics. It uses a 940nm VCSEL emitter and advanced SPAD detection to measure absolute distances up to 4 meters with millimeter-level precision.
Choose Your Platform
About VL53L1X Time-of-Flight Sensor
📏 VL53L1X Sensor Overview
- Range: 0cm to 400cm (Max)
- Interface: I²C digital communication
- Resolution: 1mm
- Field of View: 27°
- Operating Voltage: 2.6V to 3.5V (typically 3.3V)
- Typical Current: ~20–40mA during ranging
- Laser Wavelength: 940nm
- Adjustable timing budget and distance mode
- Compact 6-pin PCB module with mounting holes
Check Other sensors modules based on VL53L1X Time of Flight Sensor:
Where to Buy
Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
Technical Specifications
Pinout Configuration
The VCC
pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND
pin is the ground connection and must be connected to the ground of your ESP32.
- VIN: Power supply (3.3V recommended)
- GND: Ground
- SCL: I²C Clock
- SDA: I²C Data
- GPIO1: Interrupt output
- XSHUT: Shutdown (active low)
Troubleshooting Guide
Common Issues
🚫 Sensor Not Detected
Issue: Sensor not responding over I²C.
Solution: Verify wiring, check if XSHUT is high, and ensure the I²C address does not conflict with other devices.
📉 Distance Readings Fluctuate
Issue: Unstable distance values.
Solution: Use longer timing budget in code, or stabilize the environment (lighting, surface reflectivity).
⚠️ Always Reads Maximum
Issue: Sensor stuck at max distance (4000 mm).
Solution: Ensure object is within line of sight, avoid high IR interference, and ensure proper power supply.
Debugging Tips
🔍 Serial Monitor
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
⚡ Voltage Checks
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
Code Examples
Arduino Example
#include <Wire.h>
#include <Adafruit_VL53L1X.h>
Adafruit_VL53L1X vl = Adafruit_VL53L1X();
void setup() {
Serial.begin(115200);
Wire.begin();
if (!vl.begin()) {
Serial.println("Failed to find VL53L1X sensor!");
while (1);
}
vl.setDistanceMode(VL53L1X::Long);
vl.setTimingBudget(50);
vl.startRanging();
Serial.println("VL53L1X ready!");
}
void loop() {
if (vl.dataReady()) {
int distance = vl.read();
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" mm");
}
delay(100);
}
ESPHome Example
i2c:
sda: 21
scl: 22
sensor:
- platform: vl53l1x
name: "VL53L1X Distance"
long_range: true
update_interval: 1s
MicroPython Example
from machine import I2C, Pin
import time
from vl53l1x import VL53L1X
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
tof = VL53L1X(i2c)
tof.start()
while True:
distance = tof.read()
print("Distance: {} mm".format(distance))
time.sleep(0.5)
vl53l1x.py
driver. It initializes the sensor and prints distance measurements every 0.5 seconds.Conclusion
The ESP32 VL53L1X Time-of-Flight Sensor is a powerful distance sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.