From 740bfc600b0511281bc45d6f46e15c9a0884d89e Mon Sep 17 00:00:00 2001 From: klaute Date: Sat, 2 Feb 2019 11:15:27 +0100 Subject: [PATCH] Battery charging states added. --- firmware/config.h | 18 ++++++++++-------- firmware/firmware.ino | 4 ++-- firmware/sensors.ino | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) mode change 100644 => 100755 firmware/config.h mode change 100644 => 100755 firmware/firmware.ino mode change 100644 => 100755 firmware/sensors.ino diff --git a/firmware/config.h b/firmware/config.h old mode 100644 new mode 100755 index da0ab0e..00db8b3 --- a/firmware/config.h +++ b/firmware/config.h @@ -15,14 +15,14 @@ #define BAT_CHARGE_STATE_CHARGING 1.0 #define BAT_CHARGE_STATE_NOTCHARGING 0.0 -#define WIFI_AUTOCONNECT_TIMEOUT_S 60 -#define WIFI_CONFIG_PORTAL_TIMEOUT_S 60 -#define UPDATE_SENSOR_INTERVAL_S 10 -#define UPDATE_WEBSERVER_INTVERVAL_S 1 -#define DELAY_LOOP_MS 50 -#define POWERSAVING_SLEEP_S 600 +#define WIFI_AUTOCONNECT_TIMEOUT_S 60 +#define WIFI_CONFIG_PORTAL_TIMEOUT_S 60 +#define UPDATE_SENSOR_INTERVAL_S 10 +#define UPDATE_WEBSERVER_INTVERVAL_S 1 +#define DELAY_LOOP_MS 50 +#define POWERSAVING_SLEEP_S 600 #define EMERGENCY_SLEEP_S 172800 // Sleep for 2 days to recover -#define ENERGY_SAVING_ITERATIONS 30 +#define ENERGY_SAVING_ITERATIONS 30 #define BAT_LOW_VOLTAGE 3.6 #define BAT_EMERGENCY_DEEPSLEEP_VOLTAGE 3.5 @@ -31,6 +31,8 @@ #define STATUS_LED_PIN BUILTIN_LED #define ANEMOMETER_PIN D7 +#define BAT_CHARGED_PIN D6 +#define BAT_CHARGING_PIN D5 #define BME_SCK 13 #define BME_MISO 12 @@ -40,4 +42,4 @@ #define INITIAL_WEBSERVER_TIME 20 -#endif +#endif diff --git a/firmware/firmware.ino b/firmware/firmware.ino old mode 100644 new mode 100755 index bb01514..2fba37e --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -75,7 +75,7 @@ void setup() { if (!wifiManager.autoConnect(wifiName.c_str(), "DEADBEEF")) { #ifdef DEBUG - Serial.println("WiFi connection failed, we reboot ..."); + Serial.println("WiFi connection failed, going into deep sleep ..."); #endif // If autoconnect to WLAN failed and no client connected, go to deep sleep ESP.deepSleep(POWERSAVING_SLEEP_S * 1000000, WAKE_RF_DEFAULT); @@ -244,4 +244,4 @@ void _loop() { } -//*************************************************************************// +//*************************************************************************// diff --git a/firmware/sensors.ino b/firmware/sensors.ino old mode 100644 new mode 100755 index a503a3b..2123cfb --- a/firmware/sensors.ino +++ b/firmware/sensors.ino @@ -62,7 +62,7 @@ float getBatteryVoltage() { return volt * 4.2; } -float isBatCompletelyCharged() { +float isBatCharging() { if (HIGH == digitalRead(BAT_CHARGED_PIN)) { return BAT_CHARGE_STATE_CHARGED; @@ -74,4 +74,4 @@ float isBatCompletelyCharged() { return BAT_CHARGE_STATE_NOTCHARGING; } -#endif +#endif