ESP32 VL53L0X V2 Time-of-Flight Sensor
Overview
The VL53L0X V2 (GY-VL53L0XV2) is a high-accuracy Time-of-Flight (ToF) laser ranging sensor that can measure distances up to 2 meters. It's ideal for gesture sensing, obstacle detection, and IoT applications requiring compact, low-power, and precise distance measurement. The VL53L0X V2 (GY-VL53L0XV2) is functionally similar to V1 but offers improved signal stability and build quality. While both versions use the same ST VL53L0X chip, the V2 module typically features a slightly larger PCB (25x13mm) with better trace routing, additional capacitors, and more robust pull-ups. It's more plug-and-play friendly for modern ESP boards and includes clear labeling for I²C, XSHUT, and GPIO pins.
Choose Your Platform
About VL53L0X V2 Time-of-Flight Sensor
📏 VL53L0X V2 Sensor Overview
- Range: 3cm to 200cm (Max)
- Interface: I²C digital communication
- Resolution: 1mm
- Field of View: ~25°
- Operating Voltage: 3V to 5V
- Typical Current: ~20–40mA
- Compact Board Size: 25mm × 13mm × 3mm
- I²C Pins + XSHUT + GPIO (interrupt/reset)
Check Other sensors modules based on VL53L0X 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.0V–5.0V)
- GND: Ground
- SCL: I²C Clock
- SDA: I²C Data
- XSHUT: Reset pin
- GPIO: Interrupt output (optional)
Troubleshooting Guide
Common Issues
🚫 Sensor Not Detected
Issue: VL53L0X not showing on I²C bus.
Solution: Check that XSHUT is tied high and that SDA/SCL are correctly connected. Scan for address with I²C scanner.
📉 Inaccurate or Unstable Readings
Issue: Sensor gives fluctuating values.
Solution: Try averaging measurements and avoid reflective or dark objects too close to the sensor.
⚠️ Always Reads Maximum Distance
Issue: Constant 2000 mm or 0 mm readings.
Solution: Ensure object is within range and directly in front of the sensor. Add a delay between readings.
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_VL53L0X.h>
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
void setup() {
Serial.begin(115200);
Wire.begin();
if (!lox.begin()) {
Serial.println("Failed to initialize VL53L0X V2 sensor!");
while (1);
}
Serial.println("VL53L0X V2 ready!");
}
void loop() {
VL53L0X_RangingMeasurementData_t measure;
lox.rangingTest(&measure, false);
if (measure.RangeStatus != 4) {
Serial.print("Distance: ");
Serial.print(measure.RangeMilliMeter);
Serial.println(" mm");
} else {
Serial.println("Out of range");
}
delay(500);
}
ESPHome Example
i2c:
sda: 21
scl: 22
sensor:
- platform: vl53l0x
name: "VL53L0X V2 Distance"
update_interval: 1s
MicroPython Example
from machine import I2C, Pin
import time
import vl53l0x
# Initialize I2C interface
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
# Initialize VL53L0X sensor
tof = vl53l0x.VL53L0X(i2c)
tof.start()
while True:
distance = tof.read()
print("Distance: {} mm".format(distance))
time.sleep(0.5)
vl53l0x.py
driver must be present on your board.Conclusion
The ESP32 VL53L0X V2 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.