Si1133 - Light and UV Sensor

Description

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

Si1133 Details
Register interface and implementation details.

Data Structures

struct sl_si1133_samples_t
Structure to store the data measured by the Si1133.

Functions

sl_status_t sl_si1133_init (sl_i2cspm_t *i2cspm)
Initialize the Si1133 chip.
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.
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.
sl_status_t sl_si1133_get_hardware_id (sl_i2cspm_t *i2cspm, uint8_t *hardwareID)
Read Hardware ID from the SI1133 sensor.
sl_status_t sl_si1133_reset (sl_i2cspm_t *i2cspm)
Reset the Si1133.
sl_status_t sl_si1133_reset_command_counter (sl_i2cspm_t *i2cspm)
Send a RESET COMMAND COUNTER command to the Si1133.
sl_status_t sl_si1133_force_measurement (sl_i2cspm_t *i2cspm)
Send a FORCE command to the Si1133.
sl_status_t sl_si1133_pause_measurement (sl_i2cspm_t *i2cspm)
Send a PAUSE command to the Si1133.
sl_status_t sl_si1133_start_measurement (sl_i2cspm_t *i2cspm)
Send a START command to the Si1133.
sl_status_t sl_si1133_set_parameter (sl_i2cspm_t *i2cspm, uint8_t address, uint8_t value)
Write a byte to an Si1133 Parameter.
sl_status_t sl_si1133_read_parameter (sl_i2cspm_t *i2cspm, uint8_t address)
Read a parameter from the Si1133.
sl_status_t sl_si1133_read_samples (sl_i2cspm_t *i2cspm, sl_si1133_samples_t *samples)
Read samples from the Si1133 chip.
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.
sl_status_t sl_si1133_get_irq_status (sl_i2cspm_t *i2cspm, uint8_t *irqStatus)
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.

Parameters
[in] i2cspm The I2C peripheral to use.
Return values
SL_STATUS_OK Success
SL_STATUS_INITIALIZATION Initialization Failure

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.

Parameters
[in] i2cspm The I2C peripheral to use.
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

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.

Parameters
[in] i2cspm The I2C peripheral to use.
[out] lux The measured ambient light illuminance in lux
[out] uvi The measured UV index
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

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.

Parameters
[in] i2cspm The I2C peripheral to use.
[out] hardwareID The Hardware ID of the chip (should be 0x33)
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

sl_si1133_reset()

sl_status_t sl_si1133_reset ( sl_i2cspm_t * i2cspm )

Reset the Si1133.

Parameters
[in] i2cspm The I2C peripheral to use.
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

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.

Parameters
[in] i2cspm The I2C peripheral to use.
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

sl_si1133_force_measurement()

sl_status_t sl_si1133_force_measurement ( sl_i2cspm_t * i2cspm )

Send a FORCE command to the Si1133.

Parameters
[in] i2cspm The I2C peripheral to use.
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

sl_si1133_pause_measurement()

sl_status_t sl_si1133_pause_measurement ( sl_i2cspm_t * i2cspm )

Send a PAUSE command to the Si1133.

Parameters
[in] i2cspm The I2C peripheral to use.
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

sl_si1133_start_measurement()

sl_status_t sl_si1133_start_measurement ( sl_i2cspm_t * i2cspm )

Send a START command to the Si1133.

Parameters
[in] i2cspm The I2C peripheral to use.
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

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.

Parameters
[in] i2cspm The I2C peripheral to use.
[in] address The parameter address
[in] value The byte value to be written to the Si1133 parameter
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure
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.

Parameters
[in] i2cspm The I2C peripheral to use.
[in] address The address of the parameter.
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

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.

Parameters
[in] i2cspm The I2C peripheral to use.
[out] samples Retrieves interrupt status and measurement data for channel 0..3 and converts the data to int32_t format
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

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.

Parameters
[in] i2cspm The I2C peripheral to use.
[out] lux The measured ambient light illuminance in lux
[out] uvi UV index
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure

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.

Parameters
[in] i2cspm The I2C peripheral to use.
[out] irqStatus The content of the IRQ status register
Return values
SL_STATUS_OK Success
SL_STATUS_TRANSMIT I2C transmit failure