diff --git a/firmware/sensor_apds9930.ino b/firmware/sensor_apds9930.ino index 0917dd5..0790208 100644 --- a/firmware/sensor_apds9930.ino +++ b/firmware/sensor_apds9930.ino @@ -2,21 +2,30 @@ APDS9930 _sensor_apds9930 = APDS9930(); -bool sensor_apds9930_begin() { +bool sensor_apds9930_begin() +{ bool status = _sensor_apds9930.init(); - if (status) { + + if (status) + { _sensor_apds9930.enableLightSensor(false); debug("APDS9930 Connected"); + } else { debug("Could not find a valid APDS9930 sensor, check wiring!"); } + return status; } -float apds9930_light() { +float apds9930_light() +{ float ambient_light = 0; - if (_sensor_apds9930.readAmbientLightLux(ambient_light)) { + + if (_sensor_apds9930.readAmbientLightLux(ambient_light)) + { return ambient_light; + } else { return 0; } diff --git a/firmware/sensor_apds9960.ino b/firmware/sensor_apds9960.ino index b6ad2ab..ea0bd4a 100644 --- a/firmware/sensor_apds9960.ino +++ b/firmware/sensor_apds9960.ino @@ -2,26 +2,34 @@ Adafruit_APDS9960 _sensor_apds9960; -bool sensor_apds9960_begin() { +bool sensor_apds9960_begin() +{ bool status = _sensor_apds9960.begin(); - if (status) { + + 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() { +float apds9960_light() +{ uint16_t red, green, blue, white, lux; - while(!_sensor_apds9960.colorDataReady()) { + 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; } diff --git a/firmware/sensor_bme280.ino b/firmware/sensor_bme280.ino index ae22d3f..0e9afeb 100644 --- a/firmware/sensor_bme280.ino +++ b/firmware/sensor_bme280.ino @@ -3,22 +3,32 @@ Adafruit_BME280 _sensor_bme280; -bool sensor_bme280_begin(uint8_t addr) { +bool sensor_bme280_begin(uint8_t addr) +{ bool status = _sensor_bme280.begin(addr); - if (status) { + + if (status) + { debug("BME280 Connected"); + } else { debug("Could not find a valid BME280 sensor, check wiring!"); } + return status; } -float bme280_temperature() { +float bme280_temperature() +{ return _sensor_bme280.readTemperature() * TEMP_FACTOR; } -float bme280_pressure() { + +float bme280_pressure() +{ return _sensor_bme280.readPressure() / 100.0F; } -float bme280_humidity() { + +float bme280_humidity() +{ return _sensor_bme280.readHumidity() * HUMIDITY_FACTOR; }