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


Release history Release notifications

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
VL53L1X2-0.1.5-cp35-cp35m-linux_armv6l.whl (131.3 kB) Copy SHA256 hash SHA256 Wheel cp35
VL53L1X2-0.1.5-cp35-cp35m-linux_armv7l.whl (131.3 kB) Copy SHA256 hash SHA256 Wheel cp35
VL53L1X2-0.1.5-cp36-cp36m-linux_armv6l.whl (118.1 kB) Copy SHA256 hash SHA256 Wheel cp36
VL53L1X2-0.1.5-cp36-cp36m-linux_armv7l.whl (120.0 kB) Copy SHA256 hash SHA256 Wheel cp36
VL53L1X2-0.1.5-cp37-cp37m-linux_armv6l.whl (118.1 kB) Copy SHA256 hash SHA256 Wheel cp37
VL53L1X2-0.1.5-cp37-cp37m-linux_armv7l.whl (118.1 kB) Copy SHA256 hash SHA256 Wheel cp37
VL53L1X2-0.1.5.tar.gz (80.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page