Android 4.1.2 + Debian kst - Watch battery voltage

I wanted a way to monitor battery voltage on a rooted Android 4.1.2 smartphone (Samsung Galaxy S3 Mini) from a Debian 8 desktop computer.

This is one way to do it:

On Android:

Install SSHDroid SSH server:

(I also tried SSH Server, but this one refused to run commands, which is needed.)

Start the server, it should share root access directly.

On Debian:

Install sshpass and kst:
apt-get install sshpass kst

(sshpass is used to skip entering passwords and kst is a graph viewer amongst other things to display data.)

Create the following file on the desktop, save it as "fetcher" or something else.


# enter the ip or hostname of your phone here

while :
	# fetch data from source
	V=$(sshpass -p "admin" ssh -q -l root -o StrictHostKeyChecking=no $PHONE "cat /sys/class/power_supply/battery/voltage_now")
	C=$(sshpass -p "admin" ssh -q -l root -o StrictHostKeyChecking=no $PHONE "cat /sys/class/power_supply/battery/current_now")
	# voltage is in uV, divide it to get mV
	echo $(($V / 1000)) $C >> batterydata
	# sleep for a while
	sleep 5

Run the file in a terminal standing in the desktop folder:
bash ./fetcher

(Cancel with Ctrl+C / Ctrl+M / Ctrl+Z for the univinted.)

Note: the location of battery data differ based on makers and models, so the sys-path above may not match your phone. Login using standard SSH and have a look for yourself if it doesn't work.

If everything worked, then you should have a new file named batterydata with the voltage.

Open Kst and go to Tools -> Data wizard. Select the batterydata file and go Next.

This is a personal note. Last updated: 2017-08-11 22:14:37.







Don't forget to pay my friend a visit too. Joakim