laptop battery discharge / logging

laptop battery discharge / logging

  • Written by
    Walter Doekes
  • Published on

I recently got a new Framework Laptop. It is generally nice. Apart from the reflective screen, and the excessive battery consumption.

In suspend mode, it draws too much battery: more than a Watt. This is a known issue. The worst offenders are the expansion cards. For instance the USB-A cards consume about 350mW each, just by being plugged in.

To do some testing, I whipped up a script allowing easy access to battery usage logs: discharge-log

Place it in /usr/lib/systemd/system-sleep with execute permissions.

It will log usage before going into sleep and after waking up. This allows for easy testing of various configurations of expansion cards. The values look like this:

# journalctl -o cat -t discharge-log -b0 --grep dT | tail -n1
(sleep) dT = 362 (s), dQ = -9 (mAh) = 138 (mWh), rate = 0 (plmpt), rate/h = 0 (plmpt/h), dE = -542 (J), P = -1498 (mW)

One can run it manually too:

$ /usr/lib/systemd/system-sleep/discharge-log begin
$ /usr/lib/systemd/system-sleep/discharge-log show '(testing charge)'
(testing charge) dT = 185 (s), dQ = 32 (mAh) = 561 (mWh), rate = 10 (pmlpt), rate/h = 194 (pmlpt/h), dE = 2019 (J), P = 10916 (mW)
$ /usr/lib/systemd/system-sleep/discharge-log begin
$ /usr/lib/systemd/system-sleep/discharge-log show '(testing discharge)'
(testing discharge) dT = 314 (s), dQ = -50 (mAh) = -854 (mWh), rate = -15 (pmlpt), rate/h = -171 (pmlpt/h), dE = -3074 (J), P = -9791 (mW)

(The plmpt values are promille-points.)

Ejecting all (non USB-C) cards leaves us with a battery usage of about 400mW. Still steep, but a lot better than a Watt. In my tests — with 2023-07 firmware and a Linux 6.1 kernel (linux-oem-22.04c) — deep versus s2idle sleep did matter a lot: I could leave the USB-A cards connected (with one mouse dongle) and get about 520mW discharge rate with s2idle; a clear winner.


Back to overview Newer post: mariadb / gdb / debugging shutdown deadlock / part 1 Older post: viewing unencrypted traffic / ltrace / bpftrace