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

    Power Input

    Scheduled Pinned Locked Moved Core 2
    3 Posts 2 Posters 3.6k Views
    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 Offline
      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 Offline
        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 Offline
          felmue
          last edited by

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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post