weatherstation/firmware/sensor_apds9930.ino

33 lines
528 B
Arduino
Raw Normal View History

#include <APDS9930.h>
APDS9930 _sensor_apds9930 = APDS9930();
2022-09-14 11:55:43 +02:00
bool sensor_apds9930_begin()
{
bool status = _sensor_apds9930.init();
2022-09-14 11:55:43 +02:00
if (status)
{
_sensor_apds9930.enableLightSensor(false);
debug("APDS9930 Connected");
2022-09-14 11:55:43 +02:00
} else {
debug("Could not find a valid APDS9930 sensor, check wiring!");
}
2022-09-14 11:55:43 +02:00
return status;
}
2022-09-14 11:55:43 +02:00
float apds9930_light()
{
float ambient_light = 0;
2022-09-14 11:55:43 +02:00
if (_sensor_apds9930.readAmbientLightLux(ambient_light))
{
return ambient_light;
2022-09-14 11:55:43 +02:00
} else {
return 0;
}
2022-05-16 14:26:17 +02:00
}