How to know when the power of the USB port is cut off?
-
@hardmax What's your specific meaning? What's the vehicle?
-
@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)
-
I found this info about controler charger:
IP5306 https://yadi.sk/i/dRp0HTF4oPCo2g
Same thing for IP5209 IP5109 IP5207 IP5108
https://yadi.sk/i/oNhqTei36jFwSgI going to try found something about external power...
I write to you when I find what I'm looking for -
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
-
This post is deleted! -
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
-
I found this:
M5.Power.isCharging()
-
@cepics I get the error "Class M5Stack has no member named Power"
-
@lukasmaximus m5Stack library version?
-
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