Light, distance and motion
VL53L0X with ESP32
The VL53L0X measures distance with a tiny laser and a time-of-flight sensor, over I2C. Compared with an HC-SR04 it is far smaller and works on soft surfaces, but its range is shorter. Adafruit quotes about 50 mm to 1.2 m in default mode, and up to 1.5 to 2 m in long range mode on a white, reflective surface.
The chip itself needs 2.8 V, so buy a module with a regulator and level shifting, which then works from 3 to 5 V. Dark or absorbing surfaces return little light, and bright sunlight hurts accuracy. Adafruit expects 3 to 12 % ranging accuracy, depending on ambient light and distance.
Every sensor starts on address 0x29, so two on one bus clash. To use several, hold the others in shutdown with their XSHUT pins and change each address at startup. The address is not stored, so this runs on every boot. On a display board this means extra free pins, which are often missing.

Specifications
| Measures | Distance by time of flight |
|---|---|
| Default range | About 50 mm to 1.2 m |
| Long range mode | About 1.5–2 m on white surfaces |
| Chip supply | 2.8 V, modules add a regulator |
| Interface | I2C |
| Default address | 0x29 |
| Accuracy | 3–12 %, by light and distance |
Power and logic levels
3.3 V: safe to connect directly
| Supply | Chip up to 3.5 V, some modules have a regulator |
|---|---|
| Signal level | 3.3 V |
| On an ESP32 | Run it from 3V3, so the I2C lines stay at 3.3 V. |
ESP32 pins, including those on a display board's connectors, work at 3.3 V and are not 5 V tolerant. Modules differ, so if in doubt, measure the signal before you connect it.
Wiring
| VL53L0X | Connect to | Note |
|---|---|---|
| VIN / VCC | 3V3 | |
| GND | GND | |
| SDA | GPIO 8 | Any free pin, set in Wire.begin() |
| SCL | GPIO 9 | Any free pin, set in Wire.begin() |
| XSHUT | Not connected | GPIO only for several sensors |
Arduino code
#include <Wire.h>
#include <Adafruit_VL53L0X.h>
const int SDA_PIN = 8, SCL_PIN = 9; // use your board's I2C pins
Adafruit_VL53L0X lox;
void setup() {
Serial.begin(115200);
Wire.begin(SDA_PIN, SCL_PIN);
if (!lox.begin(VL53L0X_I2C_ADDR, false, &Wire)) {
Serial.println("VL53L0X not found: check wiring");
while (true) delay(1000);
}
}
void loop() {
VL53L0X_RangingMeasurementData_t m;
lox.rangingTest(&m, false);
if (m.RangeStatus != 4) Serial.printf("%d mm\n", m.RangeMilliMeter);
else Serial.println("Out of range");
delay(200);
}
Needs the Adafruit_VL53L0X library. Compiled for ESP32-S3 with arduino-esp32 3.x. Not yet tested by us on a physical sensor. Change the pins to match your board.
On a display
Read the value in your sketch and pass it to a label, or send it over MQTT and show it with an MQTT value in the editor.
Design a display for VL53L0XBoards with a ready connector
Only boards whose connectors we have surveyed. Others may still work on free GPIOs.
| Elecrow CrowPanel ESP32 HMI 2.4" | I2C port: SDA 22, SCL 21Not shared with the touch controller (it is on SPI) — free for sensors |
| Elecrow CrowPanel ESP32 HMI 2.8" | I2C port: SDA 22, SCL 21Not shared with the touch controller (it is on SPI) — free for sensors |
| Elecrow CrowPanel ESP32 HMI 3.5" | I2C port: SDA 22, SCL 21Not shared with the touch controller (it is on SPI) — free for sensors |
| Elecrow CrowPanel ESP32-S3 HMI 5.0" | I2C port: SDA 19, SCL 20Same I2C bus as the GT911 touch (0x14 / 0x5D) and, on V3.0 boards, the PCA9557 touch-reset expander (0x18) |
| Elecrow CrowPanel ESP32-S3 HMI 7.0" | I2C port: SDA 19, SCL 20Same I2C bus as the GT911 touch (0x14 / 0x5D) and, on V3.0 boards, the PCA9557 touch-reset expander (0x18) |
| LilyGO T-Display-S3-Pro 2.33" | QWIIC RIGHT: SDA 5, SCL 6I2C only — same bus as the touch, the PMU (SY6970) and the light sensor |
| M5Stack AtomS3 0.85" | Bottom I2C pins: SDA 38, SCL 39Same I2C bus as the built-in IMU (MPU6886, 0x68) |
| Makerfabs MaTouch ESP32-S3 Rotary IPS 2.1 Round | Mabee I2C (J1): SDA 17, SCL 18Same I2C bus as the touch controller (CST826) |
| Makerfabs MaTouch ESP32-S3 Parallel TFT 4.3" | Mabee I2C: SDA 17, SCL 18Same I2C bus as the touch controller (GT911) |
| Makerfabs MaTouch ESP32-S3 Parallel TFT with Touch 5.0" | Mabee I2C: SDA 17, SCL 18Same I2C bus as the touch controller (GT911) |
| Makerfabs MaTouch ESP32-S3 Parallel TFT with Touch 7.0" | Mabee I2C: SDA 17, SCL 18Same I2C bus as the touch controller (GT911) |
| Sunton ESP32-4827S043R/C 4.3" | I2C header (P3): SDA 19, SCL 20Same I2C bus as the GT911 touch controller. P3 also carries GPIO 17 / 18. |
| Sunton ESP32-8048S043C 4.3" | I2C header (P3): SDA 19, SCL 20Same I2C bus as the GT911 touch controller. P3 also carries GPIO 17 / 18. |
| Sunton ESP32-8048S050C 5.0" | I2C header (P3): SDA 19, SCL 20Same I2C bus as the GT911 touch controller. P3 also carries GPIO 17 / 18. |
| Sunton ESP32-8048S070C 7.0" | I2C header (P3): SDA 19, SCL 20Same I2C bus as the GT911 touch controller. P3 also carries GPIO 17 / 18. |
| Waveshare ESP32-S3 Touch LCD 2.1" round | I2C connector: SDA 15, SCL 7Same I2C bus as the touch controller, the IO expander, the RTC and the IMU (addresses 0x15/0x5D, 0x20, 0x51, 0x6B, 0x7E taken) |
| Waveshare ESP32-S3 Touch LCD 2.8" | I2C connector: SDA 11, SCL 10Same I2C bus as the RTC and the IMU (0x51, 0x6B, 0x7E taken) — the touch has its own bus |
| Waveshare ESP32-S3 Touch LCD 2.8" Type B | I2C connector: SDA 15, SCL 7Same I2C bus as the touch controller, the IO expander, the RTC and the IMU (addresses 0x15/0x5D, 0x20, 0x51, 0x6B, 0x7E taken) |
| Waveshare ESP32-S3-Touch-LCD-2.8C | I2C connector: SDA 15, SCL 7Same I2C bus as the touch controller, the IO expander, the RTC and the IMU (addresses 0x15/0x5D, 0x20, 0x51, 0x6B, 0x7E taken) |
| Waveshare ESP32-S3-LCD-7B | I2C connector (H1): SDA 8, SCL 9Same I2C bus as the touch controller (GT911) and the IO expander (CH422G) |
Good to know
- All sensors start at 0x29. Several need XSHUT pins.
- Dark surfaces and sunlight reduce range.
- The bare chip is 2.8 V. Use a module with a regulator.
- For longer range, consider a larger ultrasonic or laser module.
What it is good for
- Hand gesture and presence triggers
- Short-range level sensing
- Small robots
FAQ
What is the VL53L0X I2C address?
0x29 by default. It can be changed at startup, but the new address is not stored.
How far does it measure?
About 1.2 m in default mode, up to about 2 m in long range mode on white surfaces.
VL53L0X or HC-SR04?
VL53L0X is smaller and uses I2C. HC-SR04 reaches further but needs 5 V and a divider.
Sources
Related parts
Use this information at your own risk. It is for general guidance only: the example code compiles, but it has not been tested on every part, and modules differ between sellers. Check the manufacturer's data before you build. Product names belong to their owners, and LCD Ultra Pro is not affiliated with them. See our Terms.