adafruit_vcnl4010
¶
CircuitPython module for the VCNL4010 proximity and light sensor. See examples/vcnl4010_simpletest.py for an example of the usage.
Author(s): Tony DiCola
Implementation Notes¶
Hardware:
Adafruit VCNL4010 Proximity/Light sensor breakout (Product ID: 466)
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_vcnl4010.VCNL4010(i2c, address=19)[source]¶
Vishay VCNL4010 proximity and ambient light sensor.
- Parameters
Quickstart: Importing and using the VCNL4010
Here is an example of using the
VCNL4010
class. First you will need to import the libraries to use the sensorimport board import adafruit_vcnl4010
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA sensor = adafruit_vcnl4010.VCNL4010(i2c)
Now you have access to the
sensor.proximity
andambient_lux
attributesproximity = sensor.proximity ambient_lux = sensor.ambient_lux
- property ambient¶
The detected ambient light in front of the sensor. This is a unit-less unsigned 16-bit value (0-65535) with higher values for more detected light. See the
ambient_lux property
for a value in lux.
- property ambient_lux¶
The detected ambient light in front of the sensor as a value in lux.
- property frequency¶
The frequency of proximity measurements. Must be a value of:
FREQUENCY_3M125: 3.125 Mhz
FREQUENCY_1M5625: 1.5625 Mhz
FREQUENCY_781K25: 781.25 Khz
FREQUENCY_390K625: 390.625 Khz (default)
See the datasheet for how frequency changes the proximity detection accuracy.
- property led_current¶
The current of the LED. The value is in units of 10mA and can only be set to 0 (0mA/off) to 20 (200mA). See the datasheet for how LED current impacts proximity measurements. The default is 200mA.
- property led_current_mA¶
The current of the LED in milli-amps. The value here is specified in a milliamps from 0-200. Note that this value will be quantized down to a smaller less-accurate value as the chip only supports current changes in 10mA increments, i.e. a value of 123 mA will actually use 120 mA. See the datasheet for how the LED current impacts proximity measurements, and the led_current property to explicitly set values without quantization or unit conversion.
- property proximity¶
The detected proximity of an object in front of the sensor. This is a unit-less unsigned 16-bit value (0-65535) INVERSELY proportional to the distance of an object in front of the sensor (up to a max of ~200mm). For example a value of 10 is an object farther away than a value of 1000. Note there is no conversion from this value to absolute distance possible, you can only make relative comparisons.