cosurgi
http://janek.kozicki.pl/
Hi, sorry if this is wrong section, but I think that most of battery-related problems will appear here. So this is why I decided to post this here.
I was worried that my battery has problems and so I had setup a simple script for tracking battery life. I have records from more than a week already, and finally (in the bus) I have time to post about how I'm doing this. So that everyone concerned can track battery life, and perhaps later we can compare our results.
That's really simple, first you have to install cron:
will do that for you. Then you need to make a script battery.sh like this:
then you need to make it executable with:
Also make sure that you have write access in place where you record the battery data.
Finally you need to add a crontab entry. Make a textfile that contains:
and with this command
make it to be your crontab. Remember that you need empty line at the end of crontab file or it will not work. I am invoking this script every two minutes (the */2 is for that), you might want to chose different interval. You can check for sure if your crontab is really configured by "l"isting it with command
OK, so now you have recording up and running, you can check if your battery.dat file is getting filled with numbers.
At the end I have made a simple gnuplot script for plotting this data, but there is still lots of room for improvement here:
(just change your paths to battery.dat file)
to plot this on pandora you will need to install gnuplot, fortunately [/CODE]
So if you are interested in battery life - go setup your cron and start recording it!
EDIT: now setup cron with call "crontab texfile" - should make things simpler for everyone.
EDIT: added invocation to gnuplot, for plotting.
I was worried that my battery has problems and so I had setup a simple script for tracking battery life. I have records from more than a week already, and finally (in the bus) I have time to post about how I'm doing this. So that everyone concerned can track battery life, and perhaps later we can compare our results.
That's really simple, first you have to install cron:
Code:
opkg install cron
Code:
#!/bin/sh
cd /media/someSDcard/somepath_where_you_have_write_access
echo `date +%s` `cat /sys/class/power_supply/bq27500-0/capacity` `cat /sys/class/power_supply/bq27500-0/time_to_empty_avg` >> battery.dat
then you need to make it executable with:
Code:
chmod a+x battery.sh
Also make sure that you have write access in place where you record the battery data.
Finally you need to add a crontab entry. Make a textfile that contains:
Code:
# min hr dom moy dow command
*/2 * * * * /the/path/to/your/script/battery.sh
and with this command
Code:
crontab /path/to/textfile
Code:
crontab -l
OK, so now you have recording up and running, you can check if your battery.dat file is getting filled with numbers.
At the end I have made a simple gnuplot script for plotting this data, but there is still lots of room for improvement here:
Code:
set xdata time
set format x "%H:%M"
set ytic 1
set grid
set ylabel "hours"
set y2label "battery %"
#set xlabel "hours"
set yr [0:25]
set y2r [0:100]
set y2tics
set pointsize 1.5
set key left bottom
plot '/media/SanDisk32GB/battery.dat' u ($1)$3/3600.0) title "expected hours" w lp, '/media/SanDisk32GB/battery.dat' u ($1)$2/4.0) title "battery %/4 (max 25)" w lp
pause -1
(just change your paths to battery.dat file)
to plot this on pandora you will need to install gnuplot, fortunately [/CODE]
Code:
opkg install gnuplot
will work. Maybe also gnuplot-nox (I forgot). This plot will squash whole battery history, so after a week it stopped being readable, but that's easy to fix so perhaps later I will post about that too - but anyway - first we need to have some recorded data, then we can worry about plotting it. But for now, with this script you can plot by calling:
[CODE]gnuplot that_script_above.gnuplot
So if you are interested in battery life - go setup your cron and start recording it!
EDIT: now setup cron with call "crontab texfile" - should make things simpler for everyone.
EDIT: added invocation to gnuplot, for plotting.
Last edited by a moderator: