OpenSourceSimWheelESP32
Open-source wireless steering wheel/button box for ESP32 boards
Loading...
Searching...
No Matches
VoltageDividerMonitor Class Reference

Battery monitor implemented as a voltage divider. More...

#include <BatteryMonitorHardware.hpp>

Public Member Functions

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.
 
- Public Member Functions inherited from BatteryMonitorInterface
virtual void getStatus (BatteryStatus &currentStatus)
 Get the battery status.
 
virtual void onStart ()
 Called once when the battery monitor daemon is started.
 

Static Public Member Functions

static uint8_t readingToSoC (int reading)
 Translate a battery reading to a state of charge.
 

Public Attributes

int lastBatteryReading = 0
 Last ADC reading.
 

Protected Member Functions

virtual bool read_soc (uint8_t &currentSoC) override
 Retrieve the current state of charge.
 
- Protected Member Functions inherited from BatteryMonitorInterface

Protected Attributes

OutputGPIO _batteryENPin
 ADC-capable GPIO for reading.
 
ADC_GPIO _batteryREADPin
 output GPIO to enable/disable the circuitry
 
int CHARGING_ADC_READING = 3442
 Minimum expected ADC reading when the battery is charging.
 

Detailed Description

Battery monitor implemented as a voltage divider.

Definition at line 220 of file BatteryMonitorHardware.hpp.

Constructor & Destructor Documentation

◆ 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
battREADPinADC-capable GPIO for reading
battENPinOutput GPIO to enable or disable the circuit. Set to -1 (GPIO_NUM_NC) if the NPN-PNP pair is not used.
resistorToGNDImpedance of the resistor connected to GND. Use any impedance unit, but the same as resistorToBattery
resistorToBatteryImpedance of the resistor connected to the battery positive pole. Use any impedance unit, but the same as resistorToGND . Must be lower than resistorToGND.

Member Function Documentation

◆ read_soc()

virtual bool VoltageDividerMonitor::read_soc ( uint8_t & soc)
overrideprotectedvirtual

Retrieve the current state of charge.

Parameters
[out]socState 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
readingADC reading
Returns
uint8_t State of charge

Member Data Documentation

◆ _batteryENPin

OutputGPIO VoltageDividerMonitor::_batteryENPin
protected

ADC-capable GPIO for reading.

Definition at line 224 of file BatteryMonitorHardware.hpp.

◆ _batteryREADPin

ADC_GPIO VoltageDividerMonitor::_batteryREADPin
protected

output GPIO to enable/disable the circuitry

Definition at line 226 of file BatteryMonitorHardware.hpp.

◆ CHARGING_ADC_READING

int VoltageDividerMonitor::CHARGING_ADC_READING = 3442
protected

Minimum expected ADC reading when the battery is charging.

Definition at line 228 of file BatteryMonitorHardware.hpp.

◆ lastBatteryReading

int VoltageDividerMonitor::lastBatteryReading = 0

Last ADC reading.

Definition at line 236 of file BatteryMonitorHardware.hpp.


The documentation for this class was generated from the following file: