PiicoDev Distance Sensor VL53L1X - Raspberry Pi Guide

Michael just shared a new tutorial: “PiicoDev Distance Sensor VL53L1X - Raspberry Pi Guide”

This guide will help you read distance data from your PiicoDev® Distance Sensor and a Raspberry Pi single-board computer!

Read more


Hello. If I am using a headless RPi, can I just run pip install piicodev to install the Python package, and then run the Python script shown in that guide, rather than firing up a GUI and then running Thonny?

(I’d test this myself but I haven’t bought the parts yet to test with…)

Thanks in advance.


I recommend installing with pip3 install piicodev and then running your script with python3


Great, thanks. I’ll place an order shortly. :slight_smile:

I recently bought a house and the kitchen cupboard has a roller door sort of thing on it (sounds weird, but actually looks kinda cool). There’s a power point inside for e.g. toaster etc. It gets a bit dark in there so I’ve already got a small LED light mounted in there, but the problem is the light switch is high up and hard to reach. I plan to use this sensor and a Raspberry Pi, which will be mounted at the back of the cupboard, to detect the distance to the roller door. If it exceeds a certain value, the door will be considered open. In which case, it will then use hueadm to control a Philips Hue Smart Plug to turn on/off the light, depending on whether or not the roller door is open or closed.


This sounds like a great project :smiley: We’d love for you to share your progress at any step in the process on our projects module.


Following the steps of the tutorial, after installation there was no PiicoDev folder created and a quick search showed no main.py associated with piicodev. I uninstalled and reinstalled piicodev and tried again. Seems I’m missing a step, please help

1 Like

Hi @Tom111921 , copying my reply in the other thread:

Hi Tom,
You can download the example code right away here: main.py - right-click and save link as.
That’s pretty strange. It seems like some content has gone missing from the tutorial - you can see in the video that we save a file from a link… In any case, I’ve fixed the article and the update should appear soon.


Thanks a lot for the quick response, all good now. I do have another question regarding ranging. I’m getting great accuracy below 3 metres, but it’s pretty wild beyond that. The VL53L1X sensor has 3 modes, 1-short, 2-medium and 3-long. Any advice how I can check the mode?

@Michael - another great product from you guys.

Btw, just to let you know, i tested my VL53L1X sensor using your library and also the Pimoroni library and yours provide a lot more accurate readings.

The reason I tried their library is because they have a number of good examples, that was the whole reason. Could you please point me to an advanced usage example with Piicodev library please?

In my setup I am looking to use 2x VL53L1X sensors - both on seperate bus (I2C0 and I2C1). Hopefully different bus means no conflict. I am after an example that helps me define bus for each of the sensors and thus isolating their outputs.

1 Like

Ok i figured it out. on your github repo it shows how to declare bus. in case anyone else is looking for it.

tof1 = PiicoDev_VL53L1X(bus=0)
tof2 = PiicoDev_VL53L1X(bus=1)


Hey Riddhi,

Thanks for letting us know, I am sure that will be helpful for anyone else looking for configuration of these boards.


1 Like