Skip to main content

CircuitPython driver for VL53L5CX and VL53L8CX ToF sensors

Project description

Introduction

Documentation Status Discord Build Status Code Style: Ruff

CircuitPython driver for VL53L5CX and VL53L8CX ToF sensors

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install circuitpython-vl53lxcx

To install system-wide (this may be required in some cases):

sudo pip3 install circuitpython-vl53lxcx

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .env/bin/activate
pip3 install circuitpython-vl53lxcx

Installing to a Connected CircuitPython Device with Circup

Make sure that you have circup installed in your Python environment. Install it with the following command if necessary:

pip3 install circup

With circup installed and your CircuitPython device connected use the following command to install:

circup install vl53lxcx

Or the following command to update an existing version:

circup update

Usage Example

from vl53lxcx import (
    DATA_DISTANCE_MM,
    DATA_TARGET_STATUS,
    RESOLUTION_8X8,
    STATUS_VALID,
    VL53L8CX,
)

i2c = busio.I2C(board.SCL, board.SDA, frequency=1_000_000)

lpn = DigitalInOut(board.D3)
lpn.direction = Direction.OUTPUT
lpn.value = True

tof = VL53L8CX(i2c, lpn=lpn)

def main():
    tof.reset()

    if not tof.is_alive():
        raise ValueError("VL53L8CX not detected")

    tof.init()

    tof.resolution = RESOLUTION_8X8
    grid = 7

    tof.ranging_freq = 2

    tof.start_ranging({DATA_DISTANCE_MM, DATA_TARGET_STATUS})

    while True:
        if tof.check_data_ready():
            results = tof.get_ranging_data()
            distance = results.distance_mm
            status = results.target_status

            # enumerate(distance) ...

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

circuitpython_vl53lxcx-0.0.2.tar.gz (243.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

circuitpython_vl53lxcx-0.0.2-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file circuitpython_vl53lxcx-0.0.2.tar.gz.

File metadata

  • Download URL: circuitpython_vl53lxcx-0.0.2.tar.gz
  • Upload date:
  • Size: 243.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for circuitpython_vl53lxcx-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9de7b1e4924bdc9ef3f45232feb141158e84e8aef3a199f66b1a1ca6e73e7e45
MD5 1dfb76dbd00cada63fff14f1629bb97e
BLAKE2b-256 ef160b6e973749db99e755b29035d92e65bd15792778e3024155c6d72848ea66

See more details on using hashes here.

File details

Details for the file circuitpython_vl53lxcx-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for circuitpython_vl53lxcx-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f236581ecca4243773d9af6710ca68881e0e0a2e87388d479a3b230abfa2fb1e
MD5 919a15be835baaed0c5a516e0ca059af
BLAKE2b-256 423b2c4c1b0773c2ee28a1189162b2155e002d17c351c58b5201fb224c71ce52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page