Added battery pin configuration

This commit is contained in:
klaute 2020-02-20 19:49:44 +01:00
parent f9ee9740ae
commit 35e1234798
4 changed files with 18 additions and 2 deletions

View file

@ -32,8 +32,14 @@
#define STATUS_LED_PIN LED_BUILTIN #define STATUS_LED_PIN LED_BUILTIN
#define ANEMOMETER_PIN D7 #define ANEMOMETER_PIN D7
#ifndef BAT_PINS_D34
#define BAT_CHARGED_PIN D6 #define BAT_CHARGED_PIN D6
#define BAT_CHARGING_PIN D5 #define BAT_CHARGING_PIN D5
#else
#define BAT_CHARGED_PIN D3
#define BAT_CHARGING_PIN D4
#endif
#define BME_SCK 13 #define BME_SCK 13
#define BME_MISO 12 #define BME_MISO 12

View file

@ -17,6 +17,7 @@
//#define SENSOR_APDS9930 //#define SENSOR_APDS9930
#define SENSOR_BME280 #define SENSOR_BME280
#define SENSOR_BATTERY #define SENSOR_BATTERY
//#define BAT_PINS_D34
const float HUMIDITY_FACTOR = 1.0; const float HUMIDITY_FACTOR = 1.0;
const float LIGHT_FACTOR = 1.0; const float LIGHT_FACTOR = 1.0;

View file

@ -45,14 +45,20 @@ void setup() {
#endif #endif
// Pin settings // Pin settings
pinMode(BAT_CHARGED_PIN, INPUT_PULLUP); pinMode(BAT_CHARGED_PIN, INPUT);
pinMode(BAT_CHARGING_PIN, INPUT_PULLUP); pinMode(BAT_CHARGING_PIN, INPUT);
pinMode(STATUS_LED_PIN, OUTPUT); pinMode(STATUS_LED_PIN, OUTPUT);
pinMode(ANEMOMETER_PIN, INPUT_PULLUP); pinMode(ANEMOMETER_PIN, INPUT_PULLUP);
pinMode(A0, INPUT); pinMode(A0, INPUT);
digitalWrite(STATUS_LED_PIN, LOW); digitalWrite(STATUS_LED_PIN, LOW);
#ifndef BAT_PINS_D34
debug("D5 D6 used as battery pins");
#else
debug("D3 D4 used as battery pins");
#endif
#ifdef BATTERY_POWERED #ifdef BATTERY_POWERED
criticalBatCheck(); criticalBatCheck();
#endif #endif

View file

@ -13,6 +13,9 @@ float battery_voltage() {
} }
float battery_charging() { float battery_charging() {
//debug("charging pin=" + String(digitalRead(BAT_CHARGING_PIN)));
//debug("charged pin=" + String(digitalRead(BAT_CHARGED_PIN)));
if (LOW == digitalRead(BAT_CHARGING_PIN)) { if (LOW == digitalRead(BAT_CHARGING_PIN)) {
return BAT_CHARGE_STATE_CHARGING; return BAT_CHARGE_STATE_CHARGING;
} else if (LOW == digitalRead(BAT_CHARGED_PIN)) { } else if (LOW == digitalRead(BAT_CHARGED_PIN)) {