weatherstation/firmware/sensor_apds9960.ino
2022-05-16 14:26:17 +02:00

28 lines
732 B
C++

#include <Adafruit_APDS9960.h> // Adafruit APDS9960 - https://www.makerfabs.com/index.php?route=product/product&product_id=281
Adafruit_APDS9960 _sensor_apds9960;
bool sensor_apds9960_begin() {
bool status = _sensor_apds9960.begin();
if (status) {
_sensor_apds9960.enableColor(true);
debug("APDS9960 Connected");
} else {
debug("Could not find a valid APDS9960 sensor, check wiring!");
}
return status;
}
float apds9960_light() {
uint16_t red, green, blue, white, lux;
while(!_sensor_apds9960.colorDataReady()) {
delay(5);
}
_sensor_apds9960.getColorData(&red, &green, &blue, &white);
//calculate lux
lux = _sensor_apds9960.calculateLux(red, green, blue);
return lux * LIGHT_FACTOR;
}