The VL53L0X measures distance with an infrared laser pulse — narrower beam than an ultrasonic sensor, no 5 V, and good from about 3 cm to 1.2–2 m indoors.
On the SuperMini wire VIN to 3V3, SDA to GPIO5 and SCL to GPIO6. The sketch uses the Pololu library in continuous mode and prints a reading five times a second.
Wiring
| ESP32-C3 SuperMini | VL53L0X ToF distance sensor | Wire | Notes |
|---|---|---|---|
| 3V3 | VIN | red | |
| GND | GND | black | |
| 6 | SCL | yellow | |
| 5 | SDA | blue |
2.6–5 V (on-board regulator) part, 3.3 V board. Breakouts with a regulator and level shifting accept 3.3 V or 5 V. Bare boards without them are 2.8 V-only — check the listing.
Board quirks
- I2C on GPIO5/6 — the core’s default GPIO8/9 are strapping pins carrying the SuperMini’s LED and BOOT button.
- Peel the clear protective film off the sensor window. With it on, readings stick around 20–50 mm.
- Unlike the HC-SR04 the VL53L0X is a 3.3 V part, so there is no divider and it fits a battery-powered SuperMini project.
- Every VL53L0X starts at 0x29. For two sensors, hold one in reset with XSHUT and change the other’s address with
setAddress().
Code
// VL53L0X time-of-flight distance sensor on an ESP32-C3 SuperMini over I2C (address 0x29).
// VIN → 3V3, GND → GND, SDA → GPIO5, SCL → GPIO6. XSHUT and GPIO1 left open.
#include <Wire.h>
#include <VL53L0X.h>
constexpr int SDA_PIN = 5;
constexpr int SCL_PIN = 6;
VL53L0X sensor;
void setup() {
Serial.begin(115200);
delay(1500); // let the native USB serial port enumerate
Wire.begin(SDA_PIN, SCL_PIN); // GPIO8/9 are strapping pins on the C3 — not used for I2C
sensor.setBus(&Wire);
sensor.setTimeout(500);
if (!sensor.init()) {
Serial.println("VL53L0X not found at 0x29 — check wiring and remove the protective film");
while (true) delay(1000);
}
sensor.startContinuous(); // back-to-back measurements (~33 ms each)
Serial.println("VL53L0X ready");
}
void loop() {
uint16_t mm = sensor.readRangeContinuousMillimeters();
if (sensor.timeoutOccurred()) {
Serial.println("Timeout");
} else if (mm >= 8190) {
Serial.println("Out of range");
} else {
Serial.printf("Distance: %u mm\n", mm);
}
delay(200);
}// VL53L0X time-of-flight distance sensor on an ESP32-C3 SuperMini over I2C (address 0x29).
// VIN → 3V3, GND → GND, SDA → GPIO5, SCL → GPIO6. XSHUT and GPIO1 left open.
#include <Wire.h>
#include <VL53L0X.h>
constexpr int SDA_PIN = 5;
constexpr int SCL_PIN = 6;
VL53L0X sensor;
void setup() {
Serial.begin(115200);
delay(1500); // let the native USB serial port enumerate
Wire.begin(SDA_PIN, SCL_PIN); // GPIO8/9 are strapping pins on the C3 — not used for I2C
sensor.setBus(&Wire);
sensor.setTimeout(500);
if (!sensor.init()) {
Serial.println("VL53L0X not found at 0x29 — check wiring and remove the protective film");
while (true) delay(1000);
}
sensor.startContinuous(); // back-to-back measurements (~33 ms each)
Serial.println("VL53L0X ready");
}
void loop() {
uint16_t mm = sensor.readRangeContinuousMillimeters();
if (sensor.timeoutOccurred()) {
Serial.println("Timeout");
} else if (mm >= 8190) {
Serial.println("Out of range");
} else {
Serial.printf("Distance: %u mm\n", mm);
}
delay(200);
}Library: VL53L0X (Pololu) — compiled with VL53L0X 1.3.1.
Expected serial output
VL53L0X ready
Distance: 412 mm
Distance: 409 mm
Out of rangeVL53L0X ready Distance: 412 mm Distance: 409 mm Out of range
Common errors
“VL53L0X not found at 0x29”
Check SDA/SCL and power. I2C troubleshooting.
Readings are short or stuck
Protective film still on, or the target is dark/shiny. White, matt targets read best.