Core2 should turn off after USB is disconnected

  • 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!

  • 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.


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


    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 [](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!

  • Hello @Armin_PP

    the function is here. Line 390.

    It returns true if USB is connected and false otherwise.