API Reference
adafruit_vcnl4030
CircuitPython driver library for VCNL4030X01 Proximity / Ambient Light sensor
Author(s): Tim Cocks
Implementation Notes
Hardware:
Adafruit VCNL4030X01 Proximity and Ambient Light Sensor Breakout
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 # * Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- class adafruit_vcnl4030.ALSIntegrationTime
ALS integration time settings for ALS_IT bits [7:5] of ALS_CONF.
Longer integration times give higher resolution (lower lux/step).
Setting
Time
Resolution
ALSIntegrationTime.MS_5050 ms
0.064 lux/step
ALSIntegrationTime.MS_100100 ms
0.032 lux/step
ALSIntegrationTime.MS_200200 ms
0.016 lux/step
ALSIntegrationTime.MS_400400 ms
0.008 lux/step
ALSIntegrationTime.MS_800800 ms
0.004 lux/step
- class adafruit_vcnl4030.ALSPersistence
ALS interrupt persistence settings for ALS_PERS bits [3:2] of ALS_CONF.
Number of consecutive out-of-threshold readings before an interrupt fires.
Setting
Readings
ALSPersistence.CYCLES_11 reading
ALSPersistence.CYCLES_22 readings
ALSPersistence.CYCLES_44 readings
ALSPersistence.CYCLES_88 readings
- class adafruit_vcnl4030.CV
Constant-value helper for enum-like classes.
- class adafruit_vcnl4030.ProxDuty
PS IRED duty ratio settings for PS_DUTY bits [7:6] of PS_CONF1.
Higher duty divisor = lower average LED power.
Setting
Duty cycle
ProxDuty.RATIO_401/40 (highest power)
ProxDuty.RATIO_801/80
ProxDuty.RATIO_1601/160
ProxDuty.RATIO_3201/320 (lowest power)
- class adafruit_vcnl4030.ProxGain
PS gain settings for PS_GAIN bits [13:12] of PS_CONF2.
Setting
Description
ProxGain.TWO_STEPTwo-step mode (~4x single 1x)
ProxGain.SINGLE_8XSingle mode, 8x range
ProxGain.SINGLE_1XSingle mode, 1x range
- class adafruit_vcnl4030.ProxIntegrationTime
PS integration time settings for PS_IT bits [3:1] of PS_CONF1.
Higher T values give higher sensitivity.
Setting
Period
ProxIntegrationTime.T_11T
ProxIntegrationTime.T_1_51.5T
ProxIntegrationTime.T_22T
ProxIntegrationTime.T_2_52.5T
ProxIntegrationTime.T_33T
ProxIntegrationTime.T_3_53.5T
ProxIntegrationTime.T_44T
ProxIntegrationTime.T_88T (highest sensitivity)
- class adafruit_vcnl4030.ProxInterruptMode
PS interrupt mode settings for PS_INT bits [9:8] of PS_CONF2.
Setting
Description
ProxInterruptMode.DISABLEDInterrupt disabled
ProxInterruptMode.CLOSEInterrupt on close
ProxInterruptMode.AWAYInterrupt on away
ProxInterruptMode.BOTHInterrupt on close and away
- class adafruit_vcnl4030.ProxLEDCurrent
LED driving current settings for LED_I bits [10:8] of PS_MS.
Setting
Current
ProxLEDCurrent.MA_5050 mA
ProxLEDCurrent.MA_7575 mA
ProxLEDCurrent.MA_100100 mA
ProxLEDCurrent.MA_120120 mA
ProxLEDCurrent.MA_140140 mA
ProxLEDCurrent.MA_160160 mA
ProxLEDCurrent.MA_180180 mA
ProxLEDCurrent.MA_200200 mA
- class adafruit_vcnl4030.ProxPersistence
PS interrupt persistence settings for PS_PERS bits [5:4] of PS_CONF1.
Setting
Readings
ProxPersistence.CYCLES_11 reading
ProxPersistence.CYCLES_22 readings
ProxPersistence.CYCLES_33 readings
ProxPersistence.CYCLES_44 readings
- class adafruit_vcnl4030.SunlightCancelCurrent
Sunlight cancellation current multiplier for PS_SC_CUR bits [14:13] of PS_MS.
Setting
Multiplier
SunlightCancelCurrent.X11x typical
SunlightCancelCurrent.X22x typical
SunlightCancelCurrent.X44x typical
SunlightCancelCurrent.X88x typical
- class adafruit_vcnl4030.VCNL4030(i2c_bus: I2C, address: int = _VCNL4030_DEFAULT_ADDR)
CircuitPython driver for the Vishay VCNL4030X01 proximity and ambient light sensor.
- Parameters:
- als_high_dynamic_range
Enable ALS high dynamic range mode (2x range, halves sensitivity). True to enable.
- property als_high_flag: bool
True if the ALS high-threshold flag was set in the last
interrupt_flagsread.
- property als_integration_time: int
ALS integration time.
Must be an
ALSIntegrationTimevalue, e.g.ALSIntegrationTime.MS_100.
- als_interrupt_enabled
Enable or disable the ALS interrupt. True to enable.
- property als_low_flag: bool
True if the ALS low-threshold flag was set in the last
interrupt_flagsread.
- als_low_sensitivity
Enable ALS low sensitivity mode (1x vs 2x). True for lower sensitivity.
- property als_persistence: int
ALS interrupt persistence.
Must be an
ALSPersistencevalue, e.g.ALSPersistence.CYCLES_1.
- als_threshold_high
ALS interrupt high threshold (16-bit).
- als_threshold_low
ALS interrupt low threshold (16-bit).
- property interrupt_flags: int
Read and return the interrupt flags byte.
Reading this register clears all flags on the device. Use the returned byte with the
VCNL4030_ALS_IF_H,VCNL4030_ALS_IF_L,VCNL4030_PROX_IF_CLOSE,VCNL4030_PROX_IF_AWAY, andVCNL4030_PROX_SPFLAGbitmask constants, or check the individual flag properties.
- property led_current: int
LED driving current.
Must be a
ProxLEDCurrentvalue, e.g.ProxLEDCurrent.MA_200.
- led_low_current
Reduce LED current to 1/10 of normal. True to enable.
- property lux: float
Ambient light in lux, computed from the raw ALS reading.
Resolution is determined by the current
als_integration_time,als_high_dynamic_range, andals_low_sensitivitysettings.
- property proximity: int
Raw PS reading (12-bit or 16-bit depending on
proximity_resolution_16bit).
- proximity_active_force_mode
Enable PS active force mode (manual trigger). True to enable.
- property proximity_away_flag: bool
True if the PS away (receding) flag was set in the last
interrupt_flagsread.
- proximity_cancellation
PS crosstalk cancellation level (subtracted from raw PS reading).
- property proximity_close_flag: bool
True if the PS close (approaching) flag was set in the last
interrupt_flagsread.
- property proximity_integration_time: int
PS integration time.
Must be a
ProxIntegrationTimevalue, e.g.ProxIntegrationTime.T_1.
- property proximity_interrupt_mode: int
PS interrupt mode.
Must be a
ProxInterruptModevalue, e.g.ProxInterruptMode.DISABLED.
- proximity_logic_mode
Enable PS logic output mode. True for logic output, False for normal+interrupt.
- proximity_low_sensitivity
Enable PS low sensitivity mode. True for lower sensitivity.
- property proximity_persistence: int
PS interrupt persistence.
Must be a
ProxPersistencevalue, e.g.ProxPersistence.CYCLES_1.
- proximity_resolution_16bit
Enable 16-bit PS output resolution (False = 12-bit). True for 16-bit.
- proximity_smart_persistence
Enable PS smart persistence. True to enable.
- property proximity_sunlight_flag: bool
True if the PS sunlight protection flag was set in the last
interrupt_flagsread.
- proximity_threshold_high
PS interrupt high threshold (16-bit).
- proximity_threshold_low
PS interrupt low threshold (16-bit).
- reset()
Reset the sensor back to its initial configuration state.
- property sunlight_cancel_current: int
Sunlight cancellation current multiplier.
Must be a
SunlightCancelCurrentvalue, e.g.SunlightCancelCurrent.X1.
- sunlight_cancellation_enabled
Enable sunlight cancellation feature. True to enable.
- sunlight_protect_output_high
Sunlight protect output level. True for 0xFF output, False for 0x00.
- sunlight_protection_enhanced
Enable enhanced sunlight protection (1.5x capability). True to enable.
- trigger_proximity() None
Trigger a single PS measurement in active force mode.
Has no effect unless
proximity_active_force_modeis True. The PS_TRIG bit is self-clearing.