VEML6035 - Ambient Light Sensor
Description
Driver for the Vishay VEML6025 ambient light sensor.
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.
|
|
Enumerations |
|
enum |
sl_veml6035_integration_time_t
{
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 |
sl_veml6035_psm_wait_t
{
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 |
sl_veml6035_als_pers_t
{
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.
|
|
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.
- 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 .
- Parameters
-
[in] i2cspm
The I2C peripheral to use. [in] white_enable
Set to true to enable WHITE channel sensor readings in addition to the ALS channel.
- Return values
-
SL_STATUS_OK
Success SL_STATUS_INITIALIZATION
Initialization Failure
◆ 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
-
[in] i2cspm
The I2C peripheral to use. [out] lux
The measured ambient light illuminance in lux.
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure SL_STATUS_INVALID_CONFIGURATION
Invalid sensor configuration
◆ 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
-
[in] i2cspm
The I2C peripheral to use. [out] lux
The measured white light illuminance in lux.
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure SL_STATUS_INVALID_CONFIGURATION
Invalid sensor configuration
◆ sl_veml6035_enable_sensor()
sl_status_t sl_veml6035_enable_sensor | ( | sl_i2cspm_t * |
i2cspm,
|
bool |
enable
|
||
) |
Enable or disable sensor measurements.
- Note
- Disabling the sensor does not make sensor lose its configuration and last measurement values.
- Parameters
-
[in] i2cspm
The I2C peripheral to use. [in] enable
Set to true to enable sensor, set to false to disable sensor.
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure
◆ 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.
- Note
- This function does not clear data output registers, or interrupt status register.
- Parameters
-
[in] i2cspm
The I2C peripheral to use.
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure
◆ 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.
- Note
- A low sensitivity results in a larger light sensing range, while a high sensitivity yields a higher resolution at low illumination levels.
- Parameters
-
[in] i2cspm
The I2C peripheral to use. [in] low_sensitivity
Set to true for low sensitivity (1/8th of normal), false for normal sensitiviy. [in] gain
Sensitivity gain, possible values: 1, 2, 4
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure SL_STATUS_INVALID_PARAMATER
Invalid parameter
◆ 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.
- Note
- The default integration time is 100ms. This can be increased to achieve a higher resolution, or decreased to achieve a faster measurement rate.
- Parameters
-
[in] i2cspm
The I2C peripheral to use. [in] integration_time
Integration time
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure
◆ 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
-
[in] i2cspm
The I2C peripheral to use. [in] psm_wait
The desired interval between measurements [in] enable
Set to true to enable power save mode, false to disable power save mode.
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure
◆ 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
-
[in] i2cspm
The I2C peripheral to use. [in] high_threshold
Threshold for interrupt to trigger when lux value above [in] low_threshold
Interrupt should trigger when lux count below this value [in] persistence
How many sensor reads out of threshold window before interrupt triggers [in] white_enable
Selection for which channel the interrupt should trigger. True for WHITE channel, false for ALS channel. [in] enable
Set to true to enable interrupts, false to disable interrupts
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure
◆ 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
-
[in] i2cspm
The I2C peripheral to use. [in] enable
Set to true to enable interrupt mode, false to disable interrupt mode
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure
◆ 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
-
[in] i2cspm
The I2C peripheral to use [out] threshold_low
True if crossing low threshold interrupt was triggered [out] threshold_high
True if crossing high threshold interrupt was triggered
- Return values
-
SL_STATUS_OK
Success SL_STATUS_TRANSMIT
I2C transmit failure
Enumeration Type Documentation
◆ sl_veml6035_integration_time_t
Integration time settings.
◆ sl_veml6035_psm_wait_t
◆ sl_veml6035_als_pers_t
Interrupt persistence settings.