CircuitPython module for the VCNL4010 proximity and light sensor. See examples/ for an example of the usage.

  • Author(s): Tony DiCola

Implementation Notes


Software and Dependencies:

class adafruit_vcnl4010.VCNL4010(i2c, address=19)[source]

Vishay VCNL4010 proximity and ambient light sensor.

  • i2c (I2C) – The I2C bus the VCNL4010 is connected to
  • address (int) – (optional) The I2C address of the device. Defaults to 0x13

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 sensor

import board
import adafruit_vcnl4010

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()   # uses board.SCL and board.SDA
sensor = adafruit_vcnl4010.VCNL4010(i2c)

Now you have access to the sensor.proximity and ambient_lux attributes

proximity = sensor.proximity
ambient_lux = sensor.ambient_lux

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.


The detected ambient light in front of the sensor as a value in lux.


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.


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.


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.


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.