PiicoDev Distance Sensor VL53L1X – Raspberry Pi Guide — Transcript

Learn to use the PiicoDev VL53L1X distance sensor with Raspberry Pi, including wiring, software setup, and reading distance data.

Key Takeaways

  • Proper hardware setup and I2C configuration are essential for sensor functionality.
  • PiicoDev packages must be installed and up to date to run the example code.
  • Distance readings can be visualized in real-time using the plotter feature in Thonny.
  • Simple Python code can be customized to respond to different distance thresholds.
  • The tutorial is beginner-friendly but assumes basic familiarity with Raspberry Pi desktop usage.

Summary

  • Introduction to using the PiicoDev VL53L1X distance sensor with a Raspberry Pi.
  • Required hardware includes Raspberry Pi, PiicoDev adapter, distance sensor, and cable.
  • Instructions on physically connecting the sensor to the Raspberry Pi via the adapter and cable.
  • Enabling the I2C interface on the Raspberry Pi for sensor communication.
  • Downloading example code from the tutorial page and saving it locally.
  • Opening and running the example script in Thonny IDE after installing necessary PiicoDev packages.
  • Streaming live distance data and visualizing it using the plotter tool.
  • Explanation of the example code structure, including importing packages, reading sensor data, and adding delays.
  • Modifying the code to display messages based on distance thresholds (e.g., close or far).
  • Encouragement to seek help on the Core Electronics forums and additional beginner resources.

Full Transcript — Download SRT & Markdown

00:00
Speaker A
G'day. I'm going to show you how to get started reading distance using your PicoDev distance sensor and a Raspberry Pi. We'll wire these two together, download the necessary packages, and start taking some readings. Let's get started.
00:18
Speaker A
pi set up to run like a desktop computer a pico dev adapter for raspberry pi of course the picf distance sensor and a picket of cable i recommend cables 100 millimeters or longer for raspberry pi projects it's best if you're already
00:32
Speaker A
To follow along, you'll need a Raspberry Pi set up to run like a desktop computer, a PicoDev adapter for Raspberry Pi, of course, the PicoDev distance sensor, and a PicoDev cable. I recommend cables 100 millimeters or longer.
00:45
Speaker A
you're using a raspberry pi 3. connect one end of your picodev cable into one of the ports of the adapter and connect the other end to your distance sensor and i've just mounted all my hardware onto a pkdf platform for raspberry pi just to
00:58
Speaker A
For Raspberry Pi projects, it's best if you're already comfortable using a Raspberry Pi like a desktop computer. If you need help with that, check out the Raspberry Pi for Beginners workshop.
01:18
Speaker A
example download link next right click the link and save link as and i'll save this into a folder that i have in my home directory called picodev and i'll name this file distance just for some context when that's
01:35
Speaker A
Connect the adapter to your Raspberry Pi, making sure the arrow is pointing towards the Ethernet socket or a USB socket if you're using a Raspberry Pi 3. Connect one end of your PicoDev cable into one of the ports of the adapter and connect the other end to your distance sensor. I've just mounted all my hardware onto a PKDF platform for Raspberry Pi just to keep everything stable for this tutorial.
01:52
Speaker A
and just click install or upgrade if you need to to go to the latest version and this example is ready to run just hit the green run current script button and you should see distance data being streamed into the
02:05
Speaker A
Make sure you have the I squared C interface enabled on your Raspberry Pi. Go to the Pi menu, Preferences, Raspberry Pi Configuration. Under the Interfaces tab, make sure you have I2C enabled.
02:20
Speaker A
don't see it open the view plotter option let's take a quick tour of the example code we have the first line which just imports the package that will help us drive the sensor we also import a function to create a delay so that we
02:35
Speaker A
Navigate to the tutorial page, find the example download link. Next, right-click the link and Save Link As. I'll save this into a folder that I have in my home directory called PicoDev, and I'll name this file Distance.
02:49
Speaker A
there's an infinite loop the while true and then we call our distance sensor with dot read to read the distance in millimeters this gets saved or assigned to a variable called dist next up we call print to show the data
03:04
Speaker A
Just for some context, when that's finished downloading, you can find that wherever you saved it. Double-click to open in Thonny. Let's make sure we have the PicoDev packages installed. Go to Tools, Manage Packages, and search for PicoDev with two eyes. There's the package.
03:19
Speaker A
this number with a space and millimeters showing in the shell finally there's just a 0.1 second sleep before the next loop let's remix this code so that it gives us some kind of message depending on how close something might
03:33
Speaker A
Just click Install or Upgrade if you need to go to the latest version. This example is ready to run. Just hit the green Run Current Script button, and you should see distance data being streamed into the shell.
04:01
Speaker A
150 millimeters we can say pretty close l if dist is less than let's go with 500 and we can print close and then finally if none of those conditions are met we can say else print far okay and i'm just going to remove this
04:34
Speaker A
If I move my hand, that distance data will change. I've got my plotter open to the right here, so you can also see that wave that I'm creating by moving my hand up and down. If you'd like to see the plotter and you don't see it, open the View Plotter option.
04:50
Speaker A
closer and closer where we're now at the closed threshold and now we're pretty close and we're really close and we can step back through and so by creating this simple if-else chain we've set up different thresholds that we can create
05:08
Speaker A
Let's take a quick tour of the example code. We have the first line, which just imports the package that will help us drive the sensor. We also import a function to create a delay so that we can pause the script for some amount of time.
05:21
Speaker A
on the core electronics forums where full-time makers and here to help until next time catch you later
Topics:PiicoDevVL53L1Xdistance sensorRaspberry PiI2CThonnyPythonsensor tutorialCore Electronicshardware setup

Frequently Asked Questions

What hardware do I need to use the PiicoDev VL53L1X distance sensor with a Raspberry Pi?

You need a Raspberry Pi set up as a desktop computer, a PiicoDev adapter for Raspberry Pi, the PiicoDev VL53L1X distance sensor, and a PiicoDev cable, preferably 100 millimeters or longer.

How do I enable communication between the Raspberry Pi and the distance sensor?

You must enable the I2C interface on your Raspberry Pi by going to the Pi menu, selecting Preferences, then Raspberry Pi Configuration, and enabling I2C under the Interfaces tab.

How can I visualize the distance data readings from the sensor?

After running the example script in Thonny, you can open the View Plotter option to see live graphical data of the distance readings as you move an object in front of the sensor.

Get More with the Söz AI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries, speaker detection, and unlimited transcriptions.

Or transcribe another YouTube video here →