this post was submitted on 20 Aug 2023
40 points (100.0% liked)

Linux

48413 readers
1102 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Hello folks, is there a tool in Linux to track how much current the battery is pulling during charging? In Android there is Ampere that does this, and I'm looking for something similar. This nicely shows for example that my Android device is charging the battery with 1.5A right now.

top 15 comments
sorted by: hot top controversial new old
[–] [email protected] 16 points 1 year ago

The voltage, state and current draw and other cool stuff can usually be found from /sys/class/power_supply/BAT0/ you just have to make a small script to calculate what you need from that. This requres some knowledge, but it's one way to do it.

[–] [email protected] 11 points 1 year ago (1 children)

powertop shows discharge rate in W, Joules consumed since last charging and estimated remaining time in the "Overview" pane.

[–] [email protected] 4 points 1 year ago

powertop

awesome, thanks!

[–] [email protected] 6 points 1 year ago (1 children)

I am not sure, but maybe upower could be useful. upower -d will dump all available information.

[–] [email protected] 2 points 1 year ago (1 children)

This is exactly it, thanks! It doesn't show the current, but it shows the voltage and the power and it can be calculated from it.

[–] [email protected] 7 points 1 year ago (1 children)

Pro tip: Add an alias for it into your .bashrc to nicely view battery level in TTY. In my case I did alias battery='upower -i /org/freedesktop/UPower/devices/battery_BAT1 | grep -wE "percentage:|time to empty:|state:|energy:|energy-rate:|voltage:" which shows me this:

Direct image link

[–] [email protected] 2 points 1 year ago

very nice, thanks!

[–] [email protected] 3 points 1 year ago (1 children)

What DE are you using? Gnome and cinnamon have extensions for it

[–] [email protected] 1 points 1 year ago

do you know what they are calling in the backend?

I use XFCE

[–] HMitsuha 3 points 1 year ago

i use lm-Sensors because it also shows temperature data, which is useful for what I do.

[–] [email protected] 2 points 1 year ago (1 children)

This data is available in the sysfs, I'm not aware of any apps that make use of it sadly

[–] [email protected] 3 points 1 year ago

apparently powertop does.

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (2 children)

If a battery is rated at 4amph and it is 99% discharged (dead), and it takes 4hr to fully charge then it is charging at 1amp/h, at 2amph it would charge in 2hrs. Why do you actually want to know the number of Amps passing through? It may further confuse you if you read your charger is rated at 2amph and is only charging at 1.7amps

2amps at 5V = 10W, and 4amph of 4.4V = 17..6Wh

acpi vattery battctl can all provide some relevant info, but basically it is simple formulas of volt x amp x time = power/Wh measurements. The software may actually confuse you more as things in charging, discharginj and rates are not very linear and understood outside physics and practical electronics.

For example, some software will tell you your battery is at 0, when in fact the battery may be 18% charged. A battery for example rated at 4.4V may actually show 4.6 when fully charged, When it begins to fall off given the load it is presented by the machine, the voltage may drop below a threshold the manufacturer considers safe, say 4.1V, and therefor the machine shuts down.

Take the battery out and measure it and it shows 4.38V but give it a load, say a small 4-5V light bulb (a resistance) and it drops to 4.05V. Plug the charger on and measure it, it shows 5.0V Weird? No, this is how it works, car, motorcycle, e-bike, laptop or vaper. A 12V battery for a car that unplugged shows 12V, it is nearly dead. A tiny moped battery may show 12.6V, if you try to crank a V8 engiine with it will drop to 0.4V and it would stilll be pretty well charged, for the moped. A 12.3V from a boat may crank that V8 car engine like when it was new. + You have a large tank of 200lit and at the bottom through a pipe you measure 5psi, you have a little tank with 4.1psi, you connect them and there is flow, till the flow stops from the large tank to the little one and both have 4.6psi, no flow. Exchange psi for V and this is what a charger does. Take 5 lit off of the large tank, it still shows 4.59V, take the same from the little tank and it drops to 3.9V/psi. A boat 100amph battery can charge many 4.4V batteries at little loss, and the transfer works just like tanks equalizing each other through pressure in the transfer pipe.

Practical:

If a battery shows as fully charging at very little time and lasts very little time is either on a machine with a short or the battery is dead. Fast charging is never as good as slow low rate charging, because: Fast charging tends to heat up the battery, when the battery gets hot it gives a false reading of higher voltage telling the charger it is full, when if you let it cool, it may take more charge. Trickle charging is best, charge, pause, recharge, pause, recharge, at lower rates keeping the battery cool.

[–] [email protected] 4 points 1 year ago

I'm testing multiple different cables, so I would love to see what current they are drawing.

[–] [email protected] 1 points 1 year ago

Battery: dead --> 2 senarios 1 Battery shows the right voltage but can't retain much charge, the voltage drops right away with a small load. 2 Battery can still have capacity to be charged but never reaches the required voltage.

In both cases, 2 separate reasons for battery problem, the battery is useless for what is needed.