SI1133 light sensor
main.cpp
- Committer:
- brunnobbco
- Date:
- 2019-11-06
- Revision:
- 0:fe6c4edd0ecc
File content as of revision 0:fe6c4edd0ecc:
#include "mbed.h" #include "Si1133.h" //I2C i2c (p13, p15); //Create an Si1133 object Si1133 sensor(P0_13, P0_15); //Serial pc(p25, p26); 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"); } }