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.

Defines

MPPT_CONTROLLER_SERVICE_ID
MPPT_EVENT_FAULT_DETECTED
MPPT_EVENT_PGOOD_CHANGED
MPPT_EVENT_VOLTAGE_LOW
MPPT_EVENT_TELEMETRY

Enums

enum mppt_controller_event_id_t

Values:

enumerator MPPT_FAULT_DETECTED

Published when a critical fault is detected. Payload: mppt_channel_t (Snapshot at time of fault)

enumerator MPPT_PGOOD_CHANGED

The state of the MPPT controller’s PGOOD pin has changed Payload: new state (bool)

enumerator MPPT_VOLTAGE_LOW

The MPPT input voltage level has lowered below the threshold Payload: new voltage (float)

enumerator MPPT_TELEMETRY

Periodic telemetry broadcast Payload: mppt_channel_t.

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

size_t num_channels

Number of MPPT channels

uint32_t tick_counter

Internal counter for update loop

uint32_t telemetry_tick_counter

Internal counter for telemetry publish timing

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

If called more than once, the internal MPPT controller state will be reset.

Parameters:

mppt[out] The MPPT controller

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)