12 .bits = powerConfigBits
24 FOSSASAT_VERBOSE_PRINT(F(
"MPPT "));
25 FOSSASAT_VERBOSE_PRINTLN(charge);
28 if(powerConfig.bits.mpptKeepAliveEnabled) {
30 FOSSASAT_VERBOSE_PRINTLN(
'K');
34 FOSSASAT_VERBOSE_PRINTLN(
'L');
49 uint32_t interval = 0;
51 #ifdef ENABLE_INTERVAL_CONTROL 56 interval = (uint32_t)20 * (uint32_t)1000;
57 }
else if(batt > 4.0f) {
58 interval = (uint32_t)35 * (uint32_t)1000;
59 }
else if(batt > 3.9f) {
60 interval = (uint32_t)100 * (uint32_t)1000;
61 }
else if(batt > 3.8f) {
62 interval = (uint32_t)160 * (uint32_t)1000;
63 }
else if(batt > 3.7f) {
64 interval = (uint32_t)180 * (uint32_t)1000;
66 interval = (uint32_t)240 * (uint32_t)1000;
79 float numLoops = 0.5f;
81 numLoops += (float)ms / 500.0;
83 numLoops += (float)ms / 50.0;
92 for(uint32_t i = 0; i < (uint32_t)numLoops; i++) {
95 LowPower.powerDown(SLEEP_500MS, ADC_OFF, BOD_OFF);
110 ina.configure(INA226_AVERAGES_1, INA226_BUS_CONV_TIME_1100US, INA226_SHUNT_CONV_TIME_1100US, INA226_MODE_SHUNT_BUS_CONT);
118 Wire.endTransmission();
122 Wire.requestFrom((uint8_t)
INA_ADDR, (uint8_t)2);
123 if(Wire.available() != 2) {
128 uint8_t vha = Wire.read();
129 uint8_t vla = Wire.read();
130 uint16_t value = vha << 8 | vla;
146 val =
ina.readBusVoltage();
159 return(
ina.readBusVoltage());
166 return(
ina.readShuntCurrent());
174 bool checkPassed =
true;
177 powerConfig.bits.lowPowerModeActive = 1;
181 powerConfig.bits.lowPowerModeActive = 0;
#define BATTERY_VOLTAGE_LIMIT
void Power_Control_Delay(uint32_t ms, bool sleep, bool sleepRadio=false)
This function delays the program execution for the given number of milliseconds, while maintaining th...
bool Power_Control_Check_Battery_Limit()
Checks whether battery voltage is below low power limit. Will enable low power mode if that is the ca...
void Pin_Interface_Watchdog_Heartbeat(bool manageBattery=false)
This function toggles the signal to the watchdog and writes it to the pin.
#define MPPT_KEEP_ALIVE_ENABLED
float Power_Control_Get_Charging_Current()
Gets the amperage which is being provided to the battery.
float Pin_Interface_Read_Temperature(uint8_t sensorAddr)
This function reads the TMP100's value from its wire address.
void Power_Control_Save_Configuration()
Saves the configuration bytes from RAM into EEPROM.
float Power_Control_Get_Battery_Voltage()
Get the battery voltage by switching the MPPT off and then on again after reading is taken...
void Power_Control_Load_Configuration()
Load the configuration bytes from the EEPROM into RAM.
#define LOW_POWER_MODE_ACTIVE
void Power_Control_Charge(bool charge)
This function ensures that the battery is charging. "set MPPT to input which enables battery charging...
#define INA_MANUFACTURER_ID
#define INA_REG_MANUFACTURER_ID
powerConfig_t powerConfig
The current power configuration settings.
#define EEPROM_POWER_CONFIG_ADDR
Start AddressEnd Address 0x00010x0001
Power configuration strutcture, each entry is one bit long. Total 1 byte, lowPowerModeActive is the l...
#define LOW_POWER_MODE_ENABLED
bool Power_Control_INA226_Check()
Check that the INA2256 is valid.
uint32_t Power_Control_Get_Sleep_Interval()
Get the amount of seconds to sleep for given the battery voltage.
float Power_Control_Get_Charging_Voltage()
Gets the charging voltage (from the solar panels) by not switching the MPPT off and taking an INA226 ...
Union to quickly access power configuration bits or the entire single-byte value. ...
#define BATTERY_TEMP_SENSOR_ADDR
#define MPPT_TEMP_SWITCH_ENABLED
void Power_Control_Setup_INA226()
Initializes the INA226 current sensor.
#define BATTERY_TEMPERATURE_LIMIT
#define DIGITAL_OUT_MPPT_PIN