Using the VL53L1X with Arduino involves wiring up the sensor to your Arduino-compatible microcontroller, installing the Adafruit VL53L1X library and running the provided example code.


Wire as shown for a 5V board like an UNO. If you are using a 3V board, like an Adafruit Metro, wire the board's 3V pin to the VL53L1X Vin.

  • Board 5V to sensor Vin
  • Board GND to sensor GND
  • Board SCL to sensor SCL
  • Board SDA to sensor SDA
  • Board 2 to sensor GPIO
  • Board 3 to sensor XSHUT

Library Installation

You can install the VL53L1X library for Arduino using the Library Manager in the Arduino IDE.

Click the Manage Libraries ... menu item, search for VL53L1X , and select the Adafruit VL53L1X library:

If asked about dependencies, click "Install all".

Load Example

Open up File -> Examples -> Adafruit VL53L1X -> VL53L1X_simpletest and upload to your Arduino wired to the sensor.

#include "Adafruit_VL53L1X.h"

#define IRQ_PIN 2
#define XSHUT_PIN 3

Adafruit_VL53L1X vl53 = Adafruit_VL53L1X(XSHUT_PIN, IRQ_PIN);

void setup() {
  while (!Serial) delay(10);

  Serial.println(F("Adafruit VL53L1X sensor demo"));

  if (! vl53.begin(0x29, &Wire)) {
    Serial.print(F("Error on init of VL sensor: "));
    while (1)       delay(10);
  Serial.println(F("VL53L1X sensor OK!"));

  Serial.print(F("Sensor ID: 0x"));
  Serial.println(vl53.sensorID(), HEX);

  if (! vl53.startRanging()) {
    Serial.print(F("Couldn't start ranging: "));
    while (1)       delay(10);
  Serial.println(F("Ranging started"));

  // Valid timing budgets: 15, 20, 33, 50, 100, 200 and 500ms!
  Serial.print(F("Timing budget (ms): "));

  vl.VL53L1X_SetDistanceThreshold(100, 300, 3, 1);

void loop() {
  int16_t distance;

  if (vl53.dataReady()) {
    // new measurement for the taking!
    distance = vl53.distance();
    if (distance == -1) {
      // something went wrong!
      Serial.print(F("Couldn't get distance: "));
    Serial.print(F("Distance: "));
    Serial.println(" mm");

    // data is read out, time for another reading!

Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You should see the the values from the senor being printed out.

This guide was first published on Oct 27, 2021. It was last updated on Jun 23, 2024.

This page (Arduino) was last updated on Jun 23, 2024.

Text editor powered by tinymce.