From 449654c2508aee032c15743e26ba88e628886bac Mon Sep 17 00:00:00 2001 From: Thomas Kopp <20.kopp@gmail.com> Date: Sun, 31 Mar 2019 17:01:04 +0200 Subject: [PATCH] working without light sensor --- firmware/firmware.ino | 16 ++++++++++++---- firmware/sensors.ino | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 86b9f49..c55dd8c 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -63,6 +63,8 @@ Influxdb influxdb(INFLUXDB_HOST, INFLUXDB_PORT); Adafruit_APDS9960 apds; Adafruit_BME280 bme; +bool apds_connected = false; + #ifdef WEBUPDATER_FEATURE String localIP = "127.0.0.1"; #endif @@ -116,9 +118,13 @@ void setup() { // Initialize and configure the sensors //Light Sensor - apds.begin(); - apds.enableColor(true); - + if (apds.begin()) { + apds_connected = true; + apds.enableColor(true); + } +#ifdef DEBUG2 + Serial.println("Connected!"); +#endif //Temperature + pressure bool status = bme.begin(BME_ADDRESS); if (!status) { @@ -229,7 +235,9 @@ void _loop() { #endif currentSensorData[SENSOR_TEMPERATURE] = fetchTemperature(); currentSensorData[SENSOR_HUMIDITY] = fetchHumidity(); - currentSensorData[SENSOR_LIGHT] = fetchLight(); + if (apds_connected) { + currentSensorData[SENSOR_LIGHT] = fetchLight(); + } currentSensorData[SENSOR_PRESSURE] = fetchPressure(); #ifdef BATTERY_POWERED currentSensorData[SENSOR_BAT_VOLTAGE] = getBatteryVoltage(); diff --git a/firmware/sensors.ino b/firmware/sensors.ino index 7a4fcdc..fcf1899 100755 --- a/firmware/sensors.ino +++ b/firmware/sensors.ino @@ -24,7 +24,7 @@ float fetchLight() { while(!apds.colorDataReady()) { delay(5); } - + apds.getColorData(&red, &green, &blue, &white); //calculate lux lux = apds.calculateLux(red, green, blue); @@ -75,4 +75,4 @@ float isBatCharging() { } #endif - +