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

Everything related to the measurement of available battery charge. More...

Functions

void configure (ADC_GPIO battREADPin, OutputGPIO battENPin=UNSPECIFIED::VALUE)
 Monitor battery charge using a battery monitor circuit or a voltage divider.
 
void configure (I2CBus bus=I2CBus::PRIMARY, uint8_t i2c_address=0xFF)
 Monitor battery charge using a "fuel gauge".
 
void setPeriod (uint32_t seconds)
 Set time interval between measurements.
 
void setWarningSoC (uint8_t percentage)
 Set a battery level to warn to the user.
 
void setPowerOffSoC (uint8_t percentage)
 Set a battery level to shutdown the system.
 
void setExternalPowerWitness (InputGPIO sensePin)
 Set a GPIO pin to sense the power wire.
 
void setChargingWitness (InputGPIO sensePin, bool negativeLogic=true, bool enableInternalPullResistor=true)
 Set a GPIO pin to sense if the battery is being charged.
 

Detailed Description

Everything related to the measurement of available battery charge.

Function Documentation

◆ configure() [1/2]

void batteryMonitor::configure ( ADC_GPIO battREADPin,
OutputGPIO battENPin = UNSPECIFIED::VALUE )

Monitor battery charge using a battery monitor circuit or a voltage divider.

Parameters
battREADPinADC pin used to read battery voltage
battENPinOutput pin to enable/disable the battery monitor circuit. Set to UNSPECIFIED::VALUE if battREADPin is attached to a simple voltage divider. This is the case for most battery-enabled DevKits.

◆ configure() [2/2]

void batteryMonitor::configure ( I2CBus bus = I2CBus::PRIMARY,
uint8_t i2c_address = 0xFF )

Monitor battery charge using a "fuel gauge".

Note
For MAX17043 chips or compatible
Parameters
busI2C bus to which the chip is connected. If the secondary bus is used, manual initialization is required using inputs::initializeI2C()
i2c_addressFull I2C address of the fuel gauge chip (7 bits). Set to 0xFF to use a default address.

◆ setChargingWitness()

void batteryMonitor::setChargingWitness ( InputGPIO sensePin,
bool negativeLogic = true,
bool enableInternalPullResistor = true )

Set a GPIO pin to sense if the battery is being charged.

Parameters
sensePinGPIO pin attached to the battery charger chip
negativeLogicIf true, LOW voltage means the battery is charging. If false, HIGH voltage means the battery is charging.
enableInternalPullResistorIf true, the corresponding internal pullup/pulldown resistor is enabled. Set to true if the witness signal works in open drain.

◆ setExternalPowerWitness()

void batteryMonitor::setExternalPowerWitness ( InputGPIO sensePin)

Set a GPIO pin to sense the power wire.

Warning
Use a voltage divider to drop the power wire voltage to 3.3 volts.
Parameters
sensePinGPIO pin to sense the power wire

◆ setPeriod()

void batteryMonitor::setPeriod ( uint32_t seconds)

Set time interval between measurements.

Parameters
[in]secondsTime to wait from one measurement to the next (in seconds). Set to zero for a default interval.

◆ setPowerOffSoC()

void batteryMonitor::setPowerOffSoC ( uint8_t percentage)

Set a battery level to shutdown the system.

Parameters
[in]percentageValue in the range from 0% (disable) to 100%. Invalid values are ignored.

◆ setWarningSoC()

void batteryMonitor::setWarningSoC ( uint8_t percentage)

Set a battery level to warn to the user.

Note
No effect if there is no user interface.
Parameters
[in]percentageValue in the range from 0% (disable) to 100%. Invalid values are ignored.