Build it step by step
0 of 8 doneWire the INA219
Check it reads a cell voltage with the load off.
Add the load switch
Wire the MOSFET and 10 Ω resistor.
Test with a short run
Run for a minute and check current is about 150 mA.
Run the alkaline cell
Save the CSV from the serial monitor.
Run the NiMH cell
Use a fully charged cell and repeat.
Compare
Plot voltage against time and compare the mAh.
Note the end point
See how each cell's voltage falls near the end.
Recycle spent cells
Take them to a battery recycling point.
How do you build a compare AA battery types?
Discharge alkaline and NiMH AAs at the same load and compare capacity and voltage curves. You need AA alkaline battery, AA NiMH rechargeable 2000 mAh, INA219 Current Monitor, Arduino Nano, Resistor 10 Ω, MOSFET IRLZ44N, Resistor 10 kΩ, Resistor 220 Ω, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 8 steps and about 240 minutes.
- Level
- Beginner
- Time
- About 240 min
- Parts
- 10
Parts list
- BatteriesBuy
- BatteriesBuy
- SensorsBuy
- Development BoardsBuyArduino Nano × 1
- PassivesBuyResistor 10 Ω × 1
- SemiconductorsBuyMOSFET IRLZ44N × 1
- PassivesBuyResistor 10 kΩ × 1
- PassivesBuyResistor 220 Ω × 1
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| INA219 VCC | Nano 5V | Power |
| INA219 GND | Nano GND | Ground |
| INA219 SDA | Nano A4 | I2C data |
| INA219 SCL | Nano A5 | I2C clock |
| Cell + | INA219 VIN+ | High-side current sense |
| INA219 VIN- | 10 Ω resistor then IRLZ44N drain | Load path |
| IRLZ44N source | Cell - and Nano GND | Common ground |
| Nano D5 | 220 Ω resistor then IRLZ44N gate | Switches the load |
| 10 kΩ resistor | IRLZ44N gate and ground | Pull-down so the load is off at reset |
Code
Test only single AA cells, one type at a time, with the same 10 Ω load, which draws about 150 mA at 1.5 V and gives the resistor about 0.2 W, so use a resistor rated 0.5 W or more and expect it to feel warm. Do not test damaged cells, lithium-ion cells or anything but AA alkaline and NiMH here. Discharging stops at 0.9 V, the usual end point; going lower can damage rechargeable cells. A 2000 mAh NiMH cell should give roughly 1700 to 2000 mAh at this load and an alkaline cell often a little less at the same current, with a falling voltage curve. Run the test in a safe place and do not leave it overnight unwatched; the MOSFET switches the load off at the end. Take the cell out when finished. Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones).
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).
// Library: Adafruit INA219. Logs time, volts, mA and mAh every 10 seconds, stops at 0.9 V.
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina;
const byte LOAD = 5;
const float CUTOFF_V = 0.9;
float mah = 0;
unsigned long last, startMs;
bool running = true;
void setup() {
Serial.begin(9600);
pinMode(LOAD, OUTPUT); digitalWrite(LOAD, LOW);
if (!ina.begin()) { Serial.println("INA219 not found"); while (1) {} }
Serial.println("seconds,volts,ma,mah");
digitalWrite(LOAD, HIGH);
startMs = last = millis();
}
void loop() {
if (!running) return;
unsigned long now = millis();
if (now - last >= 10000) {
float dt = now - last; last = now;
float v = ina.getBusVoltage_V();
float ma = ina.getCurrent_mA();
mah += ma * dt / 3600000.0; // milliamps times hours
Serial.print((now - startMs) / 1000); Serial.print(",");
Serial.print(v, 3); Serial.print(","); Serial.print(ma, 1); Serial.print(",");
Serial.println(mah, 1);
if (v < CUTOFF_V) {
digitalWrite(LOAD, LOW); // stop the discharge
running = false;
Serial.println("done");
}
}
}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.
seconds,volts,ma,mah
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Load on | About 150 mA from a fresh cell |
| Voltage curve | NiMH flatter than alkaline |
| Capacity | NiMH 1500 to 2000 mAh, alkaline 1500 to 2500 mAh depending on brand |
| End | Load switches off at 0.9 V |
If it does not work
INA219 not found
Check I2C wiring and power.
Current zero
Check the MOSFET gate and the load path.
Resistor very hot
Use a higher rating or a cell with lower voltage.
Capacity looks low
Check contacts and that the cell was fully charged.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the compare AA battery types?
AA alkaline battery, AA NiMH rechargeable 2000 mAh, INA219 Current Monitor, Arduino Nano, Resistor 10 Ω, MOSFET IRLZ44N, Resistor 10 kΩ, Resistor 220 Ω, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the compare AA battery types take to build?
About 240 minutes for a beginner maker, in 8 steps.
How do I know the compare AA battery types works?
Load on: About 150 mA from a fresh cell. Voltage curve: NiMH flatter than alkaline. Capacity: NiMH 1500 to 2000 mAh, alkaline 1500 to 2500 mAh depending on brand.
INA219 not found: what should I check?
Check I2C wiring and power.
Current zero: what should I check?
Check the MOSFET gate and the load path.
Resistor very hot: what should I check?
Use a higher rating or a cell with lower voltage.
Capacity looks low: what should I check?
Check contacts and that the cell was fully charged.
