adafruit_vl53l0x
CircuitPython driver for the VL53L0X distance sensor. This code is adapted from the pololu driver here: https://github.com/pololu/vl53l0x-arduino
See usage in the examples/vl53l0x_simpletest.py file.
Author(s): Tony DiCola
Implementation Notes
Hardware:
Adafruit VL53L0X Time of Flight Distance Sensor - ~30 to 1000mm (Product ID: 3317)
Software and Dependencies:
Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_vl53l0x.VL53L0X(i2c: I2C, address: int = 41, io_timeout_s: float = 0)[source]
Driver for the VL53L0X distance sensor.
- property data_ready: bool
Check if data is available from the sensor. If true a call to .range will return quickly. If false, calls to .range will wait for the sensor’s next reading to be available.
- property distance: float
Perform a single reading of the range for an object in front of the sensor and return the distance in centimeters.
- do_range_measurement() None [source]
Perform a single reading of the range for an object in front of the sensor, but without return the distance.
- property range: int
Perform a single (or continuous if
start_continuous
called) reading of the range for an object in front of the sensor and return the distance in millimeters.
- read_range() int [source]
Return a range reading in millimeters. Note: Avoid calling this directly. If you do single mode, you need to call
do_range_measurement
first. Or your program will stuck or timeout occurred.
- set_address(new_address: int) None [source]
Set a new I2C address to the instantaited object. This is only called when using multiple VL53L0X sensors on the same I2C bus (SDA & SCL pins). See also the example for proper usage.
- Parameters:
new_address (int) – The 7-bit
int
that is to be assigned to the VL53L0X sensor. The address that is assigned should NOT be already in use by another device on the I2C bus.
Important
To properly set the address to an individual VL53L0X sensor, you must first ensure that all other VL53L0X sensors (using the default address of
0x29
) on the same I2C bus are in their off state by pulling the “SHDN” pins LOW. When the “SHDN” pin is pulled HIGH again the default I2C address is0x29
.