Motivation:
It's commonly considered bad for a lithium-ion battery's long term health to be charged up to, or left at, a high level of charge for an extended amount of time (say, if the hiby is commonly used plugging in as a USB DAC.) The consensus seems to be to keep the battery within a charge level from 20 to 80% for the least degradation.
Conveniently, the R1's PMU, the X-Powers AXP2101, offers an I2C interface to adjust different charging parameters. Doubly-conveniently, the R1 also bundled in the tools needed to read and write to the I2C bus directly.
Disclaimer: I didn't go to battery school; so I had Claude, the fancy text completion engine, doing the preliminary research for this. I have since done my due diligent to double check its claims to the datasheet and tested on my own R1. As far as I can tell, these mods (probably) won't turn yours into a pipe bomb.
Posted here since I feel this need more investigating & testing.
References:
Datasheet: https://files.waveshare.com/wiki/common/X-power-AXP2101_SWcharge_V1.0.pdf
(see section 6.13.2 for detailed descriptions on what each registers do)
Common syntax
At least on my device, the PMU is on bus 0 at address 0x34. We have to force the read/write with -f, else it would fail:
# Over adb shell
# Read
i2cget -f -y 0 0x34 0x<RegisterIndex>
# Write
i2cset -f -y 0 0x34 0x<RegisterIndex> <HexValue>
Tweaks
I have tried the following:
Lower voltage cutoff threshold:
REG 64 holds the battery voltage threshold where charging stops. Default value upon boot is 0x05 or 101 - which correspond to 4.4 Volts as per the datasheet above.
Changing it to 0x03 (011 or 4.2 Volts) seems to prevent the battery from going above 83%.
And setting the limit to 4.1V (0x02) stops charging at at roughly 72%.
Example:
adb shell i2cset -f -y 0 0x34 0x64 0x03
Have not tested with any other values.
Slower charging speed:
NOTE: I have not verify this imperially. As in: I didn't bother busting out the timer and A/B-test it through.
REG 62 controls the constant current charge current limit. Default value reads 0x0d (1101/700mA). Changing the value to 0x06 or 0x04 should limit the current to a max of 150mA and 100mA, respectively.
Example:
adb shell i2cset -f -y 0 0x34 0x62 0x06
Making the changes permanent:
The values gets reset once the R1 fully shutdowns. So I added these at the top of /usr/bin/hiby_player.sh:
# ...
# Stop charging when battery is at 4.2 volts instead of 4.4
i2cset -f -y 0 0x34 0x64 0x03
# Limit charge current to 150mA
i2cset -f -y 0 0x34 0x62 0x06
# ...
There are probably better places to inject these.
Motivation:
It's commonly considered bad for a lithium-ion battery's long term health to be charged up to, or left at, a high level of charge for an extended amount of time (say, if the hiby is commonly used plugging in as a USB DAC.) The consensus seems to be to keep the battery within a charge level from 20 to 80% for the least degradation.
Conveniently, the R1's PMU, the X-Powers AXP2101, offers an I2C interface to adjust different charging parameters. Doubly-conveniently, the R1 also bundled in the tools needed to read and write to the I2C bus directly.
Posted here since I feel this need more investigating & testing.
References:
Datasheet: https://files.waveshare.com/wiki/common/X-power-AXP2101_SWcharge_V1.0.pdf
(see section
6.13.2for detailed descriptions on what each registers do)Common syntax
At least on my device, the PMU is on bus
0at address0x34. We have to force the read/write with-f, else it would fail:Tweaks
I have tried the following:
Lower voltage cutoff threshold:
REG
64holds the battery voltage threshold where charging stops. Default value upon boot is0x05or101- which correspond to 4.4 Volts as per the datasheet above.Changing it to
0x03(011or 4.2 Volts) seems to prevent the battery from going above 83%.And setting the limit to 4.1V (
0x02) stops charging at at roughly 72%.Example:
Have not tested with any other values.
Slower charging speed:
REG
62controls the constant current charge current limit. Default value reads0x0d(1101/700mA). Changing the value to0x06or0x04should limit the current to a max of 150mA and 100mA, respectively.Example:
Making the changes permanent:
The values gets reset once the R1 fully shutdowns. So I added these at the top of
/usr/bin/hiby_player.sh:There are probably better places to inject these.