🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Power Input

    Core 2
    2
    3
    2.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bexybot
      last edited by bexybot

      Hello everyone,

      I have some questions about powering the Core2 module:

      1. Currently, if the device is turned off and is connected by USB-C, it turns on. I would like to know if I put the 5V bus in input mode and feed it 5V the same thing happens.
      2. I was wondering what is the best way to detect the 5V input turning off to turn off the Core2 since there is a battery and it could stay on. Any ideas?

      Thanks very much for your help!
      Fábio Dias

      1 Reply Last reply Reply Quote 0
      • B
        bexybot
        last edited by bexybot

        So with a bit of research, I develop this simple code that makes exactly what I was asking here:

        #include <M5Core2.h>
        #define DEVICE_TIMEOUT 120000
        float Time_bat = 0;
        
        void setup{
          M5.begin();
          M5.Axp.SetBusPowerMode(1);
        }
        
        void loop{
          M5.Lcd.drawString(("Battery: " + String(M5.Axp.GetBatteryLevel())), 0, 120, 2);
          if(!M5.Axp.isVBUS() && !M5.Axp.isCharging()){
            M5.Lcd.drawString(String((millis() - Time_bat)/1000,0) + "         ", 1, 154, 1);
          }else{M5.Lcd.drawString("Feeded             ", 1, 154, 1);}
        
          if(!M5.Axp.isVBUS() && !M5.Axp.isCharging()){
              if(Time_bat == 0){Time_bat = millis();}
              if((millis() - Time_bat) > DEVICE_TIMEOUT){M5.shutdown();}
          }else{
            Time_bat = 0;
          } 
        }
        

        Hope it helps someone!

        1 Reply Last reply Reply Quote 0
        • felmueF
          felmue
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • First post
            Last post