16

Maybe this question was made earlier but I can't find it. I want to see a terminal command or gui program that can show me the discharge rate of the battery. What hardware parts or programs are using more watts.

EDIT: Found additional information regarding my question when using for example PowerTop:

https://bbs.archlinux.org/viewtopic.php?id=128319

https://bugs.archlinux.org/task/26416

Both related to the having disable ACPI_PROCFS_POWER in the kernel.

6 Answers 6

9

You can try powerstat, which gives you the watts used over a period of 5 minutes. To install it, try the following commands:

sudo apt-get install powerstat

Or you can try the power-usage-report, which I guess, depends on fatrace and powertop.


Linked Question:

1
  • This indeed showed the Watt usage. I am hoping that powertop or the Gnome power window will have easier to read information on 12.04 about this. Very useful. Thank you jokerdino. Apr 21, 2012 at 2:24
8

Maybe you're looking for "Rate" in Power Statistics > Laptop battery > Details?

Power Statistics screenshot

2
  • +1. Thank you WarriorIng64. Although in my case the rate always shows 0.0W. So I have never paid attention to it. But nevertheless very good point there. Going to see on 12.04 if it works correctly when it comes out. The laptop is an HP DV6000. Apr 21, 2012 at 2:14
  • Forgot to add that I tested without the power cable ^^. Apr 21, 2012 at 2:21
4

"Linux Power Top" may help (currently available from https://01.org/powertop )

enter image description here

8
  • But how are you getting the "Power Usage (ACPI estimate): 14.1W". I am only getting percentages and values I can't relate to watt usage. My version is 1.97 Apr 18, 2012 at 17:25
  • Ok going out of my mind here. Haven't found an option to show me what you are showing me in that image. I would be awesome if I could directly see the power usage like that. Even better if I could output that, you know, as a variable for a program or something. Apr 18, 2012 at 18:22
  • did you look at the link provided
    – Ringtail
    Apr 18, 2012 at 22:57
  • 1
    Yeah which shows the same image as yours but there is nothing that says "Hey use this parameter or change this option in the config file to see the power usage". Apr 19, 2012 at 0:21
  • lesswatts.org/projects/powertop/faq.php there are some kernel options listed that need to be enabled
    – Ringtail
    Apr 19, 2012 at 2:14
4

Linux is in the process of removing things that used to live in proc and putting them in sysfs (a highly structured filesystem for keeping information about the machine).

On my machine, I can find information about the power supply in

/sys/class/power_supply/BAT0

This has a current rate file which keeps the charging rate:

So the following gives you an approximation of the charging rate.

calc \( $(cat charge_full) - $(cat charge_now) \) / $(cat current_now)

calc comes from the apcalc package.

If you want better rate you might be better looking at how charge_now changes over time.

You might also be interesting in looking at this realtime graph

while true; do cat current_now; sleep 1; done | feedgnuplot --stream  --line  --ymin 0

To get a feeling of how charge rate is changing over time. I can cause nice juddering drops in charge rate by quickly switching between desktops.

1
  • I have bookmarked this question to check on your answer. I will be buying a laptop soon and wanted to verify this with your answer which seems pretty awesome. Jan 29, 2017 at 23:17
2

You can see the current discharge rate of your battery without any additional tools. Open a terminal with Ctrl+Alt+T and enter this:

ls /proc/acpi

This gives you something like this:

BAT1

Now enter this command, substituting BAT1 if necessary:

cat /proc/acpi/battery/BAT1/state

You will get output similar to this:

present:                 yes
capacity state:          ok
charging state:          charged
present rate:            0 mA
remaining capacity:      3395 mAh
present voltage:         12393 mV

The present rate line is what your looking for (my PSU is plugged in right now, so the discharge rate is zero).

If you want to see how the rate changes, e.g. per second, do this:

watch -n 1 cat /proc/acpi/battery/BAT1/state

This gives your the output from above, but refreshed every 1 second. Terminate with Ctrl+c.

4
  • Thank you nem75 but that was already tried and it was not showing the correct rate in my tests. Plugged or unplugged it would say the same 0 mA. The one that jokerdino mentioned worked. Anyway I also did a full 16 hour recalibration to be 100% sure and it fixed the problem for the way you are mentioning here (which is the one I use) and every other way mentioned here. Apr 25, 2012 at 18:34
  • Ah, good to know. Guess I only tried it on calibrated systems. :)
    – nem75
    Apr 26, 2012 at 7:40
  • In Ubuntu 16.04 there is no longer a ` /proc/acpi/battery/` Apr 28, 2016 at 18:09
  • I see the same structure under /sys/class/power_supply (ACAD and BAT1 are present). Useful: find /sys/class/ -regex ".*BAT[0-9]*", find /sys/class/ -regex ".*AC.*", etc. Acpitool may help as well.
    – John P
    Feb 1, 2017 at 19:16
1

Type sudo powertop in the terminal.

1
  • Yes but I can not see anywhere something that tells me how much is been consumed. Apr 18, 2012 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .