Minimum voltage check moved into a separate function. Minimum voltage constant added.

This commit is contained in:
klaute 2018-07-13 20:20:56 +02:00
parent 984dfc07dd
commit a8c40a7e23
2 changed files with 11 additions and 11 deletions

View file

@ -14,6 +14,7 @@
#define UPDATE_WEBSERVER_INTVERVAL_S 1 #define UPDATE_WEBSERVER_INTVERVAL_S 1
#define DELAY_LOOP_MS 50 #define DELAY_LOOP_MS 50
#define POWERSAVING_SLEEP_S 600 #define POWERSAVING_SLEEP_S 600
#define BAT_LOW_VOLTAGE 3.4
#define STATUS_LED_PIN BUILTIN_LED #define STATUS_LED_PIN BUILTIN_LED
#define ANEMOMETER_PIN D7 #define ANEMOMETER_PIN D7

View file

@ -106,13 +106,7 @@ void setup() {
digitalWrite(STATUS_LED_PIN, LOW); digitalWrite(STATUS_LED_PIN, LOW);
if (currentSensorData[SENSOR_BAT_VOLTAGE] <= 3.4) lowBatCheck();
{
#ifdef DEBUG
Serial.println("Low battery, going into deep sleep.");
#endif
ESP.deepSleep(4294967295); // battery low, shutting down
}
WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_OFF);
WiFi.forceSleepBegin(); WiFi.forceSleepBegin();
@ -126,15 +120,20 @@ void setup() {
//*************************************************************************// //*************************************************************************//
void loop() { void lowBatCheck()
{
if (currentSensorData[SENSOR_BAT_VOLTAGE] <= 3.4) if (currentSensorData[SENSOR_BAT_VOLTAGE] <= BAT_LOW_VOLTAGE)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.println("Low battery, going into deep sleep."); Serial.println("Low battery, going into deep sleep.");
#endif #endif
ESP.deepSleep(4294967295); // battery low, shutting down ESP.deepSleep(4294967295); // battery low, shutting down
} }
}
void loop() {
lowBatCheck();
#ifdef POWERSAVING #ifdef POWERSAVING
delay(50); delay(50);