From e3a9ecc595d4638eaa0497f455af7302a068e608 Mon Sep 17 00:00:00 2001 From: klaute Date: Fri, 13 Jul 2018 08:02:50 +0000 Subject: [PATCH] Update 'firmware/firmware.ino' Moved the deep sleep call in case of low battery to the top of the main loop. --- firmware/firmware.ino | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/firmware/firmware.ino b/firmware/firmware.ino index ee6f78b..e76a117 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -120,6 +120,14 @@ void setup() { void loop() { + if (currentSensorData[SENSOR_BAT_VOLTAGE] <= 3.4) + { +#ifdef DEBUG + Serial.println("Low battery, going into deep sleep."); +#endif + ESP.deepSleep(4294967295); // battery low, shutting down + } + #ifdef POWERSAVING delay(50); return; @@ -134,14 +142,6 @@ void loop() { delay(DELAY_LOOP_MS); - if (currentSensorData[SENSOR_BAT_VOLTAGE] <= 3.4) - { -#ifdef DEBUG - Serial.println("Low battery, going into deep sleep."); -#endif - ESP.deepSleep(4294967295); // battery low, shutting down - } - update_sensor_cnt++; update_webserver_cnt++; } @@ -183,4 +183,4 @@ void _loop() { } //*************************************************************************// - +