I recently bought a new phone, because my old one’s battery capacity had degraded to the point where it couldn’t last me through the day – an experience that’s fairly common. The pain of financial expenditure fresh in my head, I decided to investigate what I could do to look after the battery of my new phone.
It turns out that the lifetime of a Lithium-Ion battery (the type used in all phones and laptops) is directly determined by how much you charge your phone. Though figures vary, if you charge your phone to 80% instead of 100%, you can expect nearly double the number of charging cycles before your battery can only hold 70% of its factory capacity.
Of course, charging your phone to 80% every day is forcibly limiting your capacity by itself. But I realised that I only need 100% of my capacity on certain long days when I have particular activities; on a lot of days (like when I’m home from university), charging to 80% is just fine.
So I dutifully started charging my phone, glancing at it every 5 minutes to check if the charge level had reached 80% yet, ready to unplug it. But this quickly became boring, so I decided to come up with a way to automate it.
The solution I built comes in 2 parts: a charging stand which controls the power to my phone, and an app which monitors the battery level.
When the battery level of the phone reaches the threshold set in the app, the torch on my phone flashes, shining through the hole in the charging stand onto a light sensor beneath, telling the stand to cut charging power.
This seems a bit overkill, but is the simplest way I can think of that does what I need, as it’s impossible to control the charging hardware of the phone directly through an app.
The stand hardware itself is very simple: a bit of folded stainless steel and a 3D-printed back cover enclose an Arduino nano which monitors the light sensor and supplies/cuts charging power with a MOSFET. On the front there’s an LED and some buttons which turn the whole thing on, and “reset” the charging power once it’s been cut. It deliberately doesn’t have fast charging, because it’s detrimental to battery life and I always charge overnight.
The part of this project I spent the most time on was writing the Android app, as it was my first time doing any native app development. I expected it to be easy, as the app is one glorified if-statement, but the part which turned out to be tricky was keeping a service running in the background which was able to check the charge level at a sensible interval. The solution I eventually settled on was to use a Foreground Service, which has the side effect of appearing as a persistent notification, in the same way that a music player would. I’m pretty sure there must be a better way to do it, and I’d love to hear from anyone who has any ideas.
This is one of my favourite recent projects, as I now use it almost everyday and it works great.