Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read power input from usb

Is there any way to read the power input from a USB connection in Android?

For example plug in a micro usb lead into the phone from either a computer USB output, a mains charger, or something similar and read the voltage and amp output?

I have no idea where to start looking for this information, and when searching I can only find battery widgets, or power consumption apps - this is not what I'm looking for, I want to be able to read how much power is being sent via the USB interface that is connected.

Many thanks.

like image 225
Thomas Clayson Avatar asked Sep 25 '12 13:09

Thomas Clayson


1 Answers

Probably, You should start with BatteryManager , refer to this question for some examples of usage. I believe the data provided by BatteryManager should be enough to provide approximate calculation of what You want to (how much power is being sent via the USB). Having device id and table of devices default batteries capacities or/and users input about capacity and % difference with time interval and voltage probably would give enough info for approximate calculation of consumption

Another (dirty) way might be the following - dig android sources if ones have any info about total capacity / consumption You can obtain e.g. with java reflection. I think BatteryManager and BatteryStatsImpl could be appropriate places to start analysis from.

like image 63
sandrstar Avatar answered Oct 19 '22 04:10

sandrstar