USB Battery Minder

A smart USB-C charging station that stops at 80% — no device communication required.

KiCad C++ ESP32 INA219 AP22804

The Problem

Most USB-C devices — phones, earbuds, watches, tablets — spend their lives plugged into a charger, sitting at 100% state-of-charge. Lithium-ion cells age fastest when held at full voltage. Every major device manufacturer now ships an "optimized charging" feature that caps at 80%, but only for their own hardware and only when the device's software cooperates.

The Battery Minder takes a different approach: an 8-port USB-C charging station with per-port current monitoring that detects when a battery reaches ~80% SoC by observing the charge profile itself, then cuts power. No Bluetooth pairing, no device-specific protocols, no software to install. It works with any USB-powered device that charges a lithium-ion cell.

How It Works

Lithium-ion batteries charge in two distinct phases. During constant-current (CC) mode, the charger delivers its full rated current while cell voltage climbs. When the cell reaches its voltage limit (typically 4.2V), the charger transitions to constant-voltage (CV) mode: voltage holds steady while current tapers off exponentially as the cell fills.

During CC mode, current is flat at the peak rate and SoC rises roughly linearly — this is the fast part of the charge. Once the cell hits its voltage limit, the charger switches to CV mode: voltage is capped and current decays exponentially as the cell approaches full. The last 20% of capacity takes disproportionately long.

Detection Strategy

The key insight is that you don't need to know the battery voltage or communicate with the device. You only need to watch the current. The CC-to-CV transition causes a distinctive inflection in the current draw: a flat plateau that begins decaying exponentially. By monitoring when the current drops below a configured fraction of the peak (the taper ratio), the firmware can infer approximately how full the battery is.

The taper ratio is the threshold expressed as a fraction of peak current. A ratio of 0.55 means "cut power when the current drops to 55% of what it was during CC." For most devices, this corresponds to roughly 78–82% SoC. The ratio is configurable per port in firmware to account for different device types.

This is a universal approach. It doesn't depend on the device type, battery capacity, or charging protocol. It works because all lithium-ion cells follow the same fundamental CC/CV charge profile — the physics are the same whether you're charging earbuds or a tablet.

Hardware

The board is built around an ESP32-S3 microcontroller with 8 independent charge channels. Each channel has:

  • INA219 — high-side current/voltage sensor on an I2C bus, providing continuous milliamp-resolution current readings
  • AP22804 — USB load switch with enable control, allowing the firmware to cut power to individual ports without affecting the others

The ESP32 samples current on each port at regular intervals, maintains a state machine per channel (idle → charging → tapering → complete), and controls the load switches accordingly. A maintenance mode periodically re-enables charging to keep devices topped off near the target SoC.

Interactive Demo

This simulates the charge profile for different device types. Select a device, hit play, and watch how the current drops during the CV phase. The dashed threshold line shows where the Battery Minder detects the taper and cuts power.

threshold02004006008001000Current (mA)020406080100Time (min)
IdleChargingTaperingCompleteMaintain
Idle
Current 1000 mA
SoC 0.0%
Phase Constant Current
Time 0.0 min