
No i2c device. The actual maximum output capability depends on the input power supply, load, and current-carrying capacity of the connecting cables.G12 (SDA) and G11 (SCL).#include <M5Unified.h>
#include <M5GFX.h>
#include "M5ModulePPS.h"
M5GFX display;
M5Canvas canvas(&display);
M5ModulePPS pps;
// PPS output voltage target and current limit.
#define OUTPUT_VOLTAGE 5.0f
#define OUTPUT_CURRENT 5.0f
void setup() {
M5.begin();
display.begin();
// Create a full-screen canvas for flicker-free updates.
canvas.setFont(&fonts::FreeMonoBoldOblique12pt7b);
canvas.createSprite(display.width(), display.height());
// Retry until the PPS responds on the CoreS3 internal I2C bus.
while (!pps.begin(&Wire, M5.In_I2C.getSDA(), M5.In_I2C.getSCL(),
MODULE_POWER_ADDR, 400000U)) {
Serial.println("module pps connect error");
canvas.clear(BLACK);
canvas.setTextColor(RED);
canvas.drawCenterString("No i2c device", display.width() / 2,
display.height() / 2);
canvas.pushSprite(0, 0);
delay(100);
}
// Apply both setpoints before enabling the power output.
pps.setOutputVoltage(OUTPUT_VOLTAGE);
pps.setOutputCurrent(OUTPUT_CURRENT);
pps.setPowerEnable(true);
}
void loop() {
// Read the live input, output, temperature, and regulation state.
float voltage_readback = pps.getReadbackVoltage();
float current_readback = pps.getReadbackCurrent();
float temperature = pps.getTemperature();
float vin = pps.getVIN();
uint8_t mode = pps.getMode();
// Render one complete status frame before updating the display.
canvas.fillSprite(BLACK);
canvas.setFont(&fonts::FreeMonoBold12pt7b);
canvas.setTextColor(WHITE);
canvas.drawCenterString("Module PPS", display.width() / 2, 0);
canvas.setCursor(10, 40);
canvas.setTextColor(WHITE);
canvas.printf("VIN: ");
canvas.setTextColor(GREEN);
canvas.printf("%.2fV", vin);
canvas.setCursor(10, 80);
canvas.setTextColor(WHITE);
canvas.printf("Mode: ");
canvas.setTextColor(GREEN);
// The PPS switches between CV and CC automatically as the load changes.
if (mode <= 1)
canvas.printf("Constant Voltage");
else
canvas.printf("Constant Current");
canvas.setTextColor(WHITE);
canvas.setCursor(10, 120);
canvas.printf("Voltage: ");
canvas.setTextColor(GREEN);
canvas.printf("%.2fV", voltage_readback);
canvas.setCursor(10, 160);
canvas.setTextColor(WHITE);
canvas.printf("Current: ");
canvas.setTextColor(GREEN);
canvas.printf("%.2fA", current_readback);
canvas.setCursor(10, 200);
canvas.setTextColor(WHITE);
canvas.printf("Temperature: ");
canvas.setTextColor(GREEN);
canvas.printf("%.2fC", temperature);
canvas.pushSprite(0, 0);
}
Constant Voltage) when the load current is below the current limit. If the load attempts to exceed the current limit, the module reduces the output voltage and enters constant-current mode (Constant Current). getMode() only reads the current state; it does not switch modes manually.