Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. edoceder
    3. Posts
    E
    • Continue chat with edoceder
    • Start new chat with edoceder
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by edoceder

    • RE: M5stickC turn on when connect Type-C USB with power (How to disable?)

      Don't know if still relevant, but you can just power it off if you see it was plugged in.
      I attach a basic code here, and you can tweak it to your needs of course.

      Be aware that you might need to use a small delay before M5.Axp.GetVBusVoltage() will give you a result you can trust.

      //function which reads the voltage coming out of the USB, and if it's above 4.1 I know the device is being charged.
      bool isBeingCharged()
      {
      float charge = M5.Axp.GetVBusVoltage();
      //Serial.println(charge);
      return charge > 4.1;
      }

      //check here of anywhere you want in the code if the device is being charged, and power it off.
      void setup()
      {
      if (isBeingCharged())
      {
      M5.Axp.PowerOff();
      }
      }

      posted in M5 Stick/StickC
      E
      edoceder