[PLUG] battery voltage monitor

Russell Senior seniorr at aracnet.com
Mon Jan 3 23:48:58 UTC 2011


>>>>> "Denis" == Denis Heidtmann <denis.heidtmann at gmail.com> writes:

Denis> Thanks, Russell.  There is a file there named voltage_now,
Denis> which seems to hold a recent voltage.  What system decides when
Denis> to update that file?  Can I interrogate whatever writes that
Denis> file to get more frequent updates? BAT0 is a link to BAT0 ->
Denis> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/PNP0C0A:00/power_supply/BAT0,
Denis> for whatever that is worth.

The /sys filesystem is a userspace view of various kernel values. For
more information about sysfs, see:

  http://en.wikipedia.org/wiki/Sysfs

So, however often the kernel updates the battery information, that's
how often the value in BAT0 updates.  From a shell, you can run:

  watch -n 1 cat /sys/class/power_supply/BAT0/voltage_now

to get an idea how fast it is updating.  It appears to be every few seconds.

There are some other interesting values in
/sys/class/power_supply/BAT0 too.  Figuring out what units they are
using can sometimes be a challenge.


-- 
Russell Senior         ``I have nine fingers; you have ten.''
seniorr at aracnet.com



More information about the PLUG mailing list