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

    Core2 should turn off after USB is disconnected

    Core 2
    2
    4
    4.0k
    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.
    • Armin_PPA
      Armin_PP
      last edited by

      Hello,
      I got my first Core2 and it's pretty impressive.

      But I want to turn off the device after the USB port is disconnected.

      With Core Gray this was possible with M5.Power.setPowerVin(false);
      How can I handle this with the Core2?

      Thanks in advance for any help!

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

        Hello @Armin_PP

        maybe I am missing something here, but wouldn't an M5Core2 without battery installed do exactly that - turn off when USB is disconnected?

        If that is not what you are looking for, in M5Core2 the AXP192 is responsible for all power related stuff. Calling m5.Axp.isACIN() will tell you whether USB is connected or not.

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        Armin_PPA 1 Reply Last reply Reply Quote 0
        • Armin_PPA
          Armin_PP @felmue
          last edited by Armin_PP

          @felmue said in Core2 should turn off after USB is disconnected:

          M5Core2

          Good morning Felix,
          thank you for your quick reply :-)

          So I have to disassemble the device and can disconnect the battery I suppose...
          That is of course obvious - I didn't think about it, silly me ;-)

          My goal is - if possible - I would like to do a shutdown few seconds after disconnecting the USB to save all the data on the SD card in time and close the file.
          Later, when the USB voltage is back, the device should boot again automatically

          Is this possible?





          May I ask you where to find more information about API or Power management?
          Because m5.Axp.isACIN() is not described at [https://docs.m5stack.com/en/api/core2/axp192_core2](link url) and also not in the source code AXP192.cpp. So I can only guess what some functions will do...



          Thanks again in advance for your help!

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

            Hello @Armin_PP

            the function is here. Line 390.

            It returns true if USB is connected and false otherwise.

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            1 Reply Last reply Reply Quote 0
            • First post
              Last post