Core2: Python API to get battery charge level
-
Is there a Python API to get battery charge level for the Core2 battery?
I found power.getChargeState() but it just returns true/false (charging/discharging). There is also power.getBatVoltage() which could be an indication of the charge level but would need some additional math to calculate the percentage.
-
I found table with voltage and according percentage on internet and make this code
https://github.com/stonatm/UiFlow-custom-blocks/blob/master/battery-capacity/battery.py
ewentually you could calculate with formula something like this, but it is not accurate.
percentage = int( (battery_voltage - 3.20) * 100) -
I see that your code applies to the M5stickC. Do you think the table is the same for the M5 Core2?
-
Should work if you replace line
volt = axp.getBatVoltage()with
volt = power.getBatVoltage()Battery discharge characteristics should be the same +/- some small variations independently of battery capacity.
-
Thanks. I checked on the Core2 and here battery voltage also ranges from about 3.2V to 4.2V.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login