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.

Luis Alvarado
  • 211,503

6 Answers6

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:

Jorge Castro
  • 71,754
jokerdino
  • 41,320
  • 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. – Luis Alvarado Apr 21 '12 at 02:24
8

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

Power Statistics screenshot

  • +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. – Luis Alvarado Apr 21 '12 at 02:14
  • Forgot to add that I tested without the power cable ^^. – Luis Alvarado Apr 21 '12 at 02:21
4

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

enter image description here

Bryce
  • 1,937
Ringtail
  • 16,127
  • 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 – Luis Alvarado Apr 18 '12 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. – Luis Alvarado Apr 18 '12 at 18:22
  • did you look at the link provided – Ringtail Apr 18 '12 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". – Luis Alvarado Apr 19 '12 at 00:21
  • http://www.lesswatts.org/projects/powertop/faq.php there are some kernel options listed that need to be enabled – Ringtail Apr 19 '12 at 02:14
  • Can I enable those options when loading the kernel (grub) or do I have to compile the kernel with the options enabled. – Luis Alvarado Apr 19 '12 at 14:38
  • apparently compiling is needed with the options enabled – Ringtail Apr 19 '12 at 14:47
  • This project doesnt seem to be active. The domain name has expired. – asheeshr Jun 14 '14 at 02:20
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.

Att Righ
  • 283
  • 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. – Luis Alvarado Jan 29 '17 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.

nem75
  • 1,669
  • 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. – Luis Alvarado Apr 25 '12 at 18:34
  • Ah, good to know. Guess I only tried it on calibrated systems. :) – nem75 Apr 26 '12 at 07:40
  • In Ubuntu 16.04 there is no longer a /proc/acpi/battery/ – Ulad Kasach Apr 28 '16 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 01 '17 at 19:16
1

Type sudo powertop in the terminal.

Chan-Ho Suh
  • 7,562