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

    How to know when the power of the USB port is cut off?

    General
    5
    11
    15.3k
    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.
    • m5-docsM
      m5-docs @hardmax
      last edited by

      @hardmax What's your specific meaning? What's the vehicle?

      M5Stack documentation URL

      https://docs.m5stack.com

      H 1 Reply Last reply Reply Quote 0
      • H
        hardmax @m5-docs
        last edited by

        @watson Its a tractor...I use a USB Charger (12v to 5v USB..I connect M5 to USB) and when I turn on the tractor, it power on M5 (because power in adapter is ON)...
        The problem is when I turn off the tractor, the M5 is still on for several minutes more by the internal battery...I need to detect when the external power to the M5 is removed (the tractor shuts down and register that time) and that it remains on for a few minutes so that it finishes sending the data and then Power Off the M5.

        Do you have any Idea??...I try to Ask to Internal IP5306 charger, but i dont find any register that show if externaly is connected ( I find, status of charge, batery level but not external power) (https://github.com/m5stack/M5Stack/issues/74)

        1 Reply Last reply Reply Quote 0
        • H
          hardmax
          last edited by

          I found this info about controler charger:

          IP5306 https://yadi.sk/i/dRp0HTF4oPCo2g

          Same thing for IP5209 IP5109 IP5207 IP5108
          https://yadi.sk/i/oNhqTei36jFwSg

          I going to try found something about external power...
          I write to you when I find what I'm looking for

          1 Reply Last reply Reply Quote 0
          • H
            hardmax
            last edited by

            I found this solution:

            uint8_t getIP5306REG(uint8_t reg)
            {
            Wire.beginTransmission(0x75);
            Wire.write(reg);
            if (Wire.endTransmission(false) == 0
            && Wire.requestFrom(0x75, 1)) {
            return Wire.read();
            }
            return 0;
            }

            bool batery_mode = (getIP5306REG(0x70) & 0x04) // Return 1 Batery Mode, 0 Charging or V_In enable

            C 1 Reply Last reply Reply Quote 1
            • T
              TeraWales @hardmax
              last edited by TeraWales

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • C
                cepics @hardmax
                last edited by

                Hi, @hardmax said in How to know when the power of the USB port is cut off?:

                I found this solution:

                uint8_t getIP5306REG(uint8_t reg)
                {
                	Wire.beginTransmission(0x75);
                	Wire.write(reg);
                	if (Wire.endTransmission(false) == 0
                		&& Wire.requestFrom(0x75, 1)) {
                		return Wire.read();
                	}
                	return 0;
                }
                
                bool batery_mode = (getIP5306REG(0x70) & 0x04) // Return 1 Batery Mode, 0 Charging or V_In enable
                

                is it working for you?

                tnks

                1 Reply Last reply Reply Quote 0
                • C
                  cepics
                  last edited by

                  I found this:

                  M5.Power.isCharging()
                  
                  lukasmaximusL 1 Reply Last reply Reply Quote 0
                  • lukasmaximusL
                    lukasmaximus @cepics
                    last edited by

                    @cepics I get the error "Class M5Stack has no member named Power"

                    C 1 Reply Last reply Reply Quote 0
                    • C
                      cepics @lukasmaximus
                      last edited by

                      @lukasmaximus m5Stack library version?

                      1 Reply Last reply Reply Quote 0
                      • lukasmaximusL
                        lukasmaximus
                        last edited by

                        Are you using an older version of the library? if so would you mind telling me which version. You can check in the manage libraries panel

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