LCC Fusion Project 1.0
LCC Automation
Loading...
Searching...
No Matches
LccNodePowerMonitor Class Reference

Monitors voltage and current for up to two Power-CAN Cards using ADS1115 ADCs. More...

#include <LccNodePowerMonitor.h>

Collaboration diagram for LccNodePowerMonitor:

Public Member Functions

void begin ()
 Initializes ADS1115 devices for each Power-CAN card and the SSD1309 console if present. More...
 
void update ()
 Reads and prints voltage, current, and power for all detected rails.
 
void print ()
 Prints voltage/current/power to Serial and to OLED (if available).
 
String get ()
 Returns a multi-line formatted string of all power values.
 

Private Member Functions

String _fmtRow (float v_in, float v_load, float current, float power)
 Formats a single line for the OLED console. More...
 

Detailed Description

Monitors voltage and current for up to two Power-CAN Cards using ADS1115 ADCs.

Monitors voltage and current from up to two Power-CAN cards using ADS1115 ADCs.

The LccNodePowerMonitor class provides automatic detection and monitoring of up to two ADS1115 ADC devices connected over I2C to measure voltage, current, and power for four power rails: 40V, 12V, 5V, and 3.3V. It continuously samples the rails, computes results, and reports the values via the serial console. Optionally, it can display the measurements on an attached OLED or emulator display for real-time visualization.

The class is designed for use with Power-CAN Cards in the LCC Fusion Project and supports:

  • Auto-detection of available ADS1115 ADC devices over I2C.
  • Measurement and calculation of voltage, current, and power on each rail.
  • Reporting of readings to the serial port.
  • Optional real-time display output.

Typical usage involves instantiating a single LccNodePowerMonitor object and calling its update method regularly in the main loop to keep readings up-to-date and outputs refreshed.

Note
The actual wiring and scaling factors for current and voltage calculation should match the specific hardware configuration used on the Power-CAN Cards.
Author
Pat Fleming
Date
June 10, 2024

This class supports automatic detection of ADS1115 devices over I2C and reports voltage, current, and power for four rails: 40V, 12V, 5V, and 3.3V. Results are printed to Serial and optionally to an OLED or emulator display.

Each card has two ADS1115s:

  • ADS1 (addresses 0x48 and 0x49) for 40V and 12V
  • ADS2 (addresses 0x4A and 0x4B) for 5V and 3.3V

Voltage dividers and differential shunt readings are used for calculations.

  • Display Support: Attempts to detect and initialize a 128x64 SSD1309 OLED at I²C address 0x3C. If found, readings for 40V, 12V, 5V, and 3.3V are rendered using the OledDisplay (wrap/scroll capable).
  • Serial Monitoring: All detected rails are also printed to the Serial console in a clear, multi-line format.

OLED I²C Address: 0x3C

Definition at line 71 of file LccNodePowerMonitor.h.

Member Function Documentation

◆ _fmtRow()

String LccNodePowerMonitor::_fmtRow ( float  v_in,
float  v_load,
float  current,
float  power 
)
inlineprivate

Formats a single line for the OLED console.

Parameters
v_inInput voltage before shunt.
v_loadVoltage after shunt.
currentCalculated current.
powerCalculated power.
Returns
A compact, single-line String suitable for 21-char width (~SSD1309 5x8 font).

Definition at line 206 of file LccNodePowerMonitor.h.

Here is the caller graph for this function:

◆ begin()

void LccNodePowerMonitor::begin ( )
inline

Initializes ADS1115 devices for each Power-CAN card and the SSD1309 console if present.

Attempts to connect to all four possible ADS1115 addresses. Sets gain to GAIN_ONE (±4.096V) if successful. Probes 0x3C for the SSD1309 OLED and initializes OledDisplay if found.

Definition at line 80 of file LccNodePowerMonitor.h.

Here is the call graph for this function:
Here is the caller graph for this function:

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