Ben James — pre-2020 blog archive [ Main site here ]
← All posts

A smart charger that preserves your phone battery

If you charge your phone to 80% instead of 100%, you can expect roughly double the number of charging cycles before your battery can only hold 70% of its factory capacity.

Glancing at your phone every 5 minutes to check if it’s reached 80% yet is a bit dead – so I made a gizmo.

There’s two parts: a charging stand that controls the power to my phone, and an app to monitor 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 method I can think of that does what I need (it’s impossible to control the charging hardware of the phone directly through an app).

The stand hardware itself is simple: some 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 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.

6 Comments