PiicoDev Distance Sensor VL53L1X - Raspberry Pi Pico Guide

Updated 27 July 2021


This guide will help you read distance data in millimeters from your PiicoDev® Distance Sensor and a Raspberry Pi Pico

To follow along, it's best to have:

If you prefer not to use the Expansion Board for Raspberry Pi Pico, there are other connection options in our PiicoDev Connection Guide.

Connect the PiicoDev sensor to your Pico

Plug your Pico into the Expansion Board, connect your distance sensor to the Expansion Board via the PiicoDev cable, and finally connect your Pico to your computer with a USB lead.

If you're unfamiliar with connecting PiicoDev modules, read the PiicoDev Connection Guide before proceeding.


Download MicroPython modules

We will need three files to easily read data from the Distance Sensor:

  • Download the PiicoDev Unified LibraryPiicoDev_Unified.py (right-click, "save link as").
  • Download the device module: PiicoDev_VL53L1X.py (right-click, "save link as")
  • Download the example script: main.py (right-click, "save link as")

It will be best to keep these files wherever you like to keep your coding projects eg. Documents > PiicoDev

Example Code

We'll be working in Thonny - if you're unfamiliar working with Thonny see our guide for Thonny and Raspberry Pi Pico.

Open Thonny, connect to your Pico and upload the three files (that we just downloaded) to your Pico. (Hint: View the files menu with View > Files)

Restart your Pico (Keyboard shortcut, Ctrl+D) and you should be seeing your Pico printing the distance it reads from the distance sensor.


Above: Distance data streams up the Shell, while the Plot shows historic distance data. I move my hand back and forth in front of the sensor to create the wave pattern in the plot.

If you have any questions or uncertainty, start the discussion below. We're full-time makers and here to help!

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.


Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.