pdf-icon

Arduino Quick Start

2. Devices & Examples

6. Applications

StickC Power - AXP192

The M5StickC uses the AXP192 power management scheme, and the following API and case study programs can be used to realize the basic power input/output data reading.

Example

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <M5StickC.h> void setup() { M5.begin(); M5.Lcd.begin(); M5.Lcd.setRotation(3); } void loop() { M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(0, 0, 1); M5.Lcd.printf("AXP Temp: %.1fC \r\n", M5.Axp.GetTempInAXP192()); M5.Lcd.printf("Bat:\r\n V: %.3fv I: %.3fma\r\n", M5.Axp.GetBatVoltage(), M5.Axp.GetBatCurrent()); M5.Lcd.printf("USB:\r\n V: %.3fv I: %.3fma\r\n", M5.Axp.GetVBusVoltage(), M5.Axp.GetVBusCurrent()); M5.Lcd.printf("5V-In:\r\n V: %.3fv I: %.3fma\r\n", M5.Axp.GetVinVoltage(), M5.Axp.GetVinCurrent()); M5.Lcd.printf("Bat power %.3fmw", M5.Axp.GetBatPower()); M5.update(); delay(100); }

begin

Syntax:

void begin(void);

Description:

  • To initialize the AXP192 chip, using M5.begin() will automatically call Axp.begin() internally.

Parameters:

  • null

Return:

  • null

Example:

cpp
1 2 3 4 5 6
#include <M5StickC.h> void setup() { M5.begin(); } void loop() {}

PowerOff

Syntax:

void PowerOff();

Description:

  • Turn off the power

Parameters:

  • null

Return:

  • null

Example:

cpp
1 2 3 4 5 6 7 8 9 10 11
#include <M5StickC.h> void setup() { M5.begin(); M5.lcd.fillScreen(GREEN); delay(3000); M5.Axp.PowerOff(); } void loop() { }

ScreenBreath

Syntax:

void ScreenBreath(uint8_t brightness);

Description:

  • Change the LDO3 output voltage of AXP192 chip to adjust the brightness of screen backlight.

Parameters:

  • uint8_t brightness:
    • 0-100

Return:

  • null

Example:

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <M5StickC.h> uint8_t i = 0; void setup() { M5.begin(); // By default, "M5.begin()" will initialize AXP192 chip M5.Lcd.printf("Hello, M5Stack!!"); } void loop() { M5.Axp.ScreenBreath(i++); if (i > 100) i = 0; delay(10); }

ScreenSwitch

Syntax:

void ScreenSwitch(bool state);

Description:

  • Screen Backlight Switch

Parameters:

  • bool state:
    • true:Turn on the screen backlight
    • false:Turn off the screen backlight

Return:

  • null

Example:

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <M5StickC.h> uint8_t i = 0; void setup() { M5.begin(); M5.Lcd.fillScreen(BLUE); } void loop() { M5.Axp.ScreenSwitch(true); delay(1000); M5.Axp.ScreenSwitch(false); delay(1000); }

GetBatState

Syntax:

bool GetBatState();

Description:

  • Read battery connection status

Parameters:

  • null

Return:

  • bool:
    • true:Battery connected
    • false:Battery not connected

GetBatVoltage

Syntax:

float GetBatVoltage();

Description:

  • Read battery voltage

Parameters:

  • null

Return:

  • float:
    • Battery Voltage(V)

GetBatCurrent

Syntax:

float GetBatCurrent();

Description:

  • Read battery current

Parameters:

  • null

Return:

  • float:
    • Battery Current(mA)

GetVinVoltage

Syntax:

float GetVinVoltage();

Description:

  • Read VIN input voltage

Parameters:

  • null

Return:

  • float:
    • VIN input voltage(V)

GetVinCurrent

Syntax:

float GetVinCurrent();

Description:

  • Read VIN input current

Parameters:

  • null

Return:

  • float:
    • VIN Input Current(mA)

GetVBusVoltage

Syntax:

float GetVBusVoltage();

Description:

  • Read USB input voltage

Parameters:

  • null

Return:

  • float:
    • USB Input Voltage(V)

GetVBusCurrent

Syntax:

float GetVBusCurrent();

Description:

  • Read USB input current

Parameters:

  • null

Return:

  • float:
    • USB Input Current(mA)

GetTempInAXP192

Syntax:

float GetTempInAXP192();

Description:

  • Read the value of the AXP192 internal temperature sensor

Parameters:

  • null

Return:

  • float:
    • temperature value(deg C)

GetBatPower

Syntax:

float GetBatPower();

Description:

  • Read current battery power mW

Parameters:

  • null

Return:

  • float:
    • Battery power(mW)
On This Page