VEML6035 - Ambient Light Sensor#

Driver for the Vishay VEML6025 ambient light sensor.

Enumerations#

enum
veml6035_integration_time_800_ms = SL_VEML6035_ALS_IT_800MS
veml6035_integration_time_400_ms = SL_VEML6035_ALS_IT_400MS
veml6035_integration_time_200_ms = SL_VEML6035_ALS_IT_200MS
veml6035_integration_time_100_ms = SL_VEML6035_ALS_IT_100MS
veml6035_integration_time_50_ms = SL_VEML6035_ALS_IT_50MS
veml6035_integration_time_25_ms = SL_VEML6035_ALS_IT_25MS
}

Integration time settings.

enum
veml6035_psm_wait_3200_ms = SL_VEML6035_PSM_WAIT_3200_MS
veml6035_psm_wait_1600_ms = SL_VEML6035_PSM_WAIT_1600_MS
veml6035_psm_wait_800_ms = SL_VEML6035_PSM_WAIT_800_MS
veml6035_psm_wait_400_ms = SL_VEML6035_PSM_WAIT_400_MS
}

Wait time between measurements in power save mode.

enum
veml6035_als_pers_1 = SL_VEML6035_ALS_PERS_1
veml6035_als_pers_2 = SL_VEML6035_ALS_PERS_2
veml6035_als_pers_4 = SL_VEML6035_ALS_PERS_4
veml6035_als_pers_8 = SL_VEML6035_ALS_PERS_8
}

Interrupt persistence settings.

Functions#

sl_status_t
sl_veml6035_init(sl_i2cspm_t *i2cspm, bool white_enable)

Initialize and enable the VEML6035 sensor to operate in normal mode.

sl_status_t
sl_veml6035_get_als_lux(sl_i2cspm_t *i2cspm, float *lux)

Retrieve the sample counts from the ALS channel and calculate the lux value.

sl_status_t
sl_veml6035_get_white_lux(sl_i2cspm_t *i2cspm, float *lux)

Retrieve the sample counts from the WHITE channel and calculate the lux vaule.

sl_status_t
sl_veml6035_enable_sensor(sl_i2cspm_t *i2cspm, bool enable)

Enable or disable sensor measurements.

sl_status_t
sl_veml6035_reset(sl_i2cspm_t *i2cspm)

Reset sensor configuration to the same state as after a power on reset.

sl_status_t
sl_veml6035_configure_sensitivity(sl_i2cspm_t *i2cspm, bool low_sensitivity, uint8_t gain)

Configure sensor sensitivity settings.

sl_status_t
sl_veml6035_configure_integration_time(sl_i2cspm_t *i2cspm, sl_veml6035_integration_time_t integration_time)

Set integration time.

sl_status_t
sl_veml6035_configure_psm(sl_i2cspm_t *i2cspm, sl_veml6035_psm_wait_t psm_wait, bool enable)

Enable power save mode, with a defined wait time between measurements.

sl_status_t
sl_veml6035_configure_interrupt_mode(sl_i2cspm_t *i2cspm, 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_veml6035_enable_interrupt_mode(sl_i2cspm_t *i2cspm, bool enable)

Enable or disable threshold interrupts.

sl_status_t
sl_veml6035_read_interrupt_status(sl_i2cspm_t *i2cspm, bool *threshold_low, bool *threshold_high)

Read threshold interrupt status register and return interrupt status for high and low threshold.

Enumeration Documentation#

sl_veml6035_integration_time_t#

sl_veml6035_integration_time_t

Integration time settings.

Enumerator
veml6035_integration_time_800_ms

800ms integration time

veml6035_integration_time_400_ms

400ms integration time

veml6035_integration_time_200_ms

200ms integration time

veml6035_integration_time_100_ms

100ms integration time

veml6035_integration_time_50_ms

50ms integration time

veml6035_integration_time_25_ms

25ms integration time


sl_veml6035_psm_wait_t#

sl_veml6035_psm_wait_t

Wait time between measurements in power save mode.

Enumerator
veml6035_psm_wait_3200_ms

3200ms wait time

veml6035_psm_wait_1600_ms

1600ms wait time

veml6035_psm_wait_800_ms

800ms wait time

veml6035_psm_wait_400_ms

400ms wait time


sl_veml6035_als_pers_t#

sl_veml6035_als_pers_t

Interrupt persistence settings.

Enumerator
veml6035_als_pers_1

1 sensor reading above/under threshold before interrupt trigger

veml6035_als_pers_2

2 sensor readings above/under threshold before interrupt trigger

veml6035_als_pers_4

4 sensor readings above/under threshold before interrupt trigger

veml6035_als_pers_8

8 sensor readings above/under threshold before interrupt trigger


Function Documentation#

sl_veml6035_init#

sl_status_t sl_veml6035_init (sl_i2cspm_t * i2cspm, bool white_enable)

Initialize and enable the VEML6035 sensor to operate in normal mode.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

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 with sl_veml6035_configure_sensitivity.


sl_veml6035_get_als_lux#

sl_status_t sl_veml6035_get_als_lux (sl_i2cspm_t * i2cspm, float * lux)

Retrieve the sample counts from the ALS channel and calculate the lux value.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

float *[out]lux

The measured ambient light illuminance in lux.


sl_veml6035_get_white_lux#

sl_status_t sl_veml6035_get_white_lux (sl_i2cspm_t * i2cspm, float * lux)

Retrieve the sample counts from the WHITE channel and calculate the lux vaule.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

float *[out]lux

The measured white light illuminance in lux.


sl_veml6035_enable_sensor#

sl_status_t sl_veml6035_enable_sensor (sl_i2cspm_t * i2cspm, bool enable)

Enable or disable sensor measurements.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

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_veml6035_reset#

sl_status_t sl_veml6035_reset (sl_i2cspm_t * i2cspm)

Reset sensor configuration to the same state as after a power on reset.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

Note

  • This function does not clear data output registers, or interrupt status register.


sl_veml6035_configure_sensitivity#

sl_status_t sl_veml6035_configure_sensitivity (sl_i2cspm_t * i2cspm, bool low_sensitivity, uint8_t gain)

Configure sensor sensitivity settings.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

bool[in]low_sensitivity

Set to true for low sensitivity (1/8th of normal), false for normal sensitiviy.

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_veml6035_configure_integration_time#

sl_status_t sl_veml6035_configure_integration_time (sl_i2cspm_t * i2cspm, sl_veml6035_integration_time_t integration_time)

Set integration time.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

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_veml6035_configure_psm#

sl_status_t sl_veml6035_configure_psm (sl_i2cspm_t * i2cspm, sl_veml6035_psm_wait_t psm_wait, bool enable)

Enable power save mode, with a defined wait time between measurements.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

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_veml6035_configure_interrupt_mode#

sl_status_t sl_veml6035_configure_interrupt_mode (sl_i2cspm_t * i2cspm, 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_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

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_veml6035_enable_interrupt_mode#

sl_status_t sl_veml6035_enable_interrupt_mode (sl_i2cspm_t * i2cspm, bool enable)

Enable or disable threshold interrupts.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use.

bool[in]enable

Set to true to enable interrupt mode, false to disable interrupt mode


sl_veml6035_read_interrupt_status#

sl_status_t sl_veml6035_read_interrupt_status (sl_i2cspm_t * i2cspm, bool * threshold_low, bool * threshold_high)

Read threshold interrupt status register and return interrupt status for high and low threshold.

Parameters
TypeDirectionArgument NameDescription
sl_i2cspm_t *[in]i2cspm

The I2C peripheral to use

bool *[out]threshold_low

True if crossing low threshold interrupt was triggered

bool *[out]threshold_high

True if crossing high threshold interrupt was triggered