working without light sensor
This commit is contained in:
parent
b0ec86890d
commit
449654c250
2 changed files with 14 additions and 6 deletions
|
@ -63,6 +63,8 @@ Influxdb influxdb(INFLUXDB_HOST, INFLUXDB_PORT);
|
||||||
Adafruit_APDS9960 apds;
|
Adafruit_APDS9960 apds;
|
||||||
Adafruit_BME280 bme;
|
Adafruit_BME280 bme;
|
||||||
|
|
||||||
|
bool apds_connected = false;
|
||||||
|
|
||||||
#ifdef WEBUPDATER_FEATURE
|
#ifdef WEBUPDATER_FEATURE
|
||||||
String localIP = "127.0.0.1";
|
String localIP = "127.0.0.1";
|
||||||
#endif
|
#endif
|
||||||
|
@ -116,9 +118,13 @@ void setup() {
|
||||||
|
|
||||||
// Initialize and configure the sensors
|
// Initialize and configure the sensors
|
||||||
//Light Sensor
|
//Light Sensor
|
||||||
apds.begin();
|
if (apds.begin()) {
|
||||||
apds.enableColor(true);
|
apds_connected = true;
|
||||||
|
apds.enableColor(true);
|
||||||
|
}
|
||||||
|
#ifdef DEBUG2
|
||||||
|
Serial.println("Connected!");
|
||||||
|
#endif
|
||||||
//Temperature + pressure
|
//Temperature + pressure
|
||||||
bool status = bme.begin(BME_ADDRESS);
|
bool status = bme.begin(BME_ADDRESS);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
|
@ -229,7 +235,9 @@ void _loop() {
|
||||||
#endif
|
#endif
|
||||||
currentSensorData[SENSOR_TEMPERATURE] = fetchTemperature();
|
currentSensorData[SENSOR_TEMPERATURE] = fetchTemperature();
|
||||||
currentSensorData[SENSOR_HUMIDITY] = fetchHumidity();
|
currentSensorData[SENSOR_HUMIDITY] = fetchHumidity();
|
||||||
currentSensorData[SENSOR_LIGHT] = fetchLight();
|
if (apds_connected) {
|
||||||
|
currentSensorData[SENSOR_LIGHT] = fetchLight();
|
||||||
|
}
|
||||||
currentSensorData[SENSOR_PRESSURE] = fetchPressure();
|
currentSensorData[SENSOR_PRESSURE] = fetchPressure();
|
||||||
#ifdef BATTERY_POWERED
|
#ifdef BATTERY_POWERED
|
||||||
currentSensorData[SENSOR_BAT_VOLTAGE] = getBatteryVoltage();
|
currentSensorData[SENSOR_BAT_VOLTAGE] = getBatteryVoltage();
|
||||||
|
|
|
@ -24,7 +24,7 @@ float fetchLight() {
|
||||||
while(!apds.colorDataReady()) {
|
while(!apds.colorDataReady()) {
|
||||||
delay(5);
|
delay(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
apds.getColorData(&red, &green, &blue, &white);
|
apds.getColorData(&red, &green, &blue, &white);
|
||||||
//calculate lux
|
//calculate lux
|
||||||
lux = apds.calculateLux(red, green, blue);
|
lux = apds.calculateLux(red, green, blue);
|
||||||
|
@ -75,4 +75,4 @@ float isBatCharging() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue