User Tools

Site Tools


thinkpad_battery_management

ThinkPad battery management

Most ThinkPad models since around 2011 or so support management of the battery charging system via software. Most wear of Li-ion and Li-polymer batteries is due to charging at battery levels above 80% or leaving them plugged in. (More reading: AccuBattery documentation.) Batteries will last many more charging cycles if you charge only up to 80% rather than up to 100%.

TLP is a toolkit that can handle power saving, including support for ThinkPad-specific battery management. More info: TLP website.

The following steps worked on a ThinkPad E490 to set battery 1's start threshold to 75% and stop to 80%. (Mint 19.1 (based on Ubuntu 18.04), with kernel 4.15.0-48)

apt install tlp git wget
wget https://github.com/teleshoes/tpacpi-bat/archive/master.zip
unzip -d /tmp master.zip && cd /tmp/tpacpi-bat-master && ./install.pl && cd -
cp /tmp/tpacpi-bat-master/tpacpi-bat /usr/local/bin

tpacpi-bat -s start 1 75
tpacpi-bat -s stop  1 80

The two tpacpi-bat commands need to be executed at reboot; you can create /etc/rc.local (permission 755) for that purpose.

For a T420 running arch:

pacman -S tp_smapi
echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 80 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh

Then you can create a script in /usr/sbin/, in this example called set_threshold:

#!/bin/sh
# set the battery charging thresholds to extend battery lifespan
echo ${2:-40} > /sys/devices/platform/smapi/BAT${1:-0}/start_charge_thresh
echo ${3:-80} > /sys/devices/platform/smapi/BAT${1:-0}/stop_charge_thresh

Make it executable and run set_threshold 0 96 100 Or run it with no arguments to default to BAT0, and thresholds of 40% and 80%. Create the systemd service in /etc/systemd/system/tp_smapi_set_battery_thresholds.service:

[Unit]
Description=Set Battery Charge Thresholds by tp_smapi
[Service]
Type=oneshot
ExecStart=/usr/sbin/set_battery_thresholds
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

And enable it: systemctl enable tp_smapi_set_battery_thresholds.service

You can also have it run when a battery is inserted (required acpid). Edit /etc/acpi/handler.sh:

# some ACPI code above
battery)
  case "$2" in
    BAT0)
      case "$4" in
        00000000)
        ;;
        00000001)
        /usr/sbin/set_battery_thresholds
        ;;
# some more ACPI code

Verify your settings:

cat /sys/devices/platform/smapi/BAT0/start_charge_thresh
cat /sys/devices/platform/smapi/BAT0/stop_charge_thresh

You can see the battery status (and other power management details) using tlp-stat.

More info: Arch Wiki tp_smapi

thinkpad_battery_management.txt · Last modified: 2020/02/25 04:33 by xilog