Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android get charge rate in milliamps via sysfs

Tags:

android

sysfs

I am developing a informational android app where I want to read the charge rate in milli-amps when the device is charging. I have seen other apps that can do this such as Ampere.

I believe the info should be in directory /sys/class/power_supply/battery which of these files are relevant in accomplishing this, and how could I calculate charge rate in mA from this?

like image 386
rosghub Avatar asked Apr 03 '16 00:04

rosghub


People also ask

How do I know my android charging rate?

Plug in your phone. Give it a moment to see how fast it's charging. Open your phone's Settings app. Under "Battery," see how much charge you have left, and about how long until a full charge.

Is ampere app accurate?

The Play Store listing includes devices the app isn't compatible with, as well as general guidance of the app not being capable of providing precision accuracy. In other words, don't throw away your multimeter.

How can I monitor my charging speed?

Method 1: Ampere One of the quickest and easiest ways to test how fast your smartphone is charging or discharging is by using the Ampere app, which is available free through the Android Play Store.

How can I control my android charging speed?

Put your phone in Airplane Mode before you plug it in. Testing suggests it could reduce the amount of time needed for a full charge by as much as 25%. To put your phone into Airplane Mode, simply swipe down on the notification bar and tap the Airplane mode icon.


2 Answers

According to the linux kernel doc, you can read the charge rate from /sys/class/power_supply/battery/current_now. The value is in µA, so you should scale it by 1000. Negative values mean that the device is charging.

like image 117
SpaceBison Avatar answered Oct 01 '22 19:10

SpaceBison


directory may change according to the phone manufacturer. See this link for supporting more devices currentwidget

And above API 21+ charge counter and energy counter is implemented: see the doc

like image 27
ugur Avatar answered Oct 01 '22 20:10

ugur