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:

  1. Initialize the VEML6035 sensor:sl_si91x_veml6035_init

  2. Enable or disable the sensor:sl_si91x_veml6035_enable_sensor

  3. Measure ambient light (ALS) in lux:sl_si91x_veml6035_get_als_lux

  4. Measure white light in lux:sl_si91x_veml6035_get_white_lux

  5. Configure sensitivity and gain:sl_si91x_veml6035_configure_sensitivity

  6. Set integration time:sl_si91x_veml6035_configure_integration_time

  7. Configure power save mode:sl_si91x_veml6035_configure_psm

  8. Configure and enable interrupts:sl_si91x_veml6035_configure_interrupt_mode, sl_si91x_veml6035_enable_interrupt_mode

  9. Read interrupt status:sl_si91x_veml6035_read_interrupt_status

  10. Reset the sensor configuration:sl_si91x_veml6035_reset

  • See the Function Documentation for detailed usage information of all APIs.

Functions#

SL_ENUM_GENERIC(sl_veml6035_integration_time_t, uint16_t)

Integration time settings.

SL_ENUM_GENERIC(sl_veml6035_psm_wait_t, uint16_t)

Wait time between measurements in power save mode.

SL_ENUM_GENERIC(sl_veml6035_als_pers_t, uint16_t)

Interrupt persistence settings.

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.

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.

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.

sl_status_t
sl_si91x_veml6035_enable_sensor(sl_i2c_instance_t i2c_instance, uint8_t addr, bool enable)

Enable or disable sensor measurements.

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.

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.

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.

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.

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.

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.

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.

Macros#

#define
VEML6035_ADDR VEML6035_SLAVE_ADDR

I2C device address for VEML6035.

#define
VEML6035_I2C_INSTANCE SL_VEML6035_CONFIG_I2C_INSTANCE

veml6035 I2C Instance

Function Documentation#

SL_ENUM_GENERIC#

SL_ENUM_GENERIC (sl_veml6035_integration_time_t , uint16_t )

Integration time settings.

Parameters
TypeDirectionArgument NameDescription
sl_veml6035_integration_time_tN/A
uint16_tN/A

SL_ENUM_GENERIC#

SL_ENUM_GENERIC (sl_veml6035_psm_wait_t , uint16_t )

Wait time between measurements in power save mode.

Parameters
TypeDirectionArgument NameDescription
sl_veml6035_psm_wait_tN/A
uint16_tN/A

SL_ENUM_GENERIC#

SL_ENUM_GENERIC (sl_veml6035_als_pers_t , uint16_t )

Interrupt persistence settings.

Parameters
TypeDirectionArgument NameDescription
sl_veml6035_als_pers_tN/A
uint16_tN/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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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