• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

Limit battery charge level with kernel

Search This thread

dic1911

Senior Member
Feb 22, 2014
809
801
dic1911.github.io
Google Pixel 4a 5G
DISCLAIMER: I'm not responsible if your battery or phone ever borked due to you used the commands in this post!

Just found out that there's "parameter" in /sys for limiting battery charging behavior, which probably works just like "battery charge limit"
Obviously this requires root, if you have no idea what is this for and why, read this first

As I'm no pro here, I'm just sharing what I found out, and the method may not be 100% reliable as ACC (the Magisk module, which currently somehow doesn't want to work on my 4a 5G)

Note that the following commands may not work due to you're running different kernel

To make your phone stop charging after reaching 80%, run the following command:
# echo 80 > /sys/devices/platform/soc/soc:google,charger/charge_stop_level

You can use cat against /sys/devices/platform/soc/soc:google,charger/charge_disable to check if your phone had stopped charging.

There's charge_start_level as well, I guess that the phone will start charging again after your battery level drops to the level that this "parameter" specifies, but I don't really leave my phone plugged in that long so I'll leave that for you guys to test it.

PS. I don't know why but this method may only work once for one boot, in other words, you need to reboot the phone for this method to be effective when you charge again.
Edit: it worked more than once for me now.
 
Last edited:

FooYoungHi

Member
Oct 11, 2014
36
3
Since it's been a few months since this phone is out; are there apps that can do this yet? I run CalyxOS and can't root. This feature is #1 on my wishlist for a CalyxOS update.
 

zlamar

Senior Member
Nov 9, 2011
102
13
Mars
On Pixel 4a 5g control file that works for me is sm7250_bms/charge disable and Automatically cycle through switches is ON. I've installed ACC through Termux from downloaded github zip, thren I've installed AccA from F-droid and disabled ACC module in Magisk. And it works, it stops charging, in my case, at 85 % .
Maybe it's worth to mention that I'm on LineageOS for microG 18.1, Proton kernel 1.4, Magisk rooted.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 6
    DISCLAIMER: I'm not responsible if your battery or phone ever borked due to you used the commands in this post!

    Just found out that there's "parameter" in /sys for limiting battery charging behavior, which probably works just like "battery charge limit"
    Obviously this requires root, if you have no idea what is this for and why, read this first

    As I'm no pro here, I'm just sharing what I found out, and the method may not be 100% reliable as ACC (the Magisk module, which currently somehow doesn't want to work on my 4a 5G)

    Note that the following commands may not work due to you're running different kernel

    To make your phone stop charging after reaching 80%, run the following command:
    # echo 80 > /sys/devices/platform/soc/soc:google,charger/charge_stop_level

    You can use cat against /sys/devices/platform/soc/soc:google,charger/charge_disable to check if your phone had stopped charging.

    There's charge_start_level as well, I guess that the phone will start charging again after your battery level drops to the level that this "parameter" specifies, but I don't really leave my phone plugged in that long so I'll leave that for you guys to test it.

    PS. I don't know why but this method may only work once for one boot, in other words, you need to reboot the phone for this method to be effective when you charge again.
    Edit: it worked more than once for me now.
    1
    AccA only works on the 4a 5G when using a custom kernel such as protonkernel or elementalx. The stock kernel doesn't have the right switches.