SI1133 light sensor
Diff: main.cpp
- Revision:
- 0:fe6c4edd0ecc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 06 20:10:47 2019 +0000 @@ -0,0 +1,26 @@ +#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"); + } +}