Browse Source

Battery charging states added.

klaute 1 year ago
parent
commit
740bfc600b
3 changed files with 14 additions and 12 deletions
  1. 10
    8
      firmware/config.h
  2. 2
    2
      firmware/firmware.ino
  3. 2
    2
      firmware/sensors.ino

+ 10
- 8
firmware/config.h View File

@@ -15,14 +15,14 @@
15 15
 #define BAT_CHARGE_STATE_CHARGING    1.0
16 16
 #define BAT_CHARGE_STATE_NOTCHARGING 0.0
17 17
 
18
-#define WIFI_AUTOCONNECT_TIMEOUT_S    60
19
-#define WIFI_CONFIG_PORTAL_TIMEOUT_S  60
20
-#define UPDATE_SENSOR_INTERVAL_S      10
21
-#define UPDATE_WEBSERVER_INTVERVAL_S   1
22
-#define DELAY_LOOP_MS                 50
23
-#define POWERSAVING_SLEEP_S          600
18
+#define WIFI_AUTOCONNECT_TIMEOUT_S       60
19
+#define WIFI_CONFIG_PORTAL_TIMEOUT_S     60
20
+#define UPDATE_SENSOR_INTERVAL_S         10
21
+#define UPDATE_WEBSERVER_INTVERVAL_S      1
22
+#define DELAY_LOOP_MS                    50
23
+#define POWERSAVING_SLEEP_S             600
24 24
 #define EMERGENCY_SLEEP_S            172800 // Sleep for 2 days to recover
25
-#define ENERGY_SAVING_ITERATIONS     30
25
+#define ENERGY_SAVING_ITERATIONS         30
26 26
 
27 27
 #define BAT_LOW_VOLTAGE                 3.6
28 28
 #define BAT_EMERGENCY_DEEPSLEEP_VOLTAGE 3.5
@@ -31,6 +31,8 @@
31 31
 
32 32
 #define STATUS_LED_PIN        BUILTIN_LED
33 33
 #define ANEMOMETER_PIN        D7
34
+#define BAT_CHARGED_PIN       D6
35
+#define BAT_CHARGING_PIN      D5
34 36
 
35 37
 #define BME_SCK  13
36 38
 #define BME_MISO 12
@@ -40,4 +42,4 @@
40 42
 
41 43
 #define INITIAL_WEBSERVER_TIME 20
42 44
 
43
-#endif
45
+#endif

+ 2
- 2
firmware/firmware.ino View File

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

+ 2
- 2
firmware/sensors.ino View File

@@ -62,7 +62,7 @@ float getBatteryVoltage() {
62 62
   return volt * 4.2;
63 63
 }
64 64
 
65
-float isBatCompletelyCharged() {
65
+float isBatCharging() {
66 66
   if (HIGH == digitalRead(BAT_CHARGED_PIN))
67 67
   {
68 68
     return BAT_CHARGE_STATE_CHARGED;
@@ -74,4 +74,4 @@ float isBatCompletelyCharged() {
74 74
   return BAT_CHARGE_STATE_NOTCHARGING;
75 75
 }
76 76
 
77
-#endif
77
+#endif

Loading…
Cancel
Save