Wombat Environmental Node 1.0
An environmental node for SDI-12 and digital sensors.
Loading...
Searching...
No Matches
BatteryMonitor Class Reference

Battery power monitoring handler. More...

#include <battery.h>

Collaboration diagram for BatteryMonitor:

Static Public Member Functions

static void begin ()
 Setup INA219 IC to monitoring battery voltage and current. More...
 
static double get_voltage ()
 Get the voltage of the battery. More...
 
static float get_current ()
 Get the current flowing from/to the battery. More...
 
static void sleep ()
 Puts the INA219 IC in a sleep mode. More...
 
static void wakeup ()
 Wakes up the INA219 IC. More...
 

Static Private Attributes

static const uint8_t batteryAddr = 0x45
 Default I2C battery address (cannot be changed without modifying PCB) More...
 

Detailed Description

Battery power monitoring handler.

A INA219 IC is used to monitor battery voltage and current. When using the Adafruit_INA219 library this IC requires a 1 ohm resistor across its positive and negative inputs.

See also
Library: https://github.com/adafruit/Adafruit_INA219
Datasheet: https://www.ti.com/lit/ds/symlink/ina219.pdf?ts=1673141206831

Member Function Documentation

◆ begin()

void BatteryMonitor::begin ( )
static

Setup INA219 IC to monitoring battery voltage and current.

As the battery has a maximum voltage of 4.2V a calibration factor can be used to improve accuracy.

◆ get_current()

float BatteryMonitor::get_current ( )
static

Get the current flowing from/to the battery.

Note that this may not be super accurate as the current consumption will change when different components become active and inactive. Using external power such as that through the debugger will also result inaccurate readings.

If the IC is not initialed this function will return -1.0.

Returns
Battery current.

◆ get_voltage()

double BatteryMonitor::get_voltage ( )
static

Get the voltage of the battery.

If the IC is not initialed this function will return -1.0.

Returns
Battery voltage.

◆ sleep()

void BatteryMonitor::sleep ( )
static

Puts the INA219 IC in a sleep mode.

The IC will consume around 6 uA when in sleep mode.

◆ wakeup()

void BatteryMonitor::wakeup ( )
static

Wakes up the INA219 IC.

Member Data Documentation

◆ batteryAddr

const uint8_t BatteryMonitor::batteryAddr = 0x45
staticprivate

Default I2C battery address (cannot be changed without modifying PCB)


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