Battery discharge curve analyser
Build it step by step
0 of 7 doneBuild the load
MOSFET, 1 ohm, op-amp.
Test with a bench supply
Set 3.7 V, check the current.
Add the INA219
Read volts and amps.
Set the current
0.5 A with PWM.
Add the cut-off
3.0 V for Li-ion.
Run a full discharge
Attended, on a safe surface.
Plot the curve
Compare brands.
How do you build a battery discharge curve analyser?
A constant-current load discharges AA, 18650 or LiPo cells and plots the capacity curve on a PC. You need Arduino Nano, MOSFET IRLZ44N, Wirewound resistor 1 Ω 10 W, LM358 Op-Amp, INA219 Current Monitor, Heatsink TO-220, USB A to micro-USB cable (data), Resistor 10 kΩ, Resistor 1 kΩ and Electrolytic capacitor 10 µF. It takes 7 steps and about 240 minutes.
- Level
- Intermediate
- Time
- About 240 min
- Parts
- 10
Parts list
- Development BoardsBuyArduino Nano × 1
- SemiconductorsBuyMOSFET IRLZ44N × 1
- PassivesBuyCurrent sense
- Integrated CircuitsBuyLM358 Op-Amp × 1
- SensorsBuy
- Tools & InstrumentsBuyHeatsink TO-220 × 1
- Cables & WiresBuy
- PassivesBuyResistor 10 kΩ × 1
- PassivesBuyResistor 1 kΩ × 1
- PassivesBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Cell plus | INA219 VIN+ | Measures the current |
| INA219 VIN- | MOSFET drain | Load side |
| MOSFET source | 1 ohm sense resistor to GND, and LM358 pin 2 | Feedback |
| Nano D9 | 10 k to LM358 pin 3, with 10 uF from pin 3 to GND | Current setting (filtered PWM) |
| LM358 pin 1 | 1 k resistor to MOSFET gate | Op-amp drives the gate |
| LM358 pin 8 and pin 4 | Nano 5V and GND | Op-amp power |
| Cell minus, Nano GND and INA219 GND | Joined together | Common ground |
| INA219 VCC, SDA, SCL | Nano 5V, A4, A5 | Sensor power and I2C |
| Heatsink | MOSFET tab | Cooling |
Code
Capacity printed on a cell is often optimistic, and the only way to know is to draw a steady current until the cell is empty and add up the charge. The op-amp holds the voltage across the 1 ohm resistor at the value set by the filtered PWM signal, so the load current stays steady while the cell voltage falls, and the INA219 records voltage and current every second. Safety comes first with lithium cells. Discharge only a single cell, and only a healthy one that is not swollen, dented or hot; set the cut-off voltage to 3.0 V and never lower; never leave the test unattended and keep it on a non-flammable surface. At 0.5 A on a 3.7 V cell the MOSFET dissipates about 1.5 W, so it needs the heatsink and will get hot. Compare a cheap cell with a brand-name one to see the difference. If the cell has its own protection circuit, it may cut off before the set voltage, which is normal. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Battery discharge analyser: discharges one cell at a constant current and logs time, voltage, current and mAh as CSV.
// Library: Adafruit INA219. Board: Arduino Nano. Open the Serial Monitor at 115200 and copy the lines into a spreadsheet.
// Use a SINGLE cell only. Set CUTOFF for the cell type: Li-ion/LiPo 3.0 V, NiMH 0.9 V, alkaline 0.8 V.
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina;
const float CURRENT_A = 0.5; // discharge current: 1 ohm sense resistor means 0.5 V across it
const float CUTOFF_V = 3.0;
const byte PWM_PIN = 9;
float mAh = 0;
unsigned long lastMs = 0, startMs = 0;
bool done = false;
void setup() {
Serial.begin(115200);
ina.begin();
analogWrite(PWM_PIN, 0);
Serial.println("Fit the cell, then press Enter to start.");
while (!Serial.available()) {}
while (Serial.available()) Serial.read();
Serial.println("seconds,volts,milliamps,mAh");
int duty = (int)(CURRENT_A * 255.0 / 5.0); // filtered PWM gives duty x 5 V at the op-amp input
analogWrite(PWM_PIN, duty);
startMs = lastMs = millis();
}
void loop() {
if (done) return;
delay(1000);
unsigned long now = millis();
float v = ina.getBusVoltage_V();
float ma = ina.getCurrent_mA();
mAh += ma * (now - lastMs) / 3600000.0;
lastMs = now;
Serial.print((now - startMs) / 1000); Serial.print(','); Serial.print(v, 3); Serial.print(','); Serial.print(ma, 0); Serial.print(','); Serial.println(mAh, 1);
if (v < CUTOFF_V) { analogWrite(PWM_PIN, 0); done = true; Serial.print("Done. Capacity "); Serial.print(mAh, 0); Serial.println(" mAh"); }
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
Fit the cell, then press Enter to start.
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Bench supply | Current close to the set value |
| During discharge | Voltage slowly falls |
| At cut-off | Load turns off, capacity printed |
| Spreadsheet | Plot shows a falling curve |
If it does not work
Current is wrong
Check the sense resistor value and the op-amp wiring.
MOSFET very hot
Lower the current or enlarge the heatsink.
Stops too early
The cell's own protection may have acted.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the battery discharge curve analyser?
Arduino Nano, MOSFET IRLZ44N, Wirewound resistor 1 Ω 10 W, LM358 Op-Amp, INA219 Current Monitor, Heatsink TO-220, USB A to micro-USB cable (data), Resistor 10 kΩ, Resistor 1 kΩ and Electrolytic capacitor 10 µF. Wirewound resistor 1 Ω 10 W: Current sense.
How long does the battery discharge curve analyser take to build?
About 240 minutes for a intermediate maker, in 7 steps.
How do I know the battery discharge curve analyser works?
Bench supply: Current close to the set value. During discharge: Voltage slowly falls. At cut-off: Load turns off, capacity printed.
Current is wrong: what should I check?
Check the sense resistor value and the op-amp wiring.
MOSFET very hot: what should I check?
Lower the current or enlarge the heatsink.
Stops too early: what should I check?
The cell's own protection may have acted.
