Browse Source

Added battery pin configuration

master
klaute 2 years ago
parent
commit
35e1234798
  1. 6
      firmware/config.h
  2. 1
      firmware/config_user.h.example
  3. 10
      firmware/firmware.ino
  4. 3
      firmware/sensor_battery.ino

6
firmware/config.h

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

1
firmware/config_user.h.example

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

10
firmware/firmware.ino

@ -45,14 +45,20 @@ void setup() {
#endif
// Pin settings
pinMode(BAT_CHARGED_PIN, INPUT_PULLUP);
pinMode(BAT_CHARGING_PIN, INPUT_PULLUP);
pinMode(BAT_CHARGED_PIN, INPUT);
pinMode(BAT_CHARGING_PIN, INPUT);
pinMode(STATUS_LED_PIN, OUTPUT);
pinMode(ANEMOMETER_PIN, INPUT_PULLUP);
pinMode(A0, INPUT);
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
criticalBatCheck();
#endif

3
firmware/sensor_battery.ino

@ -13,6 +13,9 @@ float battery_voltage() {
}
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)) {
return BAT_CHARGE_STATE_CHARGING;
} else if (LOW == digitalRead(BAT_CHARGED_PIN)) {

Loading…
Cancel
Save