adafruit_vcnl4200

CircuitPython driver for the Adafruit VCNL4200 Long Distance IR Proximity and Light Sensor

  • Author(s): Liz Clark, Tim Cocks

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_vcnl4200.Adafruit_VCNL4200(i2c: busio.I2C, addr: int = _I2C_ADDRESS)

Driver for VCNL4200 Proximity & Light Sensor

Parameters:
  • i2c – I2C bus

  • addr – I2C Address if not using default

property als_integration_time: str

ALS integration time setting. Configures the integration time for the ambient light sensor to control sensitivity and range.

Return str:

The ALS integration time setting

als_interrupt(enabled: bool, white_channel: bool) bool

Configure ALS interrupt settings, enabling or disabling the interrupt and selecting the interrupt channel.

Return bool:

True if setting the values succeeded, False otherwise.

property als_persistence: str

ALS persistence setting. Configures the persistence level of the ALS interrupt, which determines how many consecutive ALS threshold triggers are required to activate the interrupt.

Return str:

The current persistence setting

als_shutdown = 1

Enables or disables the ALS (Ambient Light Sensor) shutdown mode. Controls the power state of the ALS, allowing it to be shut down to conserve power. Set to true to enable shutdown mode (power off ALS), false to disable (power on ALS).

als_threshold_high = 1

The 16-bit numerical upper limit for proximity detection.If the proximity reading exceeds this threshold and the interrupt is enabled, an interrupt will be triggered.

als_threshold_low = 2

The 16-bit numerical low threshold for the ALS (Ambient Light Sensor) interrupt. If the ALS reading falls below this threshold and ALS interrupt is enabled, an interrupt will be triggered.

property interrupt_flags: Dict[str, bool]

The current interrupt flags from the sensor. Retrieves the current interrupt status flags, which indicate various sensor states, such as threshold crossings or sunlight protection events.

Return dict:

The current interrupt flag values

lux = 9

The current lux data from ambient light sensor (ALS)

prox_active_force = 4

The active force mode for the proximity sensor (PS). Configures the proximity sensor to operate in active force mode, where measurements are taken only when manually triggered by trigger_prox(). Set to True to enable active force mode, False to disable it.

prox_boost_typical_sunlight_capability = 4

The boosted sunlight protection capability for the proximity sensor (PS). Boosts the proximity sensor’s resistance to typical sunlight interference for more reliable proximity measurements in bright ambient conditions. Set to true to enable boosted sunlight protection, false to disable it.

prox_cancellation_level = 5

The 16-bit numerical proximity sensor (PS) cancellation level. Configures the cancellation level for the proximity sensor, which helps to reduce interference from background light by subtracting a baseline level.

property prox_duty: str

Proximity sensor duty cycle setting. Configures the duty cycle of the infrared emitter for the proximity sensor, which affects power consumption and response time.

Return str:

The duty cycle of the infrared emitter for the proximity sensor.

prox_hd = 3

The proximity sensor (PS) resolution to high definition (HD). Set to True to enable high definition mode (16-bit resolution), False for standard resolution (12-bit).

prox_int_threshold_high = 7

The 16-bit numerical high threshold for the proximity sensor (PS) interrupt. Configures the upper limit for proximity detection. If the proximity reading exceeds this threshold and the interrupt is enabled, an interrupt will be triggered.

prox_int_threshold_low = 6

The 16-bit numerical low threshold for the proximity sensor (PS) interrupt. Configures the lower limit for proximity detection. If the proximity reading falls below this threshold and the interrupt is enabled, an interrupt will be triggered.

property prox_integration_time: str

Proximity sensor integration time. Configures the integration time for the proximity sensor, which affects the duration for which the sensor is sensitive to reflected light.

Return str:

The current integration time

property prox_interrupt: str

Interrupt mode for the proximity sensor Configures the interrupt condition for the proximity sensor, which determines when an interrupt will be triggered based on the detected proximity.

Return str:

The interrupt mode for the proximity sensor.

prox_interrupt_logic_mode = 4

The interrupt logic mode for the proximity sensor (PS). Configures the interrupt output logic mode for the proximity sensor, determining if the interrupt signal is active high or active low. Set to True for active high logic, False for active low logic.

property prox_led_current: str

IR LED current setting. Configures the driving current for the infrared LED used in proximity detection, which affects the range and power consumption of the sensor.

Return str:

The LED current setting

property prox_multi_pulse: str

Configures the number of infrared pulses used by the proximity sensor in a single measurement. Increasing the pulse count can improve accuracy, especially in high ambient light conditions.

Return str:

The number of infrared pulses configured for the proximity sensor

property prox_persistence: str

Proximity sensor persistence setting. Configures the persistence level of the proximity sensor interrupt, defining how many consecutive threshold triggers are required to activate the interrupt.

Return str:

The current persistence setting

prox_shutdown = 3

The proximity sensor (PS) shutdown mode. Set to True to enable shutdown mode (power off proximity sensor), false to disable (power on proximity sensor).

prox_smart_persistence = 4

The smart persistence mode for the proximity sensor (PS). Configures the smart persistence feature, which helps reduce false triggers by adjusting the persistence behavior based on ambient conditions. Set to True to enable smart persistence, False to disable it.

prox_sun_cancellation = 4

The sunlight cancellation feature for the proximity sensor (PS). Controls the sunlight cancellation feature, which improves proximity detection accuracy in bright or sunny conditions by mitigating background light interference. Set to true to enable sunlight cancellation, false to disable it.

prox_sunlight_double_immunity = 4

Double immunity mode to sunlight for the proximity sensor (PS). Configures an enhanced sunlight immunity mode, which increases the sensor’s ability to filter out interference from bright sunlight for improved proximity detection. Set to True to enable double sunlight immunity, False to disable it.

proximity = 8

The current proximity data from the proximity sensor (PS).

sun_protect_polarity = 4

The polarity of the sunlight protection output for the proximity sensor (PS). Configures the polarity of the sunlight protection output signal, which affects how sunlight interference is managed in proximity detection. Set to True for active high polarity, False for active low polarity.

trigger_prox() bool

Triggers a single proximity measurement manually in active force mode. Initiates a one-time proximity measurement in active force mode. This can be used when proximity measurements are not continuous and need to be triggered individually.

Return bool:

True if triggering succeeded, False otherwise.

white_light = 10

The current white light data. The 16-bit numerical raw white light measurement, representing the sensor’s sensitivity to white light.