Script to control Nexus 10 charge between 35%-55%

Search This thread

esprout

Member
Nov 25, 2014
48
18
According to battery university, the optimal charge level for storage is 40%, and it's best to limit your depth of discharge as much as possible. Thinkpads have had a function to do just that, with the excellent tp_smapi module enabling the functionality under Linux.

I turns out Nexus 10 with OmniROM has a way to disable charging even when the AC power is plugged in via the file /sys/devices/virtual/power_supply/manta-battery/charge_enabled. I've created a script that uses this functionality to keep charge between 35%-55%. You can modify STOPLIMIT and STARTLIMIT to with desired charge levels. You can optionally create /data/local/etc/battery/STOPLIMIT and /data/local/etc/battery/STARTLIMIT and put the values in there. Those values would override the values in the script.

I start the service with 3C Toolbox Pro with a script that calls

Code:
su -c /data/local/bin/charge_control.sh &

Requirements:

Device: Nexus 10
ROM: OmniROM HOMEMADE20141102
Rooted
busybox installed

The ROM can be found in this thread: http://xdaforums.com/showthread.php?t=2705229

It may work under other configurations, but above is the configuration I've tested it under. Battery university reference: http://batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries
 

Attachments

  • charge_control.zip
    783 bytes · Views: 178
Last edited:

esprout

Member
Nov 25, 2014
48
18
Expected increase in battery longevity

Battery longevity (to 80% original life) should increase from under 1 year to over 5 years by using this script. More below.

The battery university article indicates the battery will last from 300-500 cycles with a full depth of discharge, and 150-250 cycles with maximum charge voltage of 4.3V. The Nexus 10 does charge with very high voltages above 4.3V to get the battery to 100% charge. That means your battery will last less than a year in the most extreme cases. For example, your battery will have 80% capacity after 300 days if you do a full charge every other day with 4.3V. My device reached the 80% battery life cycle in about 1 year, and then got progressively and rapidly worse, until I replaced the battery with 40% original life after 20 months.

With this script, battery life should increase to 1200-2500 cycles between 25%-50% depth of discharge, and 1200-2000 cycles with battery voltage limited to under 4V at full charge. So battery life should increase to 6.5 years up to over 13 years charging it up to 55% every day!
 

mymusicathome

Senior Member
Dec 4, 2011
633
145
I have had this tablet since release and always plug it into the charger when going to sleep. I typically use the device from 100% to 60% each day. This device is over 2 years old now and still has the same screen on time each charge cycle as day one.

Thanks for sharing.
 

omgi0wn

Senior Member
Jun 18, 2010
228
9
According to battery university, the optimal charge level for storage is 40%, and it's best to limit your depth of discharge as much as possible. Thinkpads have had a function to do just that, with the excellent tp_smapi module enabling the functionality under Linux.

I turns out Nexus 10 with OmniROM has a way to disable charging even when the AC power is plugged in via the file /sys/devices/virtual/power_supply/manta-battery/charge_enabled. I've created a script that uses this functionality to keep charge between 35%-55%. You can modify STOPLIMIT and STARTLIMIT to with desired charge levels. You can optionally create /data/local/etc/battery/STOPLIMIT and /data/local/etc/battery/STARTLIMIT and put the values in there. Those values would override the values in the script.

I start the service with 3C Toolbox Pro with a script that calls

Code:
su -c /data/local/bin/charge_control.sh &

Requirements:

Device: Nexus 10
ROM: OmniROM HOMEMADE20141102
Rooted
busybox installed

The ROM can be found in this thread: http://xdaforums.com/showthread.php?t=2705229

It may work under other configurations, but above is the configuration I've tested it under. Battery university reference: http://batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries

Could you point me in the right direction so that I could run this script? I'm on Dirty Unicorns ROM.
 

esprout

Member
Nov 25, 2014
48
18
Could you point me in the right direction so that I could run this script? I'm on Dirty Unicorns ROM.

Check that your kernel supports the system interface /sys/devices/virtual/power_supply/manta-battery/charge_enabled. You need to be rooted, and then you can open a terminal and

Code:
cat /sys/devices/virtual/power_supply/manta-battery/charge_enabled

to make sure the file exists to control charging.

The script also relies on /sys/devices/virtual/power_supply/manta-battery/capacity to check battery capacity. You can similarly check with:

Code:
cat /sys/devices/virtual/power_supply/manta-battery/capacity

But if you have charge_enabled in that folder, you most likely also have capacity as well.

After that, you would simply run the script with ./charge_control.sh &
 

pfmiller

Senior Member
May 24, 2010
645
87
I have had this tablet since release and always plug it into the charger when going to sleep. I typically use the device from 100% to 60% each day. This device is over 2 years old now and still has the same screen on time each charge cycle as day one.

Looks like someone won the battery lottery. My tablet shuts down before it even gets to 50% charge these days, it's super frustrating.
 

shcholeh

Member
Jun 3, 2014
7
2
Has anyone tried this on stock Lollipop?
Confirm work on stock Lollipop 5.1.1 (LMY48I).
Since,
Code:
/sys/devices/virtual/power_supply/manta-battery/capacity
was not found, after some time of browsing I've found
Code:
/sys/devices/virtual/power_supply/manta-battery/subsystem/ds2784-fuelgauge/capacity
You'll need to modify the respective line 22 in script to
Code:
charge=$(cat /sys/devices/virtual/power_supply/manta-battery/subsystem/ds2784-fuelgauge/capacity)
 

robrob777

Senior Member
Mar 31, 2010
722
115
Good advice.. I usually change it to 80% seems to still last a lot and I got it 1 month after the release.
I never charge it to 100% since I know it will mess up the battery.
 

shcholeh

Member
Jun 3, 2014
7
2
Is it possible to find "charge_enabled" for Nexus 7 (2013, flo, razor) in Android KitKat 4.4.4?
"online" and "capacity" can be found easily in "sys/class/power_supply".
I've tried "lsof | grep healthd", but didn't identify read/write flag "charge_enabled" or similar.
 

onoakino

Senior Member
Sep 25, 2015
332
78
Manila
Recently found a solution by customizing kernel here: Battery life extender
However applying this patch to stock kernel is not a solution for ordinary user.

Did it work for you? If so, can you tell me what control files you edited and what android version you are on?

Im on LineageOS 14.1 and i tried changing the enable_charge value to one but the app still said my device is not supported (yet).
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    According to battery university, the optimal charge level for storage is 40%, and it's best to limit your depth of discharge as much as possible. Thinkpads have had a function to do just that, with the excellent tp_smapi module enabling the functionality under Linux.

    I turns out Nexus 10 with OmniROM has a way to disable charging even when the AC power is plugged in via the file /sys/devices/virtual/power_supply/manta-battery/charge_enabled. I've created a script that uses this functionality to keep charge between 35%-55%. You can modify STOPLIMIT and STARTLIMIT to with desired charge levels. You can optionally create /data/local/etc/battery/STOPLIMIT and /data/local/etc/battery/STARTLIMIT and put the values in there. Those values would override the values in the script.

    I start the service with 3C Toolbox Pro with a script that calls

    Code:
    su -c /data/local/bin/charge_control.sh &

    Requirements:

    Device: Nexus 10
    ROM: OmniROM HOMEMADE20141102
    Rooted
    busybox installed

    The ROM can be found in this thread: http://xdaforums.com/showthread.php?t=2705229

    It may work under other configurations, but above is the configuration I've tested it under. Battery university reference: http://batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries