From 42fcf062b7608f6ab5719427292246d92ee90421 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Fri, 9 Aug 2019 18:29:30 +0200 Subject: [PATCH] power down sensors --- src/main.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 5e0abdc..42234cc 100644 --- a/src/main.cpp +++ b/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?"); }