How to adjust charging thresholds of laptop battery?
Newer Lenovo ThinkPads (such as my E540) are not compatible with tp_smapi-dkms. Fortunately I found that the TLP utility can use either of two different modules -- the tp_smapi OR the thinkpad_acpi DKMS modules -- to communicate the thresholds to the battery.
Nowadays TLP is available via standard Ubuntu or Debian repositories. (Though you may benefit from the latest version available using TLP website to install the packages.)
After installing TLP, set the battery charge thresholds using two lines in the configuration file /etc/default/tlp
START_CHARGE_THRESH_BAT0=65
STOP_CHARGE_THRESH_BAT0=80
This example tells TLP to set the battery thresholds to start charging at 65% and stop charging at 80%. I find that the thresholds persist correctly even when booting into a different OS that doesn't have TLP installed. (Though I presume if you booted into Windows or another OS that DOES have power management tools installed, that OS might overwrite the previously set charge thresholds.)
To TEMPORARILY bring the battery to a full charge, issue the following terminal command:
$ sudo tlp fullcharge
The battery will then charge to its maximum capacity, and revert to the previous thresholds afterwards.
Note: If your laptop is not a "ThinkPad," TLP probably cannot set your battery charge levels. If your vendor supplies a power management utility for Windows, you can probably boot using some form of Windows to set the battery charge levels and then reboot into linux. In my experience, the battery charge threshold settings persist after system reboots.
You need to install tp_smapi-dkms
, just do
apt-get install tp_smapi-dkms
When finished, use lsmod | grep tp_smapi
to check if module is loaded, to adjust the charge thresholds, do something like this
echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 60 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
Add these lines to /etc/rc.local
to run them at boot.
This module works at least on X220.
On my laptop (Yoga 260) I had to get acpi-call-dkms, which provides the acpi_call kernel module:
sudo apt install tlp acpi-call-dkms
sudo tlp setcharge 40 60 #set the start and stop thresholds to 40% and 60%
Output of sudo tlp stat -b
:
--- TLP 1.1 --------------------------------------------
+++ ThinkPad Battery Features
tp-smapi = inactive (unsupported hardware)
tpacpi-bat = active
+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/class/power_supply/BAT0/manufacturer = SMP
/sys/class/power_supply/BAT0/model_name = 00HW027
/sys/class/power_supply/BAT0/cycle_count = (not supported)
/sys/class/power_supply/BAT0/energy_full_design = 44000 [mWh]
/sys/class/power_supply/BAT0/energy_full = 37970 [mWh]
/sys/class/power_supply/BAT0/energy_now = 18910 [mWh]
/sys/class/power_supply/BAT0/power_now = 0 [mW]
/sys/class/power_supply/BAT0/status = Unknown (threshold effective)
tpacpi-bat.BAT0.startThreshold = 40 [%]
tpacpi-bat.BAT0.stopThreshold = 60 [%]
tpacpi-bat.BAT0.forceDischarge = 0
Charge = 49.8 [%]
Capacity = 86.3 [%]