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

18
firmware/config.h Normal file → Executable file
View File

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

4
firmware/firmware.ino Normal file → Executable file
View File

@ -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() {
}
//*************************************************************************//
//*************************************************************************//

4
firmware/sensors.ino Normal file → Executable file
View File

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