Browse Source

auto-adjust lightMeter sensitivity

main
Hendrik Langer 5 years ago
parent
commit
af59615e93
  1. 16
      src/main.cpp

16
src/main.cpp

@ -181,6 +181,22 @@ void getSensorMeasurements() {
if (light_active) {
sensor_readings.lux = lightMeter.readLightLevel();
// auto-adjust sensitivity
if (sensor_readings.lux < 0) {
Serial.println("Error reading light level");
} else if (sensor_readings.lux > 40000.0) {
if (lightMeter.setMTreg(32)) {
Serial.println(F("Setting MTReg to low value for high light environment"));
}
} else if (sensor_readings.lux <= 10.0) {
if (lightMeter.setMTreg(138)) {
Serial.println(F("Setting MTReg to high value for low light environment"));
}
} else { // if (sensor_readings.lux > 10.0)
if (lightMeter.setMTreg(69)) {
Serial.println(F("Setting MTReg to default value for normal light environment"));
}
}
}
if (sds_active) {

Loading…
Cancel
Save