Browse Source

Update 'firmware/firmware.ino'

Moved the deep sleep call in case of low battery to the top of the main loop.
klaute 2 years ago
parent
commit
e3a9ecc595
1 changed files with 9 additions and 9 deletions
  1. 9
    9
      firmware/firmware.ino

+ 9
- 9
firmware/firmware.ino View File

@@ -120,6 +120,14 @@ void setup() {
120 120
 
121 121
 void loop() {
122 122
 
123
+  if (currentSensorData[SENSOR_BAT_VOLTAGE] <= 3.4)
124
+  {
125
+#ifdef DEBUG
126
+    Serial.println("Low battery, going into deep sleep.");
127
+#endif
128
+    ESP.deepSleep(4294967295); // battery low, shutting down
129
+  }
130
+
123 131
 #ifdef POWERSAVING
124 132
   delay(50);
125 133
   return;
@@ -134,14 +142,6 @@ void loop() {
134 142
 
135 143
   delay(DELAY_LOOP_MS);
136 144
 
137
-  if (currentSensorData[SENSOR_BAT_VOLTAGE] <= 3.4)
138
-  {
139
-#ifdef DEBUG
140
-    Serial.println("Low battery, going into deep sleep.");
141
-#endif
142
-    ESP.deepSleep(4294967295); // battery low, shutting down
143
-  }
144
-
145 145
   update_sensor_cnt++;
146 146
   update_webserver_cnt++;
147 147
 }
@@ -183,4 +183,4 @@ void _loop() {
183 183
 }
184 184
 
185 185
 //*************************************************************************//
186
-
186
+

Loading…
Cancel
Save