17

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
  • 216,643

7 Answers7

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
  • 73,717
jokerdino
  • 41,732
7

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

Power Statistics screenshot

4

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

enter image description here

Bryce
  • 2,007
Ringtail
  • 16,285
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
  • 285
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
1

Type sudo powertop in the terminal.

Chan-Ho Suh
  • 7,582
  • 4
  • 43
  • 74
0

My answer for the post Battery Monitor for Ubuntu ... contains a script and installation/configuration details to show the charging and discharging rates of the battery.

This displays a graphical dialogue at configured points showing the battery status as depicted in the picture below:

battery_discharging_notification_dialogue

The script notification_battery_discharge.sh has lines that write such information to a log file every minute. The lines currently in the script are commented out which we need to un-comment to log charging/discharging percentage at every minute. The script currently lacks a mechanism to check the size of the log, and log rotation in case the log file becomes very large.

Uncomment the writes to the log files so that the lines look like:

echo "$(date +%H:%M:%S) :: Discharging :: __RATE_OF_DISCHARGE_PER_MIN=$__RATE_OF_DISCHARGE_PER_MIN , __RATE_OF_DISCHARGE_PER_HOUR=$__RATE_OF_DISCHARGE_PER_HOUR" >> "$__FILE_LOG"

and,

echo "$(date +%H:%M:%S) :: Charging    :: __RATE_OF_CHARGING_PER_MIN=$__RATE_OF_DISCHARGE_PER_MIN , __RATE_OF_CHARGING_PER_HOUR=$__RATE_OF_DISCHARGE_PER_HOUR" >> "$__FILE_LOG"

A portion of the log for my device looks like:

14:24:47 :: Charging    :: __RATE_OF_CHARGING_PER_MIN=.538 , __RATE_OF_CHARGING_PER_HOUR=32.307
14:25:47 :: Charging    :: __RATE_OF_CHARGING_PER_MIN=.571 , __RATE_OF_CHARGING_PER_HOUR=34.285
14:26:47 :: Charging    :: __RATE_OF_CHARGING_PER_MIN=.533 , __RATE_OF_CHARGING_PER_HOUR=32.000
14:27:47 :: Charging    :: __RATE_OF_CHARGING_PER_MIN=.500 , __RATE_OF_CHARGING_PER_HOUR=30.000
14:28:47 :: Charging    :: __RATE_OF_CHARGING_PER_MIN=.529 , __RATE_OF_CHARGING_PER_HOUR=31.764
14:29:47 :: Discharging :: __RATE_OF_DISCHARGE_PER_MIN=0 , __RATE_OF_DISCHARGE_PER_HOUR=0
14:30:47 :: Discharging :: __RATE_OF_DISCHARGE_PER_MIN=0 , __RATE_OF_DISCHARGE_PER_HOUR=0
14:31:47 :: Discharging :: __RATE_OF_DISCHARGE_PER_MIN=.500 , __RATE_OF_DISCHARGE_PER_HOUR=30.000
14:32:47 :: Discharging :: __RATE_OF_DISCHARGE_PER_MIN=.333 , __RATE_OF_DISCHARGE_PER_HOUR=20.000
14:33:47 :: Discharging :: __RATE_OF_DISCHARGE_PER_MIN=.250 , __RATE_OF_DISCHARGE_PER_HOUR=15.000
14:34:47 :: Discharging :: __RATE_OF_DISCHARGE_PER_MIN=.400 , __RATE_OF_DISCHARGE_PER_HOUR=24.000
14:35:47 :: Discharging :: __RATE_OF_DISCHARGE_PER_MIN=.333 , __RATE_OF_DISCHARGE_PER_HOUR=20.000

(The log could show current battery percentage and date, but I chose not to.)

When the status toggles between charging/discharging, for a couple of minutes, a garbage charging/discharging message gets logged (and displayed in the dialogue) which is a shortcoming. The rates gets more accurate as time passes.

rusty
  • 16,917