suggestions for power/battery consumption data logger for community to compare?
#1
Hi, everyone!

biketool got me thinking about this: is there a LINUX utility that can do the following:

a) log battery level over time (datalogger functionality for graphing)
b) log which processes or hardware modules (especially the modem) are consuming what power, in milliwatts
c) show power-related settings, especially those that might alter the power consumption

The primary objectives are:

1) to allow the PINE64 community to objectively compare their own experiences for the purpose of sharing settings, tips, tricks, and diagnoses to maximize battery life. There are too many variables to consider when comparing battery life, such as screen brightness, modem clock speed, settings, usage patterns, cell signal strength. With a datalogger we could see, for instance, that someone who complains about awful battery life might have a specific setting that's set wrong, or that someone else with awful battery life has a process that keeps waking the phone up, or that someone with fantastic battery life runs their screen brightness at the dimmest setting all the time, etc.

2) to improve LINUX distros' power optimization for the PinePhone and PinePhone Pro over time


PowerTOP can do b) and c), but I don't think it can do a) without having a serial-attached external datalogger.

It's probable that PINE64 has some kind of internal tool that profiles power/battery consumption as they design their hardware. If that exists and we can use it, that would be great.

If not, which 3rd party open-source LINUX tools are closest to fulfilling the objectives?

I'll search online, but if anyone knows already what tools to use, please share here. Thanks!
  Reply
#2
I'm new to PPP and am very interested in understanding the power usage of the device in order to optimize it. A simple way to log power usage is to run this in the console:

Code:
cat /sys/class/power_supply/rk818-battery/*_now

This will show the current going in/out the battery in microamps (negative for discharging, positive for charging) and the battery millivolts. You can put that into a "while" loop with a "sleep" to periodically log this to a file. However, bear in mind that during logging, the CPU is awake and working, so you won't get a true representation of whats the idle power draw is.

I'm busy porting FreeBSD to the PPP (see https://codeberg.org/Honeyguide/freebsd-pinephonepro ) and wrote the driver for the battery charger, and was trying to figure out how the Linux driver works out the state-of-charge, because the rk818 chip doesn't seem to provide it. 

My preliminary testing shows that perhaps the state-of-charge calculation in the Linux driver is not accurate, and it might be leaving usable battery capacity on the table (e.g. when it says 5% remaining, there may actually be quite a lot more actual capacity left). I'll spend some time checking if the the millivolts/microamps figures match actual battery measurements on my device, and whether the state-of-charge is indeed inaccurate. If it is, this might explain part of the battery woes that seem to afflict this device.
  Reply
#3
I did some battery testing on my phone using the logging method above. Conditions:
  • Pinephone Pro with Megi's U-boot bootloader and running PostmarketOS 24.12 Phosh
  • Battery fully charged
  • SIM card inserted and connected, WiFi enabled

I then used the phone for a bit and ran a YouTube video in Firefox at 360p. After starting the YouTube video, battery went from about 78% to 5% in about 30 minutes! I periodically manually logged the battery state and the output is below. From this output it looks like the battery capacity is under-reading when the phone is loaded (by YouTube playback in this instance) since the actual battery voltage isn't dropping anywhere near as fast as the stated capacity:

Code:
~ $ cat /sys/class/power_supply/rk818-batte
ry/*_now && cat /sys/class/power_supply/rk8
18-battery/capacity && date
-792000
3762000
78
Tue Dec 31 12:22:04 SAST 2024
~ $ cat /sys/class/power_supply/rk818-batte
ry/*_now && cat /sys/class/power_supply/rk8
18-battery/capacity && date
-933000
3679000
71
Tue Dec 31 12:28:31 SAST 2024
~ $ cat /sys/class/power_supply/rk818-batte
ry/*_now && cat /sys/class/power_supply/rk8
18-battery/capacity && date
-810000
3717000
62
Tue Dec 31 12:32:09 SAST 2024
~ $ cat /sys/class/power_supply/rk818-batte
ry/*_now && cat /sys/class/power_supply/rk8
18-battery/capacity && date
-801000
3678000
47
Tue Dec 31 12:37:50 SAST 2024
~ $ cat /sys/class/power_supply/rk818-batte
ry/*_now && cat /sys/class/power_supply/rk8
18-battery/capacity && date
-1313000
3548000
25
Tue Dec 31 12:43:54 SAST 2024
~ $ cat /sys/class/power_supply/rk818-batte
ry/*_now && cat /sys/class/power_supply/rk8
18-battery/capacity && date
-1138000
3616000
14
Tue Dec 31 12:47:24 SAST 2024
~ $ cat /sys/class/power_supply/rk818-batte
ry/*_now && cat /sys/class/power_supply/rk8
18-battery/capacity && date
-855000
3613000
5
Tue Dec 31 12:52:09 SAST 2024
~ $ cat /sys/class/power_supply/rk818-batte
ry/*_now && cat /sys/class/power_supply/rk8
18-battery/capacity && date
-834000
3552000
5
Tue Dec 31 12:52:29 SAST 2024

I shut down the phone at 5%, let the battery rest for an hour, then tested the actual voltage on the battery: 3.82V, which equates to around 50% capacity! So while the phone thinks it's at 5%, in actual fact it's at 50%, which is a huge discrepancy. I left the phone off overnight (which seems to reset the battery meter), then plugged in the battery this morning, and the phone now shows 50% battery capacity, even though I didn't charge it!

TLDR; the phone's battery capacity meter is wonky so don't trust it, and we may actually be able to get a lot better battery life if this is fixed.
  Reply
#4
(12-22-2024, 04:48 PM)dchang0 Wrote: Hi, everyone!

biketool got me thinking about this: is there a LINUX utility that can do the following:

a) log battery level over time (datalogger functionality for graphing)
b) log which processes or hardware modules (especially the modem) are consuming what power, in milliwatts
c) show power-related settings, especially those that might alter the power consumption

The primary objectives are:

1) to allow the PINE64 community to objectively compare their own experiences for the purpose of sharing settings, tips, tricks, and diagnoses to maximize battery life. There are too many variables to consider when comparing battery life, such as screen brightness, modem clock speed, settings, usage patterns, cell signal strength. With a datalogger we could see, for instance, that someone who complains about awful battery life might have a specific setting that's set wrong, or that someone else with awful battery life has a process that keeps waking the phone up, or that someone with fantastic battery life runs their screen brightness at the dimmest setting all the time, etc.

2) to improve LINUX distros' power optimization for the PinePhone and PinePhone Pro over time


PowerTOP can do b) and c), but I don't think it can do a) without having a serial-attached external datalogger.

It's probable that PINE64 has some kind of internal tool that profiles power/battery consumption as they design their hardware. If that exists and we can use it, that would be great.

If not, which 3rd party open-source LINUX tools are closest to fulfilling the objectives?

I'll search online, but if anyone knows already what tools to use, please share here. Thanks!

I would suspect much of the problem could be solved using the hardware acceleration hardware present in the chipset.  Perhaps also utilizing the low rez mode on the screen when not needed.  For example clapper video app seems to heat up the PPp about as much as idling with the screen active/unlocked, it is one of the only apps with the correct hardware acceleration compiled into the app itself rather than the OS.  Almost everything else including the OS itself using CPU fallback.  Most of the time all but one smaller CPU should be powered down.  a study into how android and apple save power would be appropriate or even reviewing power savings including freezing unfocused apps unless specifically permitted would help.  The Nokia N900/Maemo had a hardware abstraction layer, think of it as an API to abstract the hardware even though there was only one target device for the distro, this is ideal fr Pine librem and other android-first targets for the various mobile distros.
It is pretty clear that fixing power consumption has come a way with help from one dev especially, Megi(now retired); but is is also still by foar the most glaring problem with using the PP and PPp for any amount of time with the USB power unplugged.  Less than 2 hours from 100% to battery empty shutdown with screen locked just listening to audiobook?!?! unacceptable for a real mobile device.
  Reply
#5
(Yesterday, 03:16 AM)biketool Wrote: Megi(now retired)
Huh? Since when?
  Reply
#6
(8 hours ago)Kevin Kofler Wrote:
(Yesterday, 03:16 AM)biketool Wrote: Megi(now retired)
Huh? Since when?

https://xnux.eu/log/
last submission 2024-02-28 Support for WiFi on QuartzPro64 
we need more devs who really understand embedded and mobile hardware in an era where our desktop hardware has so much memory, disk, processing, and total electricity to burn.  
I wasn't so skilled but I remember people using straigh machine language vs the built in basic to program for stuff like the zilog z-80 cheap computers of the time in order to cram in more program into the 16 or upgraded 32 kilobytes(32000x8 binary bits) of system memory.
<edit - CORRECTION>
https://codeberg.org/megi/linux
Megi was working on kernel 6.11 last month, but still seems to have backed off from epic level pine64 related development.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PinePhone Pro battery life at the beginning of 2023? dante404 14 11,556 06-03-2023, 07:45 AM
Last Post: crocspot
  Unofficial Pinephone Battery Case lllsondowlll 15 19,295 02-21-2023, 10:34 AM
Last Post: Yaky
  [Solved] Connect PPP to PC via USB for data transfer ? libresurf 1 1,600 09-20-2022, 12:31 PM
Last Post: libresurf
  Would disabling all cpu's except one save power on the PPP? rp3 3 2,725 08-27-2022, 01:10 AM
Last Post: uzanto
Information Fix PinePhone Pro when unable to boot due to drained battery butjar 7 7,611 05-21-2022, 01:24 PM
Last Post: 98cwitr
  Battery Life is it possible?? Tech Question (sort of) scrwbigtek 4 4,199 05-11-2022, 06:01 AM
Last Post: danimations
  Power issue with the Pro Freitag 13 8,710 04-25-2022, 06:14 AM
Last Post: LPIZ
  Less than 12 hours on battery - doing nothing tcoulon 8 6,254 04-23-2022, 02:00 AM
Last Post: fxc
  No mobile data access on PPP henrythemouse 5 3,880 04-16-2022, 06:40 PM
Last Post: henrythemouse
  Pinephone Battery doesn't fit in the Pinephone Pro ragreenburg 2 2,329 03-25-2022, 09:21 AM
Last Post: ragreenburg

Forum Jump:


Users browsing this thread: 2 Guest(s)