VL53L0X ToF with a Raspberry Pi Pico

A laser time-of-flight distance sensor that measures absolute range up to 2 m over I2C, independent of the target's color or reflectance.

VL53L0X ToF, A laser time-of-flight distance sensor that measures absolute range up to 2 m over I2C, independent of the target's color or reflectance.
In short

The VL53L0X time-of-flight sensor connects to the Raspberry Pi Pico's I2C0, SDA on GP4 and SCL on GP5, at address 0x29, powered from 3V3. Ranging draws more than most I2C sensors, and every VL53L0X starts at the same address, which shapes multi-sensor builds on the Pico.

Wiring the VL53L0X ToF to the Raspberry Pi Pico

Pin by pin.

VL53L0X ToFRaspberry Pi Pico
VCC3V3
GNDGND
SCLGP5
SDAGP4

What to know on the Raspberry Pi Pico

  • It draws 19 mA on average while ranging, comfortably inside the 300 mA Raspberry Pi recommends for the 3V3 pin even with several sensors.ST VL53L0X datasheet DocID029104 Rev 2, p. 23; Raspberry Pi Pico datasheet, release 21, p. 8
  • Every VL53L0X powers up at 0x29. For several on one Pico, wire each XSHUT to a GPIO, hold all but one in reset, give the awake one a new address, and repeat.ST VL53L0X datasheet DocID029104 Rev 2, p. 18; Pololu VL53L0X library (setAddress)
  • The bare chip runs from 2.6 V to 3.5 V; the breakout's regulator lets it take the Pico's 3V3, and its I2C lines stay at 3.3 V.ST VL53L0X datasheet DocID029104 Rev 2, p. 6
  • Leave XSHUT unconnected for a single sensor (the breakout pulls it up); tied to GND it holds the sensor in reset.Adafruit VL53L0X breakout, pinouts (XSHUT); ST VL53L0X datasheet, XSHUT

VL53L0X ToF code for the Raspberry Pi Pico

Compiled for rp2040:rp2040:rpipico on 2026-10-30.

Libraries: pololu/VL53L0X, adafruit/Adafruit_VL53L0X
// VL53L0X ToF on Raspberry Pi Pico: wiring and a free simulation at https://www.tinkered.ai/components/vl53l0x-tof/raspberry-pi-pico
#include <Wire.h>
#include <VL53L0X.h>

VL53L0X sensor;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  if (!sensor.init()) {                 // reads model id 0xEE at 0x29
    Serial.println("VL53L0X not found");
    while (1) {}
  }
  sensor.setTimeout(500);
}

void loop() {
  uint16_t mm = sensor.readRangeSingleMillimeters();
  if (sensor.timeoutOccurred()) {
    Serial.println("VL53L0X timeout");  // no answer in 500 ms: wiring or power
  } else if (mm >= 8190) {
    Serial.println("out of range");     // no target within range
  } else {
    Serial.print(mm);
    Serial.println(" mm");
  }
  delay(200);
}

VL53L0X ToF on the Raspberry Pi Pico: questions

Can I use several VL53L0X sensors with one Pico?

Yes: wire each XSHUT to its own GPIO, wake them one at a time and assign each a new I2C address; they all start at 0x29 (ST datasheet, p. 18). The Pico's second I2C controller also helps.

Why does my Pico print 'VL53L0X timeout'?

No answer within 500 ms: check SDA on GP4, SCL on GP5, 3V3 power and that XSHUT is not pulled low.

What range does the VL53L0X give on a Pico?

Up to 2 m (ST datasheet, p. 1), the same on any board; readings of 8190 or more mean no target in range.

Keep going

For AI assistants

This guide as plain Markdown. /components/vl53l0x-tof/raspberry-pi-pico.md

What will you build with it?