Si1133 - Light and UV Sensor#
Driver for the Silicon Labs Si1133 ambient light and UV sensor.
Si1133 usage example code#
Basic example for measuring light and UV-index:
#include "sl_i2cspm_instances.h"
#include "sl_si1133.h"
int main( void )
{
...
// Initialize sensor using i2cspm instance for sensor
sl_si1133_init(sl_i2cspm_sensor);
// Measure
float lux;
float uvi;
sl_si1133_measure_lux_uvi(sl_i2cspm_sensor, &lux, &uvi);
...
}
Modules#
Functions#
Initialize the Si1133 chip.
Stop the measurements on all channel and waits until the chip goes to sleep state.
Measure lux and UV index using the Si1133 sensor.
Read Hardware ID from the SI1133 sensor.
Reset the Si1133.
Send a RESET COMMAND COUNTER command to the Si1133.
Send a FORCE command to the Si1133.
Send a PAUSE command to the Si1133.
Send a START command to the Si1133.
Write a byte to an Si1133 Parameter.
Read a parameter from the Si1133.
Read samples from the Si1133 chip.
Retrieve the sample values from the chip and convert them to lux and UV index values.
Read the interrupt status register of the device.
Function Documentation#
sl_si1133_init#
sl_status_t sl_si1133_init (sl_i2cspm_t * i2cspm)
Initialize the Si1133 chip.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
sl_si1133_deinit#
sl_status_t sl_si1133_deinit (sl_i2cspm_t * i2cspm)
Stop the measurements on all channel and waits until the chip goes to sleep state.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
sl_si1133_measure_lux_uvi#
sl_status_t sl_si1133_measure_lux_uvi (sl_i2cspm_t * i2cspm, float * lux, float * uvi)
Measure lux and UV index using the Si1133 sensor.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
float * | [out] | lux | The measured ambient light illuminance in lux |
float * | [out] | uvi | The measured UV index |
sl_si1133_get_hardware_id#
sl_status_t sl_si1133_get_hardware_id (sl_i2cspm_t * i2cspm, uint8_t * hardwareID)
Read Hardware ID from the SI1133 sensor.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
uint8_t * | [out] | hardwareID | The Hardware ID of the chip (should be 0x33) |
sl_si1133_reset#
sl_status_t sl_si1133_reset (sl_i2cspm_t * i2cspm)
Reset the Si1133.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
sl_si1133_reset_command_counter#
sl_status_t sl_si1133_reset_command_counter (sl_i2cspm_t * i2cspm)
Send a RESET COMMAND COUNTER command to the Si1133.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
sl_si1133_force_measurement#
sl_status_t sl_si1133_force_measurement (sl_i2cspm_t * i2cspm)
Send a FORCE command to the Si1133.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
sl_si1133_pause_measurement#
sl_status_t sl_si1133_pause_measurement (sl_i2cspm_t * i2cspm)
Send a PAUSE command to the Si1133.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
sl_si1133_start_measurement#
sl_status_t sl_si1133_start_measurement (sl_i2cspm_t * i2cspm)
Send a START command to the Si1133.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
sl_si1133_set_parameter#
sl_status_t sl_si1133_set_parameter (sl_i2cspm_t * i2cspm, uint8_t address, uint8_t value)
Write a byte to an Si1133 Parameter.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
uint8_t | [in] | address | The parameter address |
uint8_t | [in] | value | The byte value to be written to the Si1133 parameter |
Note
This function ensures that the Si1133 is idle and ready to receive a command before writing the parameter. Furthermore, command completion is checked. If setting parameter is not done properly, no measurements will occur. This is the most common error. It is highly recommended that host code make use of this function.
sl_si1133_read_parameter#
sl_status_t sl_si1133_read_parameter (sl_i2cspm_t * i2cspm, uint8_t address)
Read a parameter from the Si1133.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
uint8_t | [in] | address | The address of the parameter. |
sl_si1133_read_samples#
sl_status_t sl_si1133_read_samples (sl_i2cspm_t * i2cspm, sl_si1133_samples_t * samples)
Read samples from the Si1133 chip.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
sl_si1133_samples_t * | [out] | samples | Retrieves interrupt status and measurement data for channel 0..3 and converts the data to int32_t format |
sl_si1133_get_measurement#
sl_status_t sl_si1133_get_measurement (sl_i2cspm_t * i2cspm, float * lux, float * uvi)
Retrieve the sample values from the chip and convert them to lux and UV index values.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
float * | [out] | lux | The measured ambient light illuminance in lux |
float * | [out] | uvi | UV index |
sl_si1133_get_irq_status#
sl_status_t sl_si1133_get_irq_status (sl_i2cspm_t * i2cspm, uint8_t * irqStatus)
Read the interrupt status register of the device.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_i2cspm_t * | [in] | i2cspm | The I2C peripheral to use. |
uint8_t * | [out] | irqStatus | The content of the IRQ status register |