Browse Source

power down sensors

main
Hendrik Langer 5 years ago
parent
commit
42fcf062b7
  1. 22
      src/main.cpp

22
src/main.cpp

@ -119,7 +119,26 @@ time_t getTimestamp() {
void poweroffDevices() {
display.powerOff();
// ToDo: Sensors
if (sensors_active.bme680) {
bme680.setGasHeater(0, 0);
}
if (sensors_active.bme280) {
bme280.setSampling(Adafruit_BME280::MODE_SLEEP,
Adafruit_BME280::SAMPLING_X1, // temperature
Adafruit_BME280::SAMPLING_X1, // pressure
Adafruit_BME280::SAMPLING_X1, // humidity
Adafruit_BME280::FILTER_OFF );
}
if (sensors_active.light) {
static constexpr byte BH1750_I2CADDR = 0x23;
Wire.beginTransmission(BH1750_I2CADDR);
Wire.write(BH1750_POWER_DOWN);
byte ack = Wire.endTransmission();
}
if (sensors_active.uv) {
uv.shutdown(true);
}
}
@ -718,6 +737,7 @@ void setup()
if (lightMeter.begin()) {
sensors_active.light = true;
lightMeter.setMTreg((byte) BH1750_DEFAULT_MTREG);
} else {
ESP_LOGW(TAG, "Failed to communicate with BH1750 sensor, check wiring?");
}

Loading…
Cancel
Save