Battery monitor implemented as a voltage divider.
More...
#include <BatteryMonitorHardware.hpp>
|
|
int | read () |
| | Get ADC reading.
|
| |
| | VoltageDividerMonitor (ADC_GPIO battREADPin, OutputGPIO battENPin, uint32_t resistorToGND=200, uint32_t resistorToBattery=110) |
| | Construct a new Voltage Divider Monitor object.
|
| |
| virtual void | getStatus (BatteryStatus ¤tStatus) |
| | Get the battery status.
|
| |
| virtual void | onStart () |
| | Called once when the battery monitor daemon is started.
|
| |
|
| static uint8_t | readingToSoC (int reading) |
| | Translate a battery reading to a state of charge.
|
| |
|
| virtual bool | read_soc (uint8_t ¤tSoC) override |
| | Retrieve the current state of charge.
|
| |
Battery monitor implemented as a voltage divider.
Definition at line 220 of file BatteryMonitorHardware.hpp.
◆ VoltageDividerMonitor()
| VoltageDividerMonitor::VoltageDividerMonitor |
( |
ADC_GPIO | battREADPin, |
|
|
OutputGPIO | battENPin, |
|
|
uint32_t | resistorToGND = 200, |
|
|
uint32_t | resistorToBattery = 110 ) |
Construct a new Voltage Divider Monitor object.
- Note
- The parameters
resistorToGND and resistorToBattery are used to determine the expected voltage in the ADC pin when charging, and nothing else. Incoherent values are ignored.
- Parameters
-
| battREADPin | ADC-capable GPIO for reading |
| battENPin | Output GPIO to enable or disable the circuit. Set to -1 (GPIO_NUM_NC) if the NPN-PNP pair is not used. |
| resistorToGND | Impedance of the resistor connected to GND. Use any impedance unit, but the same as resistorToBattery |
| resistorToBattery | Impedance of the resistor connected to the battery positive pole. Use any impedance unit, but the same as resistorToGND . Must be lower than resistorToGND. |
◆ read_soc()
| virtual bool VoltageDividerMonitor::read_soc |
( |
uint8_t & | soc | ) |
|
|
overrideprotectedvirtual |
Retrieve the current state of charge.
- Parameters
-
| [out] | soc | State of charge. Higher than 101 if the battery is charging at constant voltage. |
- Returns
- true If
soc was retrieved with success
-
false If there is no battery or
soc is unknown
Implements BatteryMonitorInterface.
◆ readingToSoC()
| static uint8_t VoltageDividerMonitor::readingToSoC |
( |
int | reading | ) |
|
|
static |
Translate a battery reading to a state of charge.
- Parameters
-
- Returns
- uint8_t State of charge
◆ _batteryENPin
◆ _batteryREADPin
| ADC_GPIO VoltageDividerMonitor::_batteryREADPin |
|
protected |
◆ CHARGING_ADC_READING
| int VoltageDividerMonitor::CHARGING_ADC_READING = 3442 |
|
protected |
◆ lastBatteryReading
| int VoltageDividerMonitor::lastBatteryReading = 0 |
The documentation for this class was generated from the following file: