Skip to main content

vl53l1x distance sensor driver for Raspberry Pi

Project description

# vl53l1x-python

Revised Python library for the VL53L1X Laser Ranger.

# Installing

```
sudo pip3 install smbus2
sudo pip3 install VL53L1X2
```

# Usage

```python
import VL53L1X

tof = VL53L1X.VL53L1X(i2c_bus=1, i2c_address=0x29)
tof.open() # Initialise the i2c bus and configure the sensor
tof.start_ranging(1) # Start ranging, 1 = Short Range, 2 = Medium Range, 3 = Long Range
distance_in_mm = tof.get_distance() # Grab the range in mm
tof.stop_ranging() # Stop ranging
```

See examples and tests for more advanced usage.


0.1.2
-----

* @josemotta ported it to python 3.6 as part of a homeassistant component.

Please see basic sample:

from homeassistant.const import TEMP_CELSIUS
from homeassistant.helpers.entity import Entity

REQUIREMENTS = ['smbus2==0.2.2', 'VL53L1X2==0.1.2']

def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the sensor platform."""
add_devices([TofSensor()])


class TofSensor(Entity):
"""Representation of a Sensor."""

def __init__(self):
"""Initialize the sensor."""
self._state = None

@property
def name(self):
"""Return the name of the sensor."""
return 'VL53L1X'

@property
def state(self):
"""Return the state of the sensor."""
return self._state

@property
def unit_of_measurement(self):
"""Return the unit of measurement."""
return TEMP_CELSIUS

def update(self):
"""Fetch new state data for the sensor.

This is the only method that should fetch new data for Home Assistant.
"""
self._state = 23

0.0.3
-----

* @NagyAttila upgrade focusing on working with more than 1 range sensors, also changed quit a lot to make it bit more robust.

0.0.2
-----

* Improved search for .so file to pick up arch-specific files.

0.0.1
-----

* Initial release.


Project details


Download files

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

Files for VL53L1X2, version 0.1.5
Filename, size File type Python version Upload date Hashes
Filename, size VL53L1X2-0.1.5-cp35-cp35m-linux_armv6l.whl (131.3 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size VL53L1X2-0.1.5-cp35-cp35m-linux_armv7l.whl (131.3 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size VL53L1X2-0.1.5-cp36-cp36m-linux_armv6l.whl (118.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size VL53L1X2-0.1.5-cp36-cp36m-linux_armv7l.whl (120.0 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size VL53L1X2-0.1.5-cp37-cp37m-linux_armv6l.whl (118.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size VL53L1X2-0.1.5-cp37-cp37m-linux_armv7l.whl (118.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size VL53L1X2-0.1.5.tar.gz (80.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page