MPPT Controller Service

group MPPT Controller Service

Manages solar MPPT channels and associated telemetry.

The MPPT controller handles all solar power input channels. Responsibilities:

  • initialize MPPT ICs and configure GPIO/HAL interfaces

  • read per-channel voltage/current measurements

  • monitor MPPT status (faults, overtemp, undervoltage)

  • compute per-channel and total solar input power

  • provide interfaces to higher-level services (battery, power policy)

group Structures & Enums

Types used by the MPPT Controller Service.

Enums

enum mppt_status_t

MPPT channel health state.

Represents the operating or fault condition of a solar MPPT channel.

Values:

enumerator MPPT_STATUS_OK

Channel operating nominally

enumerator MPPT_STATUS_DISABLED

Channel disabled by software or hardware

enumerator MPPT_STATUS_FAULT

General hardware fault or unexpected condition

enumerator MPPT_STATUS_UNDERVOLT

Input voltage too low for MPPT to operate

enumerator MPPT_STATUS_OVERTEMP

Channel is thermally throttled or shut down

struct mppt_channel_t
#include <mppt_controller.h>

Snapshot of an individual MPPT channel.

Each channel includes voltage/current on both input and output sides, power computation, and MPPT chip status.

Public Members

float input_voltage

Input voltage (solar panel side), in volts

float input_current

Input current, in amps

float output_voltage

Regulated output voltage, in volts

float output_current

Output current, in amps

float power

Computed output power, in watts

mppt_status_t status

Operational status

bool enabled

True if channel is enabled

bool pgood

True if MPPT chip reports power-good

struct mppt_t
#include <mppt_controller.h>

Individual MPPT device.

Each MPPT device must be initialized with mppt_init

Public Members

mppt_channel_t *channels

List of MPPT channels for this device

bool initialized

True if this device has been initialized

group Public API

External interface for interacting with the MPPT Controller Service.

Functions

void mppt_init(mppt_t *mppt)

Initialize all MPPT channels.

Configures MPPT hardware interfaces & chips, sets default states, and prepares for voltage/current sensing.

This must be called once at startup per MPPT device before any other MPPT functions are called.

Note

This function is idempotent.

void mppt_enable(uint8_t ch)

Enable a specific MPPT channel.

Enables the MPPT chip via GPIO, clears stale faults, and marks the channel active for telemetry updates.

Parameters:

ch – Channel index (0 to NUM_MPPT_CHANNELS-1)

void mppt_disable(uint8_t ch)

Disable a specific MPPT channel.

Used during power-budget constraints, safe-mode transitions, or thermal protection events.

Parameters:

ch – Channel index (0 to NUM_MPPT_CHANNELS-1)

void mppt_update(void)

Update readings for all MPPT channels.

Clears and refreshes telemetry for each MPPT IC:

  • input/output voltage/current

  • computed power

  • PGOOD & fault state

  • thermal/undervoltage status

Should be called once per main loop cycle.

mppt_channel_t mppt_get_channel(uint8_t ch)

Get the current telemetry for a given MPPT channel.

Parameters:

ch – Channel index (0 to NUM_MPPT_CHANNELS-1)

Returns:

mppt_channel_t snapshot of the channel state.

float mppt_get_total_power(void)

Get total power generated across all MPPT channels.

Aggregates the power field from all enabled channels.

Returns:

Total power in watts.