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 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

View file

@ -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);