A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/sparkfun/qwiic_vl53l1x_py below:

sparkfun/qwiic_vl53l1x_py: Python package for the qwiic VL53L1X distance sensor (4m)

SparkFun Qwiic VL53L1X - Python Package

The SparkFun Qwiic ToF Distance Sensor VL53L1X Module provides a simple and cost effective solution for adding ToF Distance Sensor capabilities to your project. Implementing a SparkFun Qwiic I2C interface, these sensors can be rapidly added to any project with boards that are part of the SparkFun Qwiic ecosystem.

This repository implements a Python package for the SparkFun Qwiic VL53L1X. This package works with Python, MicroPython and CircuitPython.

This python package enables the user to access the features of the VL53L1X via a single Qwiic cable. This includes reading distance, setting distance mode, seting intermeasurement period and more. The capabilities of the VL53L1X are each demonstrated in the included examples.

New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.

Supported SparkFun Products

This Python package supports the following SparkFun qwiic products on Python, MicroPython and Circuit python.

Note

The listed supported platforms and boards are the primary platform targets tested. It is fully expected that this package will work across a wide variety of Python enabled systems.

The first step to using this package is installing it on your system. The install method depends on the python platform. The following sections outline installation on Python, MicroPython and CircuitPython.

The package is primarily installed using the pip3 command, downloading the package from the Python Index - "PyPi".

Note - the below instructions outline installation on a Linux-based (Raspberry Pi) system.

First, setup a virtual environment from a specific directory using venv:

python3 -m venv path/to/venv

You can pass any path as path/to/venv, just make sure you use the same one for all future steps. For more information on venv click here.

Next, install the qwiic package with:

path/to/venv/bin/pip3 install sparkfun-qwiic-vl53l1x

Now you should be able to run any example or custom python scripts that have import qwiic_vl53l1x by running e.g.:

path/to/venv/bin/python3 example_script.py

If not already installed, follow the instructions here to install mpremote on your computer.

Connect a device with MicroPython installed to your computer and then install the package directly to your device with mpremote mip.

mpremote mip install github:sparkfun/qwiic_vl53l1x_py

If you would also like to install the examples for this repository, issue the following mip command as well:

mpremote mip install github:sparkfun/qwiic_vl53l1x_py@examples
CircuitPython Installation

If not already installed, follow the instructions here to install CircUp on your computer.

Ensure that you have the latest version of the SparkFun Qwiic CircuitPython bundle.

circup bundle-add sparkfun/Qwiic_Py

Finally, connect a device with CircuitPython installed to your computer and then install the package directly to your device with circup.

circup install --py qwiic_vl53l1x

If you would like to install any of the examples from this repository, issue the corresponding circup command from below. (NOTE: The below syntax assumes you are using CircUp on Windows. Linux and Mac will have different path seperators. See the CircUp "example" command documentation for more information)

circup example qwiic_vl53l1x\Example1_ReadDistance
circup example qwiic_vl53l1x\Example2_SetDistanceMode
circup example qwiic_vl53l1x\Example3_StatusandRate
circup example qwiic_vl53l1x\Example4_SetIntermeasurementPeriod

Below is a quickstart program to print readings from the VL53L1X.

See the examples directory for more detailed use examples and examples/README.md for a summary of the available examples.

	Reading distance from the laser based VL53L1X

	This example prints the distance to an object. If you are getting weird
	readings, be sure the vacuum tape has been removed from the sensor.

import qwiic_vl53l1x
import time

print("VL53L1X Qwiic Test\n")
ToF = qwiic_vl53l1x.QwiicVL53L1X()
if (ToF.sensor_init() == None):					 # Begin returns 0 on a good init
	print("Sensor online!\n")

while True:
	try:
		ToF.start_ranging()						 # Write configuration bytes to initiate measurement
		time.sleep(.005)
		distance = ToF.get_distance()	 # Get the result of the measurement from the sensor
		time.sleep(.005)
		ToF.stop_ranging()

		distanceInches = distance / 25.4
		distanceFeet = distanceInches / 12.0

		print("Distance(mm): %s Distance(ft): %s" % (distance, distanceFeet))

	except Exception as e:
		print(e)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4