🤖Have you ever tried Chat.M5Stack.com before asking??😎
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
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.
  • H
    hardmax
    last edited by Mar 22, 2019, 3:10 AM

    Hi Everyone,

    I need to record how long a vehicle is on, for this I have to know when the power of the USB port is cut off. Does anyone have any idea how to do that?

    Regards

    M T 2 Replies Last reply Mar 22, 2019, 4:31 AM Reply Quote 0
    • M
      m5-docs @hardmax
      last edited by Mar 22, 2019, 4:31 AM

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

      M5Stack documentation URL

      https://docs.m5stack.com

      H 1 Reply Last reply Mar 22, 2019, 2:26 PM Reply Quote 0
      • H
        hardmax @m5-docs
        last edited by Mar 22, 2019, 2:26 PM

        @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 Mar 23, 2019, 2:34 PM

          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 Mar 24, 2019, 9:24 PM

            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 Aug 27, 2019, 2:52 PM Reply Quote 1
            • T
              TeraWales @hardmax
              last edited by TeraWales May 24, 2019, 4:21 AM Apr 3, 2019, 5:45 PM

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • C
                cepics @hardmax
                last edited by Aug 27, 2019, 2:52 PM

                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 Aug 29, 2019, 1:30 PM

                  I found this:

                  M5.Power.isCharging()
                  
                  L 1 Reply Last reply Sep 3, 2019, 3:18 AM Reply Quote 0
                  • L
                    lukasmaximus @cepics
                    last edited by Sep 3, 2019, 3:18 AM

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

                    C 1 Reply Last reply Sep 3, 2019, 7:17 PM Reply Quote 0
                    • C
                      cepics @lukasmaximus
                      last edited by Sep 3, 2019, 7:17 PM

                      @lukasmaximus m5Stack library version?

                      1 Reply Last reply Reply Quote 0
                      • L
                        lukasmaximus
                        last edited by Sep 4, 2019, 1:13 AM

                        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