Summary of TINYCHARGER – SINGLE CELL LI-ION BATTERY CHARGER WITH MONITORING
TinyCharger is a compact Li-ion battery charger using an ATtiny25/45/85 microcontroller and TP4056 chip. It features selectable charging current (100–1000mA) via parallel resistors controlled by MOSFETs, with real-time monitoring provided by an INA219 sensor and an OLED display. The system ensures safety through under-voltage lockout, automatic recharge, and precise termination when current drops to 1/10th of the programmed value.
Parts used in the TinyCharger:
- ATtiny25/45/85 microcontroller
- TP4056 linear charger IC
- OLED display
- INA219 current shunt and power monitor
- MOSFETs for switching resistors
- Three resistors connected in parallel
Two control loops, run in order
A single-cell charger is a current source that becomes a voltage source. Below the float voltage it holds the programmed current and the cell voltage climbs; at the float voltage the loop switches to constant voltage and holds it, and current falls as the cell fills.
The cycle ends on current, not voltage. TOPPOWER’s TP4056 terminates at one tenth of the programmed current, sensed on PROG through a 1.8 ms filter so a load transient cannot end the cycle early. Cell makers define the end differently: Samsung’s ICR18650-26F cycle-life test charges to a 0.05C cut-off, 130 mA on a 2600 mAh cell, where a 1C setting would stop at 260 mA. “Full” is a definition, and the last few percent of capacity depend on it.
Set the current from the cell, not the board
Samsung’s data sheet for the 2600 mAh ICR18650-26F gives a standard charge of 1300 mA, a rapid charge and maximum of 2600 mA, 4.2 ± 0.05 V, and a 0 to 45 °C charge window. Half the nominal capacity is standard; the maximum is 1C, and only at 25 °C. A 600 mAh pouch on the same board would get 1.7C.
The TP4056 sets current with one resistor from PROG to ground: 500 mA typical at 2.2 kΩ, 1 A typical at 1.1 kΩ, against a 1000 mA rating. Below 2.9 V it trickles about 130 mA until fast charging is safe. The termination point scales with the setting, so a 2600 mAh cell charged at 500 mA stops at 50 mA — 0.02C — and the constant-voltage tail gets long. A small cell needs a different resistor, not a firmware limit.
What the protection circuit does
Most single-cell packs put a protection IC and two N-channel MOSFETs in the negative lead. A DW01A opens the charge path above 4.3 V ± 50 mV, the discharge path below 2.4 V, and trips on over-current when the CS pin exceeds 0.15 V or 1.35 V after a short delay. It is a crowbar, not a regulator: when it operates, the pack is disconnected.
Its over-charge threshold sits above the charger’s float voltage, so it must never be what ends a normal charge — if it trips, the charger is at fault. Its current trip is a voltage, so the real current depends on the FETs’ on-resistance, a number from the FETs’ data sheet. And because those FETs have body diodes, an over-discharged pack still conducts in the charging direction, which is how a charger revives a flat cell.
Measuring charge current
A 0.1 Ω shunt at 1 A drops 100 mV and wastes 100 mW; 10 mΩ drops 10 mV, needs gain, and wastes a tenth. TI’s INA219 measures that drop on the high side, so system ground stays common, with a 12-bit converter and a fixed 10 µV shunt LSB. With 10 mΩ that is 1 mA per count, and the ±40 mV gain range covers 4 A. Write the calibration register before reading the current register, or it returns zero.
Some chargers read the current for free. The TP4056 regulates PROG to 1 V in constant-current mode and gives I_BAT = (V_PROG / R_PROG) × 1100, so the pin doubles as a monitor: PROG sits at 1 V in constant current and 0.1 V in trickle. It reports pass-device current, so a system load on the battery node corrupts the reading. A microcontroller ADC is no substitute: 10 mV against a 2.5 V reference is a handful of counts.
Fuel gauging: counting charge or reading volts
Coulomb counting integrates current. It tracks a discharge well regardless of the flat curve, but offset error accumulates, so the estimate drifts over weeks and needs a full-charge reference to re-anchor. Voltage gauging uses open-circuit voltage, which is monotonic but nearly flat mid-discharge — a few tenths of a volt span most of the capacity, load sags it, temperature shifts it — and it self-corrects at the endpoints. Most designs count in between and correct at the ends.
Heat
A linear charger burns (VIN − VBAT) × I: 5 V in, 3.7 V cell, 1 A is about 1.3 W in an ESOP-8 whose only heat sink is copper. The TP4056 folds current back as the die nears its limit — revision 2.4 puts regulation near 145 °C and cut-off beyond 150 °C — so the rated current is not there in a warm enclosure.
The cell’s window is 0 to 45 °C for charging. With an NTC divider on TEMP the TP4056 suspends charge outside the 45%–80% of VCC band; grounding that pin disables the check.
Rules for lithium cells
- Never exceed the cell’s float voltage or its tolerance: 4.2 ± 0.05 V, not “about 4.2”.
- Keep current inside the standard-to-maximum range, derated above 25 °C, and never charge below 0 °C.
- Fuse the input and check polarity first; a linear charger has no reverse-cell protection. The protection board is a last resort, never the controller.
- Meter the float voltage before connecting an expensive cell, and never leave a breadboarded charger unattended.
Every threshold and filter time above comes from the data sheets listed. What they cannot settle is your board: its actual float voltage, whether the pack’s protection trips before the charger’s own limit, and the temperature rise inside the finished enclosure.
References
- TOPPOWER, TP4056 1A Standalone Linear Li-Ion Battery Charger, rev. 2.4 —
PROGprogramming, C/10 termination, thermal limiting. - Samsung SDI, Specification of Product, ICR18650-26F, v1.0 — charge voltage and current, temperature limits, rate table.
- Fortune Semiconductor, DW01A Battery Protection IC Data Sheet.
- Texas Instruments, INA219 Current/Power Monitor, SBOS448.
- What microcontroller powers the TinyCharger?
The project uses an ATtiny25/45/85-based microcontroller. - How is the charging current limit selected?
The current is set between 100mA and 1000mA using three parallel resistors switched on or off by the ATtiny via MOSFETs. - Does the device support single-cell lithium-ion batteries?
Yes, it is designed specifically as a single-cell Li-ion battery charger. - Can the charge voltage be adjusted externally?
No, the maximum charge voltage is fixed at 4.2V by the TP4056. - How does the charger determine when to stop charging?
It automatically terminates the cycle when the charge current drops to 1/10th of the programmed value after reaching the float voltage. - What component measures the voltage and current?
An INA219 current shunt and power monitor is used for measurement. - Is there a display to monitor the charging process?
Yes, an OLED display is included for monitoring purposes. - Does the TP4056 offer protection against low voltage?
Yes, the TP4056 includes under voltage lockout functionality.
