pdf-icon

Arduino入門

2. デバイス&サンプル

5. 拡張モジュール&サンプル

アクセサリー

6. アプリケーション

CoreS3 Power 電源管理

CoreS3 電源管理関連 API およびサンプルプログラム。

サンプルプログラム

コンパイル要件

  • M5Stack ボード マネージャー バージョン >= 3.2.2
  • ボード選択 = M5CoreS3
  • M5Unified ライブラリ バージョン >= 0.2.11
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#include "M5Unified.h"

void setup()
{
    auto cfg = M5.config();
    // if using ext power input(Grove Port or DC input power supply) needs to be set to false.
    // cfg.output_power = false;
    M5.begin(cfg);
    M5.Display.setTextSize(2);
    M5.Power.setChargeCurrent(200);
}

void loop()
{
    M5.Display.clear();

    bool bat_ischarging = M5.Power.isCharging();
    M5.Display.setCursor(10, 30);
    M5.Display.printf("Bat Charging: %d", bat_ischarging);

    int bat_vol = M5.Power.getBatteryVoltage();
    M5.Display.setCursor(10, 50);
    M5.Display.printf("Bat Voltage: %dmv", bat_vol);

    int bat_level = M5.Power.getBatteryLevel();
    M5.Display.setCursor(10, 70);
    M5.Display.printf("Bat Level: %d", bat_level);

    int vbus_vol = M5.Power.getVBUSVoltage();
    M5.Display.setCursor(10, 90);
    M5.Display.printf("VBus Voltage: %dmv", vbus_vol);
    delay(1000);
}

アップロードが成功した後、CoreS3 でバッテリーの充電状態、バッテリー電圧、バッテリーレベルのパーセンテージ、および VBUS 電圧などの情報を確認できます。

API

CoreS3 電源セクションは M5Unified ライブラリの Power_Class を使用しています。関連する詳細な API については、以下のドキュメントを参照してください:

On This Page