A smart charger that preserves your phone battery

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.

6 thoughts on “A smart charger that preserves your phone battery

      1. Hey Ben, you mentioned that the service was always ON in the notification bar to trigger the light when the battery reached 80%. I was wondering what if you triggered the service to run at 75% rather than when its always charging?

        int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
        int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

        float batteryPct = level / (float)scale;
        if batteryPct > 75%
        //trigger that foreground service

        Disclaimer: I used to program in .NET and Java but not Android Apps,. So, maybe what I’m saying here doesn’t make sense lol. Sorry

      2. Hey Warren, ah yes I think I see what you mean.
        The issue is: where would I run the code/logic you suggest above once the app has exited? It needs to be run repeatedly, and from what I’ve gathered, in recent versions of Android it’s harder to get things to run frequently/consistently without putting them in the foreground (eg the minimum interval you can schedule a WorkManager for is 15 mins I think, and it’s scheduled by the OS so not guaranteed to be consistent).

        But I suppose ~15 minutes might be enough to have two levels of checking, perhaps that’s what you mean? Ie check infrequently until we’ve reached (TARGET – 5%), then turn on the more intensive foreground checking?
        It’s a cool idea but I’m not sure that for me it’s worth introducing an additional state; when my phone’s charging, I’m usually not using it so 1) from a usability perspective I don’t mind the foreground service running and 2) given that it’s plugged in, I don’t really mind if it’s using a little more power (and the foreground service isn’t that intensive at all anyway).
        Bit of a ramble, but maybe that answers your question?

  1. Very interesting project. Sometime ago I looked into similar project, but I lack the ability to develop the Android app, I gave up. Meanwhile I found this little guy here chargie(dot)org. They claim that if you charge the phone 80%, you can preserve its battery for 5 years.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s