Driver for the Silicon Labs Si1133 Visible Light/UV sensor
Dependents: TBSense2_Sensor_Demo mbed-BLE-coragem-teste Pulga_BLE_GPS pulga-mbed-lorawan-gps ... more
Sample library for use with the Silicon Labs Si1133 sensor for visible light intensity (lux) and UV index measurements.
Information
All examples in this repo are considered EXPERIMENTAL QUALITY, meaning this code has been created as one-off proof-of-concept and is suitable as a demonstration for experimental purposes only. This code will not be regularly maintained by Silicon Labs and there is no guarantee that these projects will work across all environments, SDK versions and hardware.
Datasheet
https://www.silabs.com/documents/public/data-sheets/Si1133.pdf
Usage
#include "mbed.h" #include "Si1133.h" //Create an Si1133 object Si1133 sensor(PC4, PC5); int main() { //Try to open the Si1133 if (sensor.open()) { printf("Device detected!\n"); while (1) { //Print the current light level printf("Lux = %.3f\n", (float)sensor.get_light_level()); //Print the current UV index printf("UV index = %.3f\n", (float)sensor.get_uv_index()); //Sleep for 0.5 seconds wait(0.5); } } else { error("Device not detected!\n"); } }
Diff: Si1133.h
- Revision:
- 2:1e2dd643afa8
- Parent:
- 0:667132a19341
--- a/Si1133.h Sun Nov 12 16:42:03 2017 +0100 +++ b/Si1133.h Sun Nov 12 20:18:04 2017 +0100 @@ -280,12 +280,12 @@ uint32_t read_parameter (enum Parameter address); uint32_t init (void); uint32_t deinit (void); - uint32_t measurementGet (Samples_t *samples); - int32_t getUv (int32_t uv); - int32_t getLux (int32_t vis_high, int32_t vis_low, int32_t ir); - uint32_t measureLuxUvi (float *lux, float *uvi); - uint32_t getMeasurement (float *lux, float *uvi); - uint32_t getHardwareID (uint8_t *hardwareID); + uint32_t measure (Samples_t *samples); + int32_t get_uv (int32_t uv); + int32_t get_lux (int32_t vis_high, int32_t vis_low, int32_t ir); + uint32_t measure_lux_uv (float *lux, float *uvi); + uint32_t get_measurement (float *lux, float *uvi); + uint32_t get_hardware_id (uint8_t *hardware_id); int32_t calculate_polynomial_helper (int32_t input, int8_t fraction, uint16_t mag, int8_t shift); int32_t calculate_polynomial (int32_t x, int32_t y, uint8_t input_fraction, uint8_t output_fraction, uint8_t num_coeff, const Coeff_t *kp);