Browse Source

Added battery pin configuration

klaute 8 months ago
parent
commit
35e1234798
4 changed files with 18 additions and 2 deletions
  1. 6
    0
      firmware/config.h
  2. 1
    0
      firmware/config_user.h.example
  3. 8
    2
      firmware/firmware.ino
  4. 3
    0
      firmware/sensor_battery.ino

+ 6
- 0
firmware/config.h View File

@@ -32,8 +32,14 @@
32 32
 
33 33
 #define STATUS_LED_PIN        LED_BUILTIN
34 34
 #define ANEMOMETER_PIN        D7
35
+
36
+#ifndef BAT_PINS_D34
35 37
 #define BAT_CHARGED_PIN       D6
36 38
 #define BAT_CHARGING_PIN      D5
39
+#else
40
+#define BAT_CHARGED_PIN       D3
41
+#define BAT_CHARGING_PIN      D4
42
+#endif
37 43
 
38 44
 #define BME_SCK  13
39 45
 #define BME_MISO 12

+ 1
- 0
firmware/config_user.h.example View File

@@ -17,6 +17,7 @@
17 17
 //#define SENSOR_APDS9930
18 18
 #define SENSOR_BME280
19 19
 #define SENSOR_BATTERY
20
+//#define BAT_PINS_D34
20 21
 
21 22
 const float HUMIDITY_FACTOR = 1.0;
22 23
 const float LIGHT_FACTOR    = 1.0;

+ 8
- 2
firmware/firmware.ino View File

@@ -45,14 +45,20 @@ void setup() {
45 45
 #endif
46 46
 
47 47
   // Pin settings
48
-  pinMode(BAT_CHARGED_PIN, INPUT_PULLUP);
49
-  pinMode(BAT_CHARGING_PIN, INPUT_PULLUP);
48
+  pinMode(BAT_CHARGED_PIN, INPUT);
49
+  pinMode(BAT_CHARGING_PIN, INPUT);
50 50
   pinMode(STATUS_LED_PIN, OUTPUT);
51 51
   pinMode(ANEMOMETER_PIN, INPUT_PULLUP);
52 52
   pinMode(A0, INPUT);
53 53
 
54 54
   digitalWrite(STATUS_LED_PIN, LOW);
55 55
 
56
+#ifndef BAT_PINS_D34
57
+  debug("D5 D6 used as battery pins");
58
+#else
59
+  debug("D3 D4 used as battery pins");
60
+#endif
61
+
56 62
 #ifdef BATTERY_POWERED
57 63
   criticalBatCheck();
58 64
 #endif

+ 3
- 0
firmware/sensor_battery.ino View File

@@ -13,6 +13,9 @@ float battery_voltage() {
13 13
 }
14 14
 
15 15
 float battery_charging() {
16
+  //debug("charging pin=" + String(digitalRead(BAT_CHARGING_PIN)));
17
+  //debug("charged pin=" + String(digitalRead(BAT_CHARGED_PIN)));
18
+
16 19
   if (LOW == digitalRead(BAT_CHARGING_PIN)) {
17 20
     return BAT_CHARGE_STATE_CHARGING;
18 21
   } else if (LOW == digitalRead(BAT_CHARGED_PIN)) {

Loading…
Cancel
Save