Minimum voltage check moved into a separate function. Minimum voltage constant added.
This commit is contained in:
parent
984dfc07dd
commit
a8c40a7e23
2 changed files with 11 additions and 11 deletions
|
@ -14,6 +14,7 @@
|
|||
#define UPDATE_WEBSERVER_INTVERVAL_S 1
|
||||
#define DELAY_LOOP_MS 50
|
||||
#define POWERSAVING_SLEEP_S 600
|
||||
#define BAT_LOW_VOLTAGE 3.4
|
||||
|
||||
#define STATUS_LED_PIN BUILTIN_LED
|
||||
#define ANEMOMETER_PIN D7
|
||||
|
|
|
@ -106,13 +106,7 @@ void setup() {
|
|||
|
||||
digitalWrite(STATUS_LED_PIN, LOW);
|
||||
|
||||
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
|
||||
}
|
||||
lowBatCheck();
|
||||
|
||||
WiFi.mode(WIFI_OFF);
|
||||
WiFi.forceSleepBegin();
|
||||
|
@ -126,15 +120,20 @@ void setup() {
|
|||
|
||||
//*************************************************************************//
|
||||
|
||||
void loop() {
|
||||
|
||||
if (currentSensorData[SENSOR_BAT_VOLTAGE] <= 3.4)
|
||||
void lowBatCheck()
|
||||
{
|
||||
if (currentSensorData[SENSOR_BAT_VOLTAGE] <= BAT_LOW_VOLTAGE)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Serial.println("Low battery, going into deep sleep.");
|
||||
#endif
|
||||
ESP.deepSleep(4294967295); // battery low, shutting down
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
lowBatCheck();
|
||||
|
||||
#ifdef POWERSAVING
|
||||
delay(50);
|
||||
|
@ -191,4 +190,4 @@ void _loop() {
|
|||
}
|
||||
|
||||
//*************************************************************************//
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue