VEML6035 Ambient Light Sensor#
Introduction#
The VEML6035 driver provides a set of functions for interacting with the VEML6035 ambient light sensor over the I2C bus. It enables integration of the sensor by providing access to features such as ambient light and white light measurements, configuration of sensitivity, integration time, power save mode, and interrupt handling.
Usage#
Once the I2C peripheral is initialized and configured, the VEML6035 sensor will be ready for use. The common functions include the following:
Initialize the VEML6035 sensor:sl_si91x_veml6035_init
Enable or disable the sensor:sl_si91x_veml6035_enable_sensor
Measure ambient light (ALS) in lux:sl_si91x_veml6035_get_als_lux
Measure white light in lux:sl_si91x_veml6035_get_white_lux
Configure sensitivity and gain:sl_si91x_veml6035_configure_sensitivity
Set integration time:sl_si91x_veml6035_configure_integration_time
Configure power save mode:sl_si91x_veml6035_configure_psm
Configure and enable interrupts:sl_si91x_veml6035_configure_interrupt_mode, sl_si91x_veml6035_enable_interrupt_mode
Read interrupt status:sl_si91x_veml6035_read_interrupt_status
Reset the sensor configuration:sl_si91x_veml6035_reset
The following sequence should be followed when using the VEML6035 sensor:
Initialize the VEML6035 sensor: Use sl_si91x_veml6035_init before using the other functions.
Enable or disable the sensor as needed: Use sl_si91x_veml6035_enable_sensor.
Configure sensitivity, integration time, or power save mode as required.
Measure ambient or white light: Use sl_si91x_veml6035_get_als_lux or sl_si91x_veml6035_get_white_lux.
Configure and handle interrupts if threshold-based events are needed.
*Reset the sensor if necessary using sl_si91x_veml6035_reset.*
See the Function Documentation for detailed usage information of all APIs.
Functions#
Integration time settings.
Wait time between measurements in power save mode.
Interrupt persistence settings.
Initialize and enable the VEML6035 sensor to operate in normal mode.
Retrieve the sample counts from the ALS channel and calculate the lux value.
Retrieve the sample counts from the WHITE channel and calculate the lux vaule.
Enable or disable sensor measurements.
Reset sensor configuration to the same state as after a power on reset.
Configure sensor sensitivity settings.
Set integration time.
Enable power save mode, with a defined wait time between measurements.
Configure interrupt mode.
Enable or disable threshold interrupts.
Read threshold interrupt status register and return interrupt status for high and low threshold.
Macros#
I2C device address for VEML6035.
veml6035 I2C Instance
Function Documentation#
SL_ENUM_GENERIC#
SL_ENUM_GENERIC (sl_veml6035_integration_time_t , uint16_t )
Integration time settings.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_veml6035_integration_time_t | N/A | ||
uint16_t | N/A |
SL_ENUM_GENERIC#
SL_ENUM_GENERIC (sl_veml6035_psm_wait_t , uint16_t )
Wait time between measurements in power save mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_veml6035_psm_wait_t | N/A | ||
uint16_t | N/A |
SL_ENUM_GENERIC#
SL_ENUM_GENERIC (sl_veml6035_als_pers_t , uint16_t )
Interrupt persistence settings.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_veml6035_als_pers_t | N/A | ||
uint16_t | N/A |
sl_si91x_veml6035_init#
sl_status_t sl_si91x_veml6035_init (sl_i2c_instance_t i2c_instance, uint8_t addr, bool white_enable)
Initialize and enable the VEML6035 sensor to operate in normal mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
bool | [in] | white_enable | Set to true to enable WHITE channel sensor readings in addition to the ALS channel. |
Note
This function configures the sensor to a default integration time of 100 ms and the lowest possible sensitivity configuration in order to achieve maximum illumination range. If the lux count is too low, consider configuring sensitivity settings.
sl_si91x_veml6035_get_als_lux#
sl_status_t sl_si91x_veml6035_get_als_lux (sl_i2c_instance_t i2c_instance, uint8_t addr, float * lux)
Retrieve the sample counts from the ALS channel and calculate the lux value.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
float * | [out] | lux | The measured ambient light illuminance in lux. |
sl_si91x_veml6035_get_white_lux#
sl_status_t sl_si91x_veml6035_get_white_lux (sl_i2c_instance_t i2c_instance, uint8_t addr, float * lux)
Retrieve the sample counts from the WHITE channel and calculate the lux vaule.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
float * | [out] | lux | The measured white light illuminance in lux. |
sl_si91x_veml6035_enable_sensor#
sl_status_t sl_si91x_veml6035_enable_sensor (sl_i2c_instance_t i2c_instance, uint8_t addr, bool enable)
Enable or disable sensor measurements.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
bool | [in] | enable | Set to true to enable sensor, set to false to disable sensor. |
Note
Disabling the sensor does not make sensor lose its configuration and last measurement values.
sl_si91x_veml6035_reset#
sl_status_t sl_si91x_veml6035_reset (sl_i2c_instance_t i2c_instance, uint8_t addr)
Reset sensor configuration to the same state as after a power on reset.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
Note
This function does not clear data output registers, or interrupt status register.
sl_si91x_veml6035_configure_sensitivity#
sl_status_t sl_si91x_veml6035_configure_sensitivity (sl_i2c_instance_t i2c_instance, uint8_t addr, bool low_sensitivity, uint8_t gain)
Configure sensor sensitivity settings.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
bool | [in] | low_sensitivity | Set to true for low sensitivity (1/8th of normal), false for normal sensitivity. |
uint8_t | [in] | gain | Sensitivity gain, possible values: 1, 2, 4 |
Note
A low sensitivity results in a larger light sensing range, while a high sensitivity yields a higher resolution at low illumination levels.
sl_si91x_veml6035_configure_integration_time#
sl_status_t sl_si91x_veml6035_configure_integration_time (sl_i2c_instance_t i2c_instance, uint8_t addr, sl_veml6035_integration_time_t integration_time)
Set integration time.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
sl_veml6035_integration_time_t | [in] | integration_time | Integration time |
Note
The default integration time is 100ms. This can be increased to achieve a higher resolution, or decreased to achieve a faster measurement rate.
sl_si91x_veml6035_configure_psm#
sl_status_t sl_si91x_veml6035_configure_psm (sl_i2c_instance_t i2c_instance, uint8_t addr, sl_veml6035_psm_wait_t psm_wait, bool enable)
Enable power save mode, with a defined wait time between measurements.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
sl_veml6035_psm_wait_t | [in] | psm_wait | The desired interval between measurements |
bool | [in] | enable | Set to true to enable power save mode, false to disable power save mode. |
sl_si91x_veml6035_configure_interrupt_mode#
sl_status_t sl_si91x_veml6035_configure_interrupt_mode (sl_i2c_instance_t i2c_instance, uint8_t addr, uint16_t high_threshold, uint16_t low_threshold, sl_veml6035_als_pers_t persistence, bool white_enable, bool enable)
Configure interrupt mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
uint16_t | [in] | high_threshold | Threshold for interrupt to trigger when lux value above |
uint16_t | [in] | low_threshold | Interrupt should trigger when lux count below this value |
sl_veml6035_als_pers_t | [in] | persistence | How many sensor reads out of threshold window before interrupt triggers |
bool | [in] | white_enable | Selection for which channel the interrupt should trigger. True for WHITE channel, false for ALS channel. |
bool | [in] | enable | Set to true to enable interrupts, false to disable interrupts |
sl_si91x_veml6035_enable_interrupt_mode#
sl_status_t sl_si91x_veml6035_enable_interrupt_mode (sl_i2c_instance_t i2c_instance, uint8_t addr, bool enable)
Enable or disable threshold interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use. |
uint8_t | [in] | addr | I2C address of the sensor. |
bool | [in] | enable | Set to true to enable interrupt mode, false to disable interrupt mode |
sl_si91x_veml6035_read_interrupt_status#
sl_status_t sl_si91x_veml6035_read_interrupt_status (sl_i2c_instance_t i2c_instance, uint8_t addr, bool * threshold_low, bool * threshold_high)
Read threshold interrupt status register and return interrupt status for high and low threshold.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2c_instance_t | [in] | i2c_instance | The I2C peripheral to use |
uint8_t | [in] | addr | I2C address of the sensor. |
bool * | [out] | threshold_low | True if crossing low threshold interrupt was triggered |
bool * | [out] | threshold_high | True if crossing high threshold interrupt was triggered |