Battery charging states added.

This commit is contained in:
klaute 2019-02-02 11:15:27 +01:00
parent 87fe6c6e7a
commit 740bfc600b
3 changed files with 14 additions and 12 deletions

16
firmware/config.h Normal file → Executable file
View file

@ -15,14 +15,14 @@
#define BAT_CHARGE_STATE_CHARGING 1.0 #define BAT_CHARGE_STATE_CHARGING 1.0
#define BAT_CHARGE_STATE_NOTCHARGING 0.0 #define BAT_CHARGE_STATE_NOTCHARGING 0.0
#define WIFI_AUTOCONNECT_TIMEOUT_S 60 #define WIFI_AUTOCONNECT_TIMEOUT_S 60
#define WIFI_CONFIG_PORTAL_TIMEOUT_S 60 #define WIFI_CONFIG_PORTAL_TIMEOUT_S 60
#define UPDATE_SENSOR_INTERVAL_S 10 #define UPDATE_SENSOR_INTERVAL_S 10
#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 EMERGENCY_SLEEP_S 172800 // Sleep for 2 days to recover #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_LOW_VOLTAGE 3.6
#define BAT_EMERGENCY_DEEPSLEEP_VOLTAGE 3.5 #define BAT_EMERGENCY_DEEPSLEEP_VOLTAGE 3.5
@ -31,6 +31,8 @@
#define STATUS_LED_PIN BUILTIN_LED #define STATUS_LED_PIN BUILTIN_LED
#define ANEMOMETER_PIN D7 #define ANEMOMETER_PIN D7
#define BAT_CHARGED_PIN D6
#define BAT_CHARGING_PIN D5
#define BME_SCK 13 #define BME_SCK 13
#define BME_MISO 12 #define BME_MISO 12

2
firmware/firmware.ino Normal file → Executable file
View file

@ -75,7 +75,7 @@ void setup() {
if (!wifiManager.autoConnect(wifiName.c_str(), "DEADBEEF")) { if (!wifiManager.autoConnect(wifiName.c_str(), "DEADBEEF")) {
#ifdef DEBUG #ifdef DEBUG
Serial.println("WiFi connection failed, we reboot ..."); Serial.println("WiFi connection failed, going into deep sleep ...");
#endif #endif
// If autoconnect to WLAN failed and no client connected, go to deep sleep // If autoconnect to WLAN failed and no client connected, go to deep sleep
ESP.deepSleep(POWERSAVING_SLEEP_S * 1000000, WAKE_RF_DEFAULT); ESP.deepSleep(POWERSAVING_SLEEP_S * 1000000, WAKE_RF_DEFAULT);

2
firmware/sensors.ino Normal file → Executable file
View file

@ -62,7 +62,7 @@ float getBatteryVoltage() {
return volt * 4.2; return volt * 4.2;
} }
float isBatCompletelyCharged() { float isBatCharging() {
if (HIGH == digitalRead(BAT_CHARGED_PIN)) if (HIGH == digitalRead(BAT_CHARGED_PIN))
{ {
return BAT_CHARGE_STATE_CHARGED; return BAT_CHARGE_STATE_CHARGED;