Build an ATmega16 battery capacity tester that discharges an 18650 Li-ion, LiFePO4 or NiMH cell through a MOSFET-switched 4.7 Ω load, measures voltage and current with the ADC, and shows the real mAh, mWh and test time on a 16×2 LCD.
Need it ready-made? Buy Ready Project
A cheap 18650 cell printed with “9900 mAh” rarely holds more than a third of that, and old laptop cells can be anywhere from excellent to useless. The only honest way to know is to discharge the cell and count the charge that comes out. This ATmega16 battery capacity tester does exactly that: it connects a known load to the battery, measures the voltage and current every second, adds up the milliamp-hours and stops automatically at the safe cut-off voltage.
The result appears on a 16×2 LCD as mAh, mWh and total test time, and the last result is stored in EEPROM. A MODE button selects the battery type (Li-ion 3.0 V, Li-ion 2.8 V, LiFePO4 2.5 V or NiMH 1.0 V cut-off), and an optional USB-TTL adapter logs a CSV line every 10 seconds so you can draw a discharge curve in a spreadsheet. It is a practical intermediate project for learning the ATmega16 ADC with its internal reference, MOSFET load switching, timer interrupts and HD44780 LCD driving in plain AVR C.

How It Works
- Constant-resistance load: the battery discharges through a 4.7 Ω power resistor switched by an IRLZ44N logic-level MOSFET on PD4. A full Li-ion cell (4.2 V) draws about 0.9 A, falling to about 0.64 A at 3.0 V, which is close to the 0.5C–1C rate most datasheets use for capacity.
- Voltage measurement: PA0 (ADC0) reads the battery voltage through a 10 kΩ/10 kΩ divider. The ADC uses the internal 2.56 V reference, so each ADC step is 2.5 mV × 2 = 5 mV and the full scale is 5.11 V. Every reading is the average of 16 conversions to remove noise.
- Current measurement: PA1 (ADC1) reads the voltage at the MOSFET drain through an identical divider. The voltage across the resistor is
V_battery − V_drain, so the current is that difference divided by 4.7 Ω. Measuring both ends means the MOSFET resistance and the wire drop do not add an error. - Counting capacity: Timer0 creates a 1 ms tick and raises a flag every second. Each second the program adds the current in mA to a milliamp-second counter and the power in mW to a milliwatt-second counter. Dividing by 3600 gives mAh and mWh.
- Automatic stop: when the battery voltage stays at or below the cut-off for 3 seconds in a row, the MOSFET switches off, the buzzer gives a 1 second beep and the LCD shows the final capacity. The 3-second filter stops one noisy reading from ending the test early. The test also stops if the battery is removed.
- Safety checks: the tester refuses to start with no battery (below 0.5 V), with a voltage above 4.6 V (for example a 2-cell pack) or with a cell that is already below its cut-off.
- Memory and logging: the selected battery type and the last mAh/mWh result are saved with
eeprom_update_*(). The UART sendstime_s,battery_mV,current_mA,mAh,mWhevery 10 seconds at 9600 baud.
Components Required
- ATmega16 microcontroller (40-pin DIP) – 1
- USBasp programmer (10-pin to 6-pin adapter if needed) – 1
- 16×2 character LCD (HD44780) + 10 kΩ contrast potentiometer – 1
- IRLZ44N logic-level N-channel MOSFET – 1
- 4.7 Ω 5 W (or 10 W) ceramic/aluminium load resistor – 1
- 220 Ω resistor (gate) and 10 kΩ resistor (gate pull-down) – 1 each
- 10 kΩ 1 % resistors for the two voltage dividers – 4
- 100 nF ceramic capacitors (AREF, ADC inputs, VCC/AVCC decoupling) – 5
- 18650 battery holder with thick leads – 1
- 12 mm tactile push buttons (START/STOP, MODE) – 2
- 5 V active buzzer (≤ 20 mA) – 1
- Red 5 mm LED + 330 Ω resistor (test running) – 1
- 10 kΩ RESET pull-up resistor – 1
- 5 V supply: USB 5 V or 9–12 V adapter with LM7805 – 1
- Optional USB-TTL serial adapter (CP2102 / CH340) for CSV logging – 1
- Breadboard or perfboard, heatsink for the resistor and jumper wires – 1 set
Wiring Table
| Part / pin | ATmega16 pin | Notes |
|---|---|---|
| +5 V | VCC (10), AVCC (30) | 100 nF from each to GND |
| GND | GND (11, 31) | Common with battery − and MOSFET source |
| AREF | Pin 32 | 100 nF to GND only – do not connect to 5 V |
| RESET | Pin 9 | 10 kΩ to +5 V (also to USBasp RESET) |
| Battery voltage divider | PA0 / ADC0 (40) | Battery + → 10 kΩ → PA0 → 10 kΩ → GND |
| Drain voltage divider | PA1 / ADC1 (39) | MOSFET drain → 10 kΩ → PA1 → 10 kΩ → GND |
| Load resistor 4.7 Ω 5 W | – | Between battery + and MOSFET drain |
| IRLZ44N gate | PD4 (18) | Through 220 Ω; 10 kΩ gate to GND |
| IRLZ44N source | GND | Thick wire to battery − |
| LCD RS / E | PD6 (20) / PD7 (21) | LCD RW to GND |
| LCD D4, D5, D6, D7 | PB0, PB1, PB2, PB3 (1–4) | LCD D0–D3 not connected |
| LCD VSS / VDD / V0 | GND / +5 V / pot wiper | 10 kΩ pot between 5 V and GND for contrast; backlight A via 100 Ω (if not on board) |
| START/STOP button | PD2 (16) | Other leg to GND, internal pull-up |
| MODE button | PD3 (17) | Other leg to GND, internal pull-up |
| Active buzzer + | PD5 (19) | Buzzer − to GND |
| Red LED (running) | PC0 (22) | 330 Ω, cathode to GND |
| USB-TTL RX (optional) | PD1 / TXD (15) | Connect the adapter GND too |
| USBasp MOSI / MISO / SCK | PB5 (6) / PB6 (7) / PB7 (8) | Left free for programming |
Pin check: PA0 and PA1 are ADC inputs. AREF must only have a capacitor because the code selects the internal 2.56 V reference; connecting AREF to 5 V while the internal reference is on can damage the chip. PC0 is not a JTAG pin, so no JTAG change is needed for this project, but programming hfuse 0xD9 (JTAG off) is still good practice. The LCD data lines are on PB0–PB3, away from the PB5–PB7 programming pins.
Connection Diagram
The diagram above gives an overview of the blocks. The drawing below lists every pin exactly as used in the code.
Code
The program is written in plain AVR C for AVR-GCC (Microchip Studio, or avr-gcc on Linux / WinAVR on Windows). It was compile-checked for the ATmega16 with -Wall -Wextra and no warnings: about 3.5 KB of flash (21 %) and 310 bytes of RAM. Edit VREF_MV and R_LOAD_MOHM at the top after the calibration step below.
/*
* ATmega16 Battery Capacity Tester (18650 Li-ion, LiFePO4, NiMH)
* Arduino Project Hub - https://ardiunoprojecthub.online
*
* MCU : ATmega16, internal 8 MHz RC oscillator
* Fuses : lfuse 0xE4 (int. 8 MHz), hfuse 0xD9 (JTAG off)
* Build : avr-gcc -mmcu=atmega16 -DF_CPU=8000000UL -Os -o battery.elf atmega16_battery_tester.c
*
* How it measures:
* Battery + -> 4.7 ohm 5 W load resistor -> IRLZ44N drain, source -> GND
* PA0 (ADC0) reads the battery voltage through a 10k/10k divider
* PA1 (ADC1) reads the MOSFET drain through a 10k/10k divider
* Current = (V_battery - V_drain) / R_LOAD
* ADC reference = internal 2.56 V (100 nF from AREF to GND), so with the
* divide-by-2 divider: 1 ADC step = 2.5 mV x 2 = 5 mV, full scale 5.11 V.
*
* Pins:
* LCD 16x2 (HD44780, 4-bit): RS PD6, E PD7, D4..D7 PB0..PB3, RW -> GND
* MOSFET gate : PD4 (220 ohm series, 10k pull-down to GND)
* START/STOP : PD2 (button to GND, internal pull-up)
* MODE : PD3 (button to GND, internal pull-up) - selects battery type
* Buzzer : PD5 (5 V active buzzer, max 20 mA)
* Test LED : PC0 (330 ohm to LED, LED to GND)
* UART log : PD1 TXD -> USB-TTL RX, 9600 8N1, one CSV line every 10 s
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/eeprom.h>
#include <util/delay.h>
#include <stdint.h>
/* ---------------- calibration - edit for your parts ---------------- */
#define VREF_MV 2560UL /* measure AREF pin with a meter and put the value here */
#define DIV_RATIO 2UL /* 10k / 10k divider */
#define R_LOAD_MOHM 4700UL /* load resistor in milli-ohm (4.7 ohm) */
#define CUTOFF_SECONDS 3 /* voltage must stay below cut-off this long to stop */
#define V_PRESENT_MV 500 /* below this there is no battery in the holder */
#define V_MAX_MV 4600 /* above this refuse to start (wrong battery / pack) */
#define LOG_EVERY_S 10 /* UART CSV interval */
/* ---------------- pins ---------------- */
#define LCD_RS PD6
#define LCD_E PD7
#define GATE PD4
#define BTN_RUN PD2
#define BTN_MODE PD3
#define BUZZER PD5
#define LED PC0
/* battery types: name and cut-off voltage (mV) */
typedef struct { char name[8]; uint16_t cutoff_mv; } btype_t;
static const btype_t TYPES[4] = {
{ "Li-ion ", 3000 },
{ "Li 2.8V", 2800 },
{ "LiFePO4", 2500 },
{ "NiMH ", 1000 },
};
/* EEPROM: last selected type and last result */
uint8_t EEMEM ee_type = 0;
uint16_t EEMEM ee_last_mah = 0;
uint16_t EEMEM ee_last_mwh = 0;
/* ---------------- 1 ms tick ---------------- */
static volatile uint16_t ms_in_sec = 0;
static volatile uint8_t sec_flag = 0; /* set once per second */
static volatile uint16_t beep_ms = 0; /* buzzer time left */
ISR(TIMER0_COMP_vect) /* 8 MHz / 64 / 125 = 1000 Hz */
{
if (++ms_in_sec >= 1000) { ms_in_sec = 0; sec_flag = 1; }
if (beep_ms) { if (--beep_ms == 0) PORTD &= ~(1 << BUZZER); }
}
static void beep(uint16_t ms)
{
cli(); beep_ms = ms; sei();
PORTD |= (1 << BUZZER);
}
/* ---------------- LCD (4-bit, write only) ---------------- */
static void lcd_nibble(uint8_t n)
{
PORTB = (PORTB & 0xF0) | (n & 0x0F);
PORTD |= (1 << LCD_E);
_delay_us(1);
PORTD &= ~(1 << LCD_E);
_delay_us(50);
}
static void lcd_byte(uint8_t b, uint8_t rs)
{
if (rs) PORTD |= (1 << LCD_RS); else PORTD &= ~(1 << LCD_RS);
lcd_nibble(b >> 4);
lcd_nibble(b);
}
static void lcd_cmd(uint8_t c) { lcd_byte(c, 0); if (c < 4) _delay_ms(2); }
static void lcd_char(char c) { lcd_byte((uint8_t)c, 1); }
static void lcd_str(const char *s) { while (*s) lcd_char(*s++); }
static void lcd_goto(uint8_t col, uint8_t row) { lcd_cmd(0x80 | (row ? 0x40 : 0x00) | col); }
static void lcd_init(void)
{
_delay_ms(50);
PORTD &= ~(1 << LCD_RS);
lcd_nibble(0x03); _delay_ms(5);
lcd_nibble(0x03); _delay_us(150);
lcd_nibble(0x03);
lcd_nibble(0x02); /* 4-bit mode */
lcd_cmd(0x28); /* 2 lines, 5x8 font */
lcd_cmd(0x0C); /* display on, no cursor */
lcd_cmd(0x06); /* auto increment */
lcd_cmd(0x01); /* clear */
}
/* write an unsigned number right-aligned in 'width' characters */
static void lcd_num(uint32_t v, uint8_t width, char pad)
{
char buf[10];
uint8_t i = 0;
do { buf[i++] = '0' + (v % 10); v /= 10; } while (v && i < sizeof buf);
while (i < width) buf[i++] = pad;
while (i) lcd_char(buf[--i]);
}
/* "3.85V" style value with 2 decimals from milli-units */
static void lcd_fixed2(uint16_t milli)
{
uint16_t cent = (milli + 5) / 10; /* round to 0.01 */
lcd_num(cent / 100, 1, ' ');
lcd_char('.');
lcd_num(cent % 100, 2, '0');
}
/* hh:mm:ss */
static void lcd_time(uint32_t s)
{
uint8_t hh = s / 3600UL;
if (hh > 99) hh = 99;
lcd_num(hh, 2, '0'); lcd_char(':');
lcd_num((s / 60) % 60, 2, '0'); lcd_char(':');
lcd_num(s % 60, 2, '0');
}
/* ---------------- UART (TX only) ---------------- */
static void uart_init(void)
{
UBRRH = 0;
UBRRL = 51; /* 9600 baud at 8 MHz */
UCSRB = (1 << TXEN);
UCSRC = (1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0); /* 8N1 */
}
static void uart_tx(char c) { while (!(UCSRA & (1 << UDRE))) ; UDR = c; }
static void uart_str(const char *s) { while (*s) uart_tx(*s++); }
static void uart_num(uint32_t v)
{
char buf[11]; uint8_t i = 0;
do { buf[i++] = '0' + (v % 10); v /= 10; } while (v);
while (i) uart_tx(buf[--i]);
}
/* ---------------- ADC ---------------- */
static void adc_init(void)
{
ADMUX = (1 << REFS1) | (1 << REFS0); /* internal 2.56 V */
ADCSRA = (1 << ADEN) | (1 << ADPS2) | (1 << ADPS1); /* 8 MHz / 64 = 125 kHz */
}
/* average of 16 conversions, returned in millivolts at the battery side */
static uint16_t read_mv(uint8_t ch)
{
uint32_t sum = 0;
ADMUX = (ADMUX & 0xE0) | (ch & 0x07);
_delay_us(20);
ADCSRA |= (1 << ADSC); /* throw away first reading */
while (ADCSRA & (1 << ADSC)) ;
for (uint8_t i = 0; i < 16; i++) {
ADCSRA |= (1 << ADSC);
while (ADCSRA & (1 << ADSC)) ;
sum += ADC;
}
/* mV = (sum/16) * VREF / 1024 * DIV_RATIO */
return (uint16_t)((sum * VREF_MV * DIV_RATIO) / (16UL * 1024UL));
}
/* ---------------- buttons (active LOW, 30 ms debounce) ---------------- */
static uint8_t pressed(uint8_t pin)
{
if (PIND & (1 << pin)) return 0;
_delay_ms(30);
if (PIND & (1 << pin)) return 0;
while (!(PIND & (1 << pin))) ; /* wait for release */
_delay_ms(30);
return 1;
}
/* ---------------- tester state ---------------- */
enum { IDLE, RUNNING, DONE };
static uint8_t state = IDLE;
static uint8_t type;
static uint32_t mas = 0; /* milliamp-seconds */
static uint32_t mws = 0; /* milliwatt-seconds */
static uint32_t secs = 0;
static uint8_t low_count = 0;
static uint8_t stop_reason = 0; /* 0 = cut-off, 1 = user, 2 = removed */
static void load_on(void) { PORTD |= (1 << GATE); PORTC |= (1 << LED); }
static void load_off(void) { PORTD &= ~(1 << GATE); PORTC &= ~(1 << LED); }
static void show_idle(uint16_t vb)
{
lcd_goto(0, 0);
lcd_str(TYPES[type].name); lcd_char(' ');
if (vb < V_PRESENT_MV) lcd_str(" NO BAT");
else { lcd_char(' '); lcd_fixed2(vb); lcd_str("V "); }
lcd_goto(0, 1);
lcd_str("Cut "); lcd_fixed2(TYPES[type].cutoff_mv);
lcd_str("V L"); lcd_num(eeprom_read_word(&ee_last_mah) > 9999 ? 9999 :
eeprom_read_word(&ee_last_mah), 4, ' ');
}
static void show_run(uint16_t vb, uint16_t ma)
{
lcd_goto(0, 0);
lcd_fixed2(vb); lcd_str("V ");
lcd_fixed2(ma); lcd_str("A RUN");
lcd_goto(0, 1);
lcd_num(mas / 3600UL, 4, ' '); lcd_str("mAh ");
lcd_time(secs);
}
static void show_done(uint8_t page)
{
lcd_goto(0, 0);
if (stop_reason == 0) lcd_str("DONE cut-off ");
else if (stop_reason == 1) lcd_str("STOPPED by user ");
else lcd_str("BATTERY REMOVED ");
lcd_goto(0, 1);
if (page) { lcd_num(mws / 3600UL, 5, ' '); lcd_str("mWh "); }
else { lcd_num(mas / 3600UL, 4, ' '); lcd_str("mAh "); lcd_time(secs); }
}
static void finish(uint8_t reason)
{
load_off();
stop_reason = reason;
state = DONE;
uint32_t mah = mas / 3600UL, mwh = mws / 3600UL;
eeprom_update_word(&ee_last_mah, mah > 65535UL ? 65535U : (uint16_t)mah);
eeprom_update_word(&ee_last_mwh, mwh > 65535UL ? 65535U : (uint16_t)mwh);
uart_str("# end,"); uart_num(mah); uart_str(" mAh,"); uart_num(mwh); uart_str(" mWh\r\n");
beep(reason == 0 ? 1000 : 200);
lcd_cmd(0x01);
}
int main(void)
{
/* outputs: LCD data PB0..PB3, RS/E/gate/buzzer on PORTD, LED on PC0 */
DDRB |= 0x0F;
DDRD |= (1 << LCD_RS) | (1 << LCD_E) | (1 << GATE) | (1 << BUZZER);
DDRC |= (1 << LED);
PORTD |= (1 << BTN_RUN) | (1 << BTN_MODE); /* pull-ups for buttons */
load_off();
/* Timer0: CTC, prescaler 64, OCR0 = 124 -> 1 ms */
TCCR0 = (1 << WGM01) | (1 << CS01) | (1 << CS00);
OCR0 = 124;
TIMSK |= (1 << OCIE0);
adc_init();
uart_init();
lcd_init();
sei();
type = eeprom_read_byte(&ee_type);
if (type > 3) type = 0;
lcd_str("Battery Capacity");
lcd_goto(0, 1); lcd_str("Tester ATmega16");
uart_str("# ATmega16 battery tester\r\n");
_delay_ms(1500);
lcd_cmd(0x01);
uint8_t page = 0;
for (;;) {
/* ---- buttons ---- */
if (pressed(BTN_MODE)) {
if (state == IDLE) {
type = (type + 1) & 0x03;
eeprom_update_byte(&ee_type, type);
beep(40);
} else if (state == DONE) {
state = IDLE; lcd_cmd(0x01); beep(40);
}
}
if (pressed(BTN_RUN)) {
if (state == RUNNING) {
finish(1);
} else {
uint16_t vb = read_mv(0);
if (vb < V_PRESENT_MV) { beep(300); }
else if (vb > V_MAX_MV) {
lcd_goto(0, 1); lcd_str("Too high! >4.6V "); beep(600); _delay_ms(1500);
} else if (vb <= TYPES[type].cutoff_mv) {
lcd_goto(0, 1); lcd_str("Already empty! "); beep(600); _delay_ms(1500);
} else {
mas = mws = secs = 0; low_count = 0;
state = RUNNING;
lcd_cmd(0x01);
load_on();
beep(80);
uart_str("time_s,battery_mV,current_mA,mAh,mWh\r\n");
cli(); ms_in_sec = 0; sec_flag = 0; sei();
}
}
}
/* ---- once per second ---- */
if (!sec_flag) continue;
sec_flag = 0;
uint16_t vb = read_mv(0);
if (state == RUNNING) {
uint16_t vd = read_mv(1);
uint16_t drop = (vb > vd) ? (vb - vd) : 0;
uint16_t ma = (uint16_t)(((uint32_t)drop * 1000UL) / R_LOAD_MOHM);
secs++;
mas += ma; /* mA x 1 s */
mws += ((uint32_t)ma * vb) / 1000UL; /* mW x 1 s */
show_run(vb, ma);
if (secs % LOG_EVERY_S == 0) {
uart_num(secs); uart_tx(','); uart_num(vb); uart_tx(',');
uart_num(ma); uart_tx(','); uart_num(mas / 3600UL); uart_tx(',');
uart_num(mws / 3600UL); uart_str("\r\n");
}
if (vb < V_PRESENT_MV) finish(2);
else if (vb <= TYPES[type].cutoff_mv) {
if (++low_count >= CUTOFF_SECONDS) finish(0);
} else low_count = 0;
} else if (state == IDLE) {
show_idle(vb);
} else { /* DONE: flip page every 3 s */
static uint8_t t = 0;
if (++t >= 3) { t = 0; page ^= 1; }
show_done(page);
}
}
}
Compile, Set Fuses and Upload
Connect the USBasp to MOSI, MISO, SCK, RESET, VCC and GND, then run these commands. The fuse values select the internal 8 MHz oscillator (lfuse 0xE4) and turn JTAG off (hfuse 0xD9).
avr-gcc -mmcu=atmega16 -DF_CPU=8000000UL -Os -o battery.elf atmega16_battery_tester.c
avr-objcopy -O ihex -R .eeprom battery.elf battery.hex
avrdude -c usbasp -p m16 -U lfuse:w:0xE4:m -U hfuse:w:0xD9:m
avrdude -c usbasp -p m16 -U flash:w:battery.hex:iCalibration (5 Minutes)
- Reference voltage: the internal 2.56 V reference can be anywhere from about 2.3 to 2.8 V. Power the circuit, measure the AREF pin (32) with a multimeter and put that value in millivolts into
VREF_MV(for example 2534). - Load resistor: measure the 4.7 Ω resistor with the leads shorted first, subtract the lead resistance, and enter the value in milli-ohms into
R_LOAD_MOHM. - Check: insert a cell, compare the LCD voltage with your meter, start a test and compare the current with a meter in series. Both should agree within 1–2 %.
Using the Tester
- Charge first: fully charge the cell in a proper charger (4.2 V for Li-ion, 3.6 V for LiFePO4) and let it rest for 30 minutes.
- Select the type: with the tester idle, press MODE to choose Li-ion (3.0 V cut-off), Li 2.8V, LiFePO4 (2.5 V) or NiMH (1.0 V). The bottom line shows the cut-off and the last result (L).
- Start: press START/STOP. The red LED lights, the top line shows voltage, current and RUN, and the bottom line counts mAh and time.
- Finish: at the cut-off the tester beeps for one second and shows DONE with the capacity and time, switching to mWh every 3 seconds. Press MODE to return to the idle screen or START/STOP to test again.
- Reading the result: a healthy 2500 mAh 18650 should show 2300–2500 mAh; below 70–80 % of the rating the cell is worn. A NiMH AA at this load draws only about 0.25 A, so the test takes several hours.
Troubleshooting
| Problem | Fix |
|---|---|
| Voltage on the LCD is a few percent off | Measure AREF and set VREF_MV to the real value. Use 1 % resistors in both dividers. |
| Current shows 0.00 A while running | Check the MOSFET: gate from PD4 through 220 Ω, source to GND, drain to the resistor. An IRFZ44N (not logic-level) will not switch fully on at 5 V – use IRLZ44N. |
| Shows NO BAT with a cell inserted | The PA0 divider is not connected to battery +, or the battery − is not connected to the circuit GND. |
| Test stops after a few seconds | Thin wires or a weak holder cause a big voltage drop under load. Use short thick wires and take the PA0 divider directly at the holder +. |
| LCD shows only black boxes | Turn the contrast pot. If it still shows boxes, check RS (PD6), E (PD7) and D4–D7 (PB0–PB3); RW must be on GND. |
| Garbage in the serial log | The internal RC oscillator can be a few percent off. Calibrate OSCCAL or use an 8 MHz crystal with lfuse 0xFF. |
| Load resistor gets very hot | That is normal (about 3.5 W at the start). Use a 10 W aluminium resistor on a heatsink, or a small fan, and keep it away from the cell and plastic. |
| Avrdude says the device signature is 0x000000 | Check the USBasp wiring and that the chip has 5 V. On a factory-fresh chip set the USBasp to slow SCK (jumper JP3) for the first fuse write. |
Safety Notes
- Test only one single cell at a time and never leave a discharge test unattended.
- Never discharge a Li-ion cell below 2.5 V; deeply discharged cells can be unsafe to recharge.
- Do not test swollen, dented or leaking cells.
Ideas to Extend
- Replace the fixed resistor with an op-amp constant-current sink (LM358 + MOSFET + 1 Ω shunt) for an exact 0.5 A or 1 A test.
- Add an NTC thermistor on PA2 to stop the test if the cell gets warm.
- Add a TP4056 charger and a relay to run a full charge – discharge – charge cycle automatically.