2

Just as the OP asked in the other question, I would like to have a battery threshold.

However, for me, when I type into the terminal

echo 80 | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold

I get a message in the terminal saying "Permission denied", even when I type "sudo" before "echo".

How can I still do it?

EDIT: I use Ubuntu 20.04 on a Dell Latitude 7390.

That's why I get in the terminal when I go to /sys/class/power_supply/

enter image description here

When I go into the folder BAT0, this is what I get:

enter image description here

Edit:

This is what I get when running smbios-battery-ctl --set-charging-mode custom.

enter image description here

6
  • I do not see a charge_control_end_threshold option for any of my notebooks, but I do see charge_stop_threshold, which does trigger the battery to stop charging when it reaches that level. Which version of Ubuntu and what kind of notebook are you using?
    – user1091774
    Feb 1, 2021 at 12:56
  • Hey Matigo, I edited my question. :) Unfortunately, ´charge_stop_threshold´ doesn't work either, still permission denied.. Feb 1, 2021 at 13:17
  • Hmm ... I just noticed that you have a comma at the end of your echo command. That's just a typo from copying here, I hope. Have you confirmed that you have a BAT0 location in /sys/class/power_supply/? Some installations report this as BATC or BATT ...
    – user1091774
    Feb 1, 2021 at 13:30
  • And another edit.. I hadn't typed the comma into the terminal, just into the main text. Feb 1, 2021 at 13:44
  • Okay, and one more request: what do you see inside the BAT0 directory? The "Permission denied" makes sense, as we cannot create files in these pseudo-directories. If your battery has a different set of feature descriptors, then they should appear when listing the contents of BAT0.
    – user1091774
    Feb 1, 2021 at 13:58

3 Answers 3

4
+50
  1. Download Dell Command Configure for Ubuntu 20.04 from here. Download link.

  2. Install according to this article

tar -xvzf command-configure_4.4.0-<Build Number>.<Ubuntu Version>_<architecture>.tar.gz

sudo dpkg -i srvadmin-hapi_9.3.0_amd64.deb

If the installation fails due to dependency problems, then run the following command to install all dependent packages from the Ubuntu repository: apt-get -f install

sudo dpkg -i command-configure_4.4.0-<Build Number>.<Ubuntu Version>_<architecture>.deb
  1. Enter the installed directory. cd /opt/dell/dcc

  2. Run sudo ./cctk --PrimaryBattChargeCfg=Custom:low-high (example: sudo ./cctk --PrimaryBattChargeCfg=Custom:50-70

Documentation on options

4
  • That's cool! Could you please also explain what the numbers low and high mean? Feb 8, 2021 at 13:21
  • low is the battery percentage you want to start charge at and high is the battery percentage you want to stop charge at. See the edit.
    – VidathD
    Feb 8, 2021 at 13:28
  • Is it also possible to undo this, so that's like before? I tried it out and I'm not really happy.. Feb 8, 2021 at 13:49
  • Yes it is possible. There are several options. Read --PrimaryBattChargeCfg in linked documentation. Did this not do what you wanted? What did you want then? BTW, you should also be able to change these from BIOS setup under power management. (Accessed by pressing F2 during post.)
    – VidathD
    Feb 9, 2021 at 9:52
2

Please read through the entire post. I am giving two possible solutions, plus one possible solution route (to be explored further if needed).

Solution 1

This thread mentions application cctk (Client Configuration Toolkit) specific for Dell.
Command cctk --PrimaryBattChargeCfg=Custom:50-70 might work.
CCTK was likely superseded by Dell Command | Configure, I am not sure if CCTK still works in some systems.

Solution 2

This thread refers to interaction between TLP and Dell. But official documentation shows battery thresholds for Dell cannot be controlled with TLP. At the bottom of the thread, it is shown that libsmbios could help, via
smbios-battery-ctl --set-custom-charge-interval low high
(with smbios-battery-ctl --set-charging-mode custom).

Another possible route

In my Lenovo, I have charge_start_threshold and charge_stop_threshold, not charge_control_start_threshold and charge_control_end_threshold. in /sys/class/power_supply/BAT0.

This old answer shows files start_charge_thresh and stop_charge_thresh in directory /sys/devices/platform/smapi/BAT0/ for a Lenovo.

So chances are the file names and/or directory should be different in your Dell. You might try all the same but with file names as charge_end_threshold, charge_stop_threshold, charge_control_stop_threshold instead, and follow up on the OP you linked.

Extra info

  1. This old thread mentions that if you set the thresholds in Windows, Linux will abide by them, although there is no way to change them from within Linux. I don't know if this workaround is useful for you, and the info is possibly outdated anyway.

  2. This mentions that
    For maximum lifespan when rarely using the battery, set Custom charge thresholds to start charging at 40% capacity and stop at 50%, and keep the ThinkPad cool. The thresholds can be adjusted in the Battery Maintenance settings of Lenovo Power Manager.
    If the battery is used somewhat frequently, set the start threshold at around 85% and stop at 90%. This will still give a good lifespan benefit over keeping the battery charged to 100%.

4
  • Hello, your first solution results in an error message ("cctk not found"), even though I downloaded the files from the following Dell website: dell.com/support/kbdoc/de-de/000178000/dell-command-configure But I had to download this file for Linux Ubuntu 18.04 (even though I use 20.04), because the one for 20.04 is not separately available!? Anyways, after having extracted the two debian files and installed them, I still get this error.. The second solution results in a strange terminal output, cf. my edited post. Feb 4, 2021 at 10:21
  • @MathIsFun - As for Solution 1, please post in your OP the complete set of steps you took to install cctk and run it. That is the sure way to guide you. As for solution 2, the same. Plus, 1) please do not add screen captures, but copy-paste the text, and format it as code block, 2) add whatever you looked for and found about the error received. Feb 4, 2021 at 11:26
  • @MathIsFun - Do you have any feedback? Feb 8, 2021 at 12:17
  • I am sorry, but I just hadn't had time to follow up.. Feb 8, 2021 at 13:20
0

With the help of a bunch of extra data and the Dell Latitude 7390 Owner's Manual, it looks like the BIOS is not configured to allow your battery to make use of some Advanced Power Management features such as charge_control_end_threshold and charge_stop_threshold.

The first clue was from the Permission denied error when setting charge_control_end_threshold, as we cannot add anything to /sys/class/ that does not already exist. When this same error appeared for charge_stop_threshold, it forced a rethink to determine whether the battery was called BAT0, BATT, or BATC (or BAT1 on a couple of Acer models). However, the final confirmation is seen with the output of the /sys/class/power_supply/BAT0/ pseudo-directory. These "files" are API interfaces when working with the battery, which is why we cannot add (or remove) any of them.

Unfortunately I do not have a Dell nearby to test this with but, according to the owner's manual, it may be possible to activate the features needed by tweaking a couple of settings in the BIOS.

Let's try this:

  1. Reboot the machine

  2. Enter the BIOS

    ⇢ Press F12 key when the Dell logo appears to access a boot menu with a list of the valid devices. Choose "Other Options" then enter "BIOS Setup"

  3. Find "Power Management"

  4. Find "Primary Battery Charge Configuration" and change the value to "Custom". As per the documentation:

    If Custom Charge is selected, you can also configure Custom Charge Start and Custom Charge Stop.

  5. Save the settings and boot back into Ubuntu

With this done, so long as your battery supports the ability to set (and display) charge thresholds, you should see charge_control_end_threshold and/or charge_stop_threshold in the /sys/class/power_supply/BAT0 location.

Hope this gives you what you're looking for 👍🏻

1
  • Hi Matigo, I followed your steps, and when I type /sys/class/power_supply/BAT0, I still cannot see charge_control_end_threshold and/or charge_stop_threshold.. :( I just booted into the BIOS again to make sure I had saved the settings with "Custom", but I had done so.. Maybe my battery just doesn't support it? My laptop is currently charging, and there were two values to choose from in the BIOS. The one was where it stops charging (which was set to $80$), and the other where it starts, I think, which was to $50$. That looks, doesn't it? Feb 1, 2021 at 19:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .