Datasheet
import board
import busio
import adafruit_vl6180x
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_vl6180x.VL6180X(i2c)
Now you're ready to read the range and other values from the sensor. You can do so with a few properties and
functions:
range Property - This property returns the range as read from the sensor in millimeters.
range_status Property - This property returns any error or issues that was encountered while reading the range.
You can compare against a few global values to see what might have occured. Check the datasheet for more
details about these error cases and how to resolve them:
adafruit_vl6180x.ERROR_NONE
adafruit_vl6180x.ERROR_SYSERR_1
adafruit_vl6180x.ERROR_SYSERR_5
adafruit_vl6180x.ERROR_ECEFAIL
adafruit_vl6180x.ERROR_NOCONVERGE
adafruit_vl6180x.ERROR_RANGEIGNORE
adafruit_vl6180x.ERROR_SNR
adafruit_vl6180x.ERROR_RAWUFLOW
adafruit_vl6180x.ERROR_RAWOFLOW
adafruit_vl6180x.ERROR_RANGEUFLOW
adafruit_vl6180x.ERROR_RANGEOFLOW
read_lux Function - This function can be called to read the light read from the sensor and return it in lux. In order
to call this function you must specify a gain that will be used during the reading. Check the datasheet for more
details on how gain impacts the reading and which value you might want to use for your application. You can
specify gain as one of these values:
adafruit_vl6180x.ALS_GAIN_1 - 1x gain
adafruit_vl6180x.ALS_GAIN_1_25 - 1.25x gain
adafruit_vl6180x.ALS_GAIN_1_67 - 1.67x gain
adafruit_vl6180x.ALS_GAIN_2_5 - 2.5x gain
adafruit_vl6180x.ALS_GAIN_5 - 5x gain
adafruit_vl6180x.ALS_GAIN_10 - 10x gain
adafruit_vl6180x.ALS_GAIN_20 - 20x gain
adafruit_vl6180x.ALS_GAIN_40 - 40x gain
print('Range: {0}mm'.format(sensor.range))
print('Range status: {0}'.format(sensor.range_status))
print('Light (1x gain): {0}lux'.format(sensor.read_lux(adafruit_vl6180x.ALS_GAIN_1)))
That's all there is to using the VL6180X distance sensor with CircuitPython!
© Adafruit Industries
https://learn.adafruit.com/adafruit-vl6180x-time-of-flight-micro-lidar-
distance-sensor-breakout
Page 21 of 27










