Picture of Rechargeable Battery Capacity Tester

Do you have a pile of AA rechargeable batteries in your drawer? Some are old, some are new, but which sets would you bring with your camera on your next trip, and which ones are past their useful life? I like using rechargeable batteries, but I’m certain that some of them are not living up to the stated capacity on the label.

So how good are those batteries? Simple battery testers measure the voltage, but that’s not what we need – we want to find the overall capacity of the battery. How long will a battery last from the time it’s fully charged to the time that the “low battery” indicator comes on your device?

You can see this in action in a video in the last step of this instructable.

Step 1: This is a job for a microcontroller

Picture of This is a job for a microcontroller

A simple way to test a battery would be to attach a load resistance to a fully charged battery and monitor the voltage until it drops below its useful value. The amount of time the battery lasts indicates its capacity.
That is a quick solution to the problem, but it involves watching a voltmeter for a few hours. That’s no fun at all. With a microcontroller, like the good old AVR chip, we can make a rechargeable battery tester that does the work for us. My tester puts AA batteries through a discharge test and reports the capacity in milliamp-hours (mAh) so you can compare battery capacity.

Design features
The tester can test multiple cells individually, and display the results on an LCD.
The tester discharges the battery while monitoring the voltage of the batteries. When the low threshold is reached, that cell is done it disconnects the load from the battery. When all tests are complete a series of beeps alerts the user. The tester identifies the type of battery by its initial voltage allowing both NiCd and NiMh batteries to be tested.

The design is based on the ATMega168 (or 328) microcontroller, which has 6 A/D converters on the chip, so these will be used to read the battery voltages and determine the load current. Since each battery will require two A/D converters per cell, the maximum number of cells is three.

I built two of the testers, first using an Arduino board as a development system, and then a standalone device that will be more compact, and free up the Arduino for other projects.

xtreamx21 month ago

My circuit is slightly different because instead I used Rload 2.5Ω 2.2Ω (code changed). 2MΩ has been changed to 2.2MΩ (only one was available). The transistor is STP80NF55-06 (0.0065Ω).

I question what I'm doing wrong that the circuit detects battery and works only 3 seconds and then shows you a "test complite". Unfortunately, Arduino I am still too weak to deal with it. My English is not better :(

4r1y4n6 months ago


I created the circuit with a bit change in schematic & code and added a push button to trigger test; so before pushing the button it only displays the battery voltage & after that it begins the test; the strange thing is before test (before turning on the FET) battery voltage that arduino reads is the same value I measure with a multimeter but after turning on the FET battery voltage drops about 0.2V ( e.g. 3.97 becomes 3.80)

the more strange thing is after the test finishes that 0.2 comes back again!! and 2.7v becomes 2.9v !!

Why this happens? am I doing something wrong?

BrianH (author)  4r1y4n3 months ago

Your results are normal. A battery with a load on it will have a drop in voltage due to the battery's 'internal resistance'. An ideal battery would have zero internal resistance, but real-world batteries are imperfect, and act as if there is a small (fractions of an ohm) resistor in series inside the cell. This is the cause of the voltage drop that you see. This is why you should test a battery with a typical load on it rather than just a voltmeter for a better idea of the battery's true state.

dk_bis made it!9 months ago

It works! Thank you! Only minor changes - correct LCD connecting pins and comment out the strings about third battery. But I'm a little confused - it shows the reduced voltages (about -0.03V) when compared with measurements of battery with multimeter. Is my multimeter wrong or LOAD_RESISTANCE is measured with error?

2014-11-10 23.06.16_.jpg
BrianH (author)  dk_bis3 months ago

The 0.03 V difference is an acceptable tolerance - it should not affect your testing. It could be due to an resistor that is not exactly the correct value - or the Arduino A/D converter may be a little bit off.

Caudex1 year ago

Is it possible to modify this so that it can be used to test Lithium Ion batteries for cell phones?

sadeghjun1 year ago

Hi brayanH.

Thanks a lot for your good and useful project.

I'm bigginer. Is it possible for you to give me this project with 2x16 lcd and in a circut without Arduino board?


Email: sadeghghafoori@yahoo.com

Hi. I am having a couple problems here. I have built this but used 22 ohm load resistors and changed the code to match. the thing is that on 2500 mAh NiMH batteries that I am testing, I am getting over 1.3V and over 9999 mAh (then the capacity reading goes to ****). I am thinking that there is something wrong here.

Please help. Thank you.
BrianH (author)  professorred2 years ago
The 22 ohm resistor that you are using is almost 9 times larger than the value that I chose - this of course reduces the discharge rate and will cause the battery to take about 9 times longer to discharge - probably not an ideal way to test the battery, but since you changed the code (#define LOAD_RESISTANCE 22) the algorithm should work. Have you check the 22 ohm resistor to make sure it really reads 22 ohms? Is your MOSFET ok? As for the 1.3V - That is reasonable for fully charged NiCads/NiMh batteries.
Thank you for the response. As far as time goes, I do not mind it taking a long time. I used the measured value of the resistor in the code. I am not sure on the mosfet but it should be ok. I am getting the same result on all three batteries. I was curious about the voltage as that was after the circuit removed about 10,000 mAh on a 2,500 mAh battery. I am just confused.
BrianH (author)  professorred2 years ago
It sounds like the battery is not getting discharged at all if it still reads 1.3V. I'm thinking that the MOSFET might not be turning ON to start the discharge. What is the part number of MOSFET are you using? Are you sure you are have the Drain, Source and Gate wired correctly?
I could be wrong (I do not have it in front of me) but I believe that it is a MTP50N06V bought at RP Electronics. I used the blink sketch to control it and measured drain to source resistance. It went very low then very high.
wasteinc2 years ago
you are definitely right, thanks

one more small question if the resistances in parallel are different in value between them (but have the same total value) will the power be distributed equally between them or not. my hunch says no, but your answer would be more credible
BrianH (author)  wasteinc2 years ago
Your hunch is correct - you'll have to do the math on each resistor. Power dissipation in each resistor = Voltage squared divided by the resistance. The voltage will be the same for all parallel resistors, but the different resistance values will affect the individual resistor's power dissipation.
HarleyDK2 years ago
What about higher voltage, like Li-Po or Li-Ion, would that be possible?
Otherwise nice circuit, I also have some Ni-Mh to test
BrianH (author)  HarleyDK2 years ago
I designed the circuit with NiMh and NiCd in mind (1.2v). A minor redesign would be necessary to test higher voltage batteries - the discharge resistor would need to be properly sized for discharge rate, and power dissipation. Small changes needed to the code too.
staryhad2 years ago
Hi, I am getting different results with the same battery in 1st and 2nd battery bay (3rd bay is not connected, just grounded via the 2MOhm resistor). in bay1 it reads voltage above 1V and will start testing, however in bay2 it reads voltage just above 0,8V and will not test. in general it seems the voltage is always detected lower in bay2 (e.g. when I test 2 batteries and swap them, the 2nd bay always reads lower than the 1st). any idea what could it be?
BrianH (author)  staryhad2 years ago
Double check your wiring, and make sure that you use heavy gauge wire for the wires in the discharge path - especially the ground wire - otherwise the resistance in the wire will affect the readings. Does the battery in bay#2 read low voltage when it is the only battery under test - or just when it is tested in pairs?
staryhad12 years ago
@ PsychoDrake

you need to have the PCD8544 library in your Arduino\libraries directory. download it from http://pcd8544.googlecode.com/files/PCD8544-1.4.zip and extract to the abovementioned directory.
posting as a new topic, as it doesn't let me to post as a reply for an unknown reason...
PsychoDrake2 years ago
hi, im doing this project too and have a arduino uno. I have download the pde but when i try upload to arduino apear this: http://www.instructables.com/files/deriv/F03/0UHH/HCV8LF9Q/F030UHHHCV8LF9Q.THUMB.jpg
can help?
Sem T��tulo-1.jpg
wasteinc3 years ago
very nice project, one small correction and one small question

if you dont have a high power resistor, then you should connect 2 or 3 smaller of them in series not in parallel. 2x 1W resistors in series will withstand 2W of power :)

and the question is . while I have many power resistors around I dont have 2,5 ones. what would be the safe values to pursue ??

thanks again for the nice project :)
BrianH (author)  wasteinc2 years ago
There are two ways to get the desired resistance. Using several series resistors of smaller value as you suggested is one way, but you may have trouble finding the values you desired. Since I had higher valued resistors available to me, I chose to use a parallel circuit to achieve the 2.5 ohms. The correct value can be achieved with four 10 ohm resistors in parallel yielding 2.5 ohms, and the power is dissipated (as heat) equally in the four resistors. This can be calculated by the formula Power = Voltage squared divided by the resistance (see http://en.wikipedia.org/wiki/Resistor). If the FET was a perfect switch (zero ohms) then the single 2.5 ohm resistor would have 1.2 volts across it, and the power dissipated would be 0.576 watts. If we use four 10 ohm resistors in parallel, then using the above formula, each resistor dissipates only 0.144 watts. (Since the FET does have a small voltage drop across it, the actual voltage across the resistor is a bit lower - and therefore the power dissipated is lower).

If you choose to use a different value for the resistor, the code must be modified appropriately.
Ideally the load resistor should be chosen to draw the amount of current that you expect from the device you want to use the batteries in.

visuallabs4 years ago
Hey, Cool TUT
But The Code Isn't Opening In
Arduino IDE
Please Can You Send It To:
arduinocode@gmail.com OR
BrianH (author)  visuallabs4 years ago
You should be able to download the code from page 5 of the instructable.
Click on Rechargeable_Battery_Capacity_Tester.pde

If you are using Windows, It downloads with a weird filename (ending in .tmp)
you will need to rename it to "Rechargeable_Battery_Capacity_Tester.pde"

You will also need to get the file PCD8544.h it's a library from code.google.com
(google search for this file)

IF this method has not worked for you, you can click on the link for the pde in your web browser. When that opens, you can copy and paste the text from your browser into the Arduino program.
First of all, great instructable for a very useful device!

I sourced a Nokia 5110 LCD from a supplier (not taken from an actual cell phone) and the pin configuration is slightly different than you describe. On my LCD the pins are identified as:

5 D/C

What connection changes do I need to make to use this LCD?
Thanks in advance,
BrianH (author)  Mikey_Likes_It3 years ago
This should be no problem, but since the LCD that I used came from an actual Nokia Cell phone, the wiring is a bit different. So when you connect the display to the Arduino, be sure to use the signal names instead of my pin numbers. Also note that my wiring diagram shows some pins that are not found on the 'store bought' version of the 5110.

♦The pin labeled LED-  on my diagram does not exist - I assume that it is internally connected to the GND wire.
♦The pin labeled Vout on my diagram does not exist, so it can be ignored and the 4.7uF capacitor can be omitted.
♦RES is the same as RST (Reset)
♦On my diagram SDIN pin (Serial Data IN) is labeled DN(MOSI)

38293312 BrianH3 years ago
Hello, very interested to see your rechargeable battery capacity tester. I was one of China's electronics enthusiasts. Government wants your consent, modeled on the production of a tester, I hope you can schematics HEX file and AVR chip fuse bit configuration to me, sent to the following e-mail. Thank you very much, and bless you in China!
382933123 years ago
Hello, very interested to see your rechargeable battery capacity tester. I was one of China's electronics enthusiasts. Government wants your consent, modeled on the production of a tester, I hope you can schematics HEX file and AVR chip fuse bit configuration to me, sent to the following e-mail. Thank you very much, and bless you in China!
This is awsome, I want to try it!
rsmack3 years ago
Where did you find the battery holder
Aquatarkus4 years ago
Great project on this site. Unfortunately, the code for standalone version was not published, and since I don't have an Arduino board I have to re-write the code myself. It takes a lot of time and so far doesn't work, but hope never dies :)
BrianH (author)  Aquatarkus4 years ago
The code is on page 5 of the instructable - I just verified that it can be downloaded successfully.
hi trying to build your circuit it is great. i have the following lcd:

how would i change the code for it to work with it\/ or would i be better buying a 5110 screen?

BrianH (author)  paulryanmini4 years ago
The product you linked to has an I2C interface which is totally different from the one that I used - it would require significant changes to the code and the hardware connection to the arduino. The 5110 from sparksfun can be used as-is.
u047974 years ago
Great Project! I hope it will work for me.
msuzuki7774 years ago
Excellent job on this Instructable. I especially liked the professionally-written code. I have never seen better written code for the Arduino with structures and subroutines.

I also like and appreciate your use of MOSFETs and will try to incorporate them in a similar project of mine.

I do have one thought. It seems to me that with the MOSFETs that you used, there would be an insignificant voltage drop across it when it's on so that you could probably ignore it in your calculations. Did you ever measure that voltage in your testing? Anyway, if this was irrelevant, you could probably test four batteries at once instead of three. Of course, since you already have it built, it's just a thought.

Again, well done!

Lazy Old Geek
arnefl4 years ago
Great work! What is the button-1 connecting ground and dig. pin 10?
BrianH (author)  arnefl4 years ago
You've got a sharp eye for detail!
It was intended for a feature that I never got around to adding, but I accidentally left it on the schematic. I'll remove it when I get a chance.

KT Gadget4 years ago
For the resistor to make the slot read "0 volts" when empty (no battery inserted), can the resistor be greater than 2M Ohms, or does it specifically have to be a 2M ohm resistor?
BrianH (author)  KT Gadget4 years ago
The value of that resistor is not critical - It should be large enough to minimize discharge of the battery, but low enough to still cause the zero reading when no battery is inserted. If you have a 1 to 10M ohm resistor give it a try.
arnefl4 years ago
I downloaded the sketch and the pcd8544.h , but it will not compile.
Lots of error messages like the one below:

undefined reference to `PCD8544::setCursor(unsigned char, unsigned char)'
arnefl arnefl4 years ago
Never mind. The folder in libraries had to be named "PCD8544"
newrev4264 years ago
Can you suggest a specific mosfet? Would a TIP31A transistor work as well instead? Can handle 3A and they seem to be a lot cheaper what is your professional opinion?
BrianH (author)  newrev4264 years ago
What we need for the circuit is a device that will switch on the resistive load with as little additional resistance as possible. That means the voltage between the Collector / Emitter should be as close to zero as possible.

I looked at the spec sheet, and the TIP31A says the Vce when fully saturated is 1.2 volts. That's WAY to high for this circuit. The transistor may be able to handle the current, but the effective resistance will be too high (at 1 amp it would be about 1.2 ohms). The 3103 MOSFET spec sheet specifies the Resistance to be about .012 ohms (12 milli-ohms). (Don't confuse little 'm' milli with big 'M' Mega Ohms)

I find that Transistors spec sheets talk about the voltage drop across the Collector and Emitter, while MOSFETS typically give ratings of the resistance across the Drain and Source.

That said, you can probably find an inexpensive substitute with similar characteristics, but it looks like MOSFETS are the way to go. I chose the one I did because it was available (on an old PC motherboard). I then Googled the partnumber looked for the RDS and I was in business.

I see that RadioShlock also sells the  IRF510 MOSFET, but the spec sheet says it has  a Drain to Source Resistance of 0.54 ohms which is a bit high too. Mouser.com, Alliedelec.com  and Jameco.com carry a large number of MOSFETS - under a dollar each. Check the spec sheets and look for low Drain to Source Resistance  (RDS)

Here's a link I found that discusses Vce (for transistors):

Wow I was expecting a yes or a no but man I love the response! I appreciate the time you spent and you explained it very well. Trying to go to school for this stuff and I can always use more info. Thanks!
duncan_a4 years ago
Brilliant - just what we need in our house...

Only problem is, I can't locate Nokia 5510 LCD screens on eBay on either side of the Atlantic (I'm in the UK) - are there other screens that would work?
arnefl duncan_a4 years ago
eBay item 200399485981 from seller szdigitalsquare $8.00 and free shipping. It also has an adapter PCB
BrianH (author)  duncan_a4 years ago
Sparkfun.com sells them for $9.95 and ships internationally. They also have other related goodies.


Their display is a lot easier to work with. I had to carefully cut the circuit board that was in the phone and solder small wires to make the display usable. But since I had it on hand I made use of it.

I didn't immediately get that the part specified is the LCD FOR the Nokia 5510 cell phone. I googled "nokia 5510 lcd" and found that the LCD for the Nokia 5510 is widely available as a repair/replacement part online in the price range 4.00 to 9.00 GBP (plus tax and shipping). You can probably get one locally from a cell phone store that does repairs.

Here are a few links I found:



KT Gadget4 years ago
This is a great instructable and I've been trying to find something that would test a lot of the rechargeable batteries I have at home. Gonna try and make this when I get the time.

One question though, does it matter what the wattage has to be for the load resistor or does it?
BrianH (author)  KT Gadget4 years ago
Yes - it will need to be 1 Watt or larger (See step 3).
ironsmiter4 years ago
ok, so Quick note for some of us... .PDE files open well in "wordpad" on windows systems.

Was just trying to look at the code, to determine what, if anything, would need to be changed besides the FET and load, to change it into a 18650 capacity tester.

AA batteries are nice, but nothing says power to weight like good, used laptop battery cells.

As a note, contrary to the code notes... a fully charged Li-Ion will read 4.2V NOT 3.6.

I'll have to dissect the code when I'm not so tired, unless you already have it sitting around? ;-)
I have a feeling there's going to be more to it than swapping 2 components, and a few variables. I think it best to simplify, and use a separate tester, instead of trying to cram all the functions into one little PIC. But I could be wrong. I don't have much experience with micros, other than burn-and-play with other peoples code.
BrianH (author)  ironsmiter4 years ago
I double checked my research, and you are correct - - it appears that the peak is 4.2, while the nominal charged cell voltage is 3.6 or 3.7 volts.
Thanks for the correction.
My tester will perform correctly since I disallow testing of anything over 1.7 volts.
ok, just thought I should re-comment....

This is GREAT looking project.
really well executed.
and useful to boot.

And the commenting in your code is VERY helpful to those of us just starting in the micro-controller arena. Bravo and 2 thumbs up!

And freehand routing the enclosure with a drill press? Impressive!
Thanks for your contribution to our collective knowledge.

My previous comment was driven more though despair at my lack of knowledge in this area, than from anything lacking in your 'Ible.
If you find the time or energy, it's be great if you could show the modifications needed for different battery types. A 'universal' modification list, to handle things like li-ion, li-po, 6/12V SLAs...

From the hardware standpoint, It still looks like it would only require recalculating the load resistor, making sure the mosfet can handle the current, and using different battery terminals. but the software code... I think that's a little beyond me at the moment :-(
jimk30384 years ago
Without digging into your code, I'm wondering, what voltage do you consider the battery to be drained. In other words, when do you stop draining the battery and consider it dead?

By the way, nice write up. Thanks.
0.95 Volts.

It's a constant defined in the first page of code.
Spokehedz4 years ago
You are my PERSONAL hero! I have piles of the 168's laying around from upgrading all my 'duinos to the 328... So this is going to be a nice use for them and all my piles of rechargeable batteries.
jrossetti4 years ago
I know this may be a really dumb question, but would we need the arduino bootloader on the chip, or would a plain-jane atmega328 work?
Arduino sketches work fine on "plain jane" atmega328/168/88/48s. (If they fit on the chip) The bootloader contains no runtime code. But, you have to have the ISP programmer and you need to set the clock speed flags.

With out the bootloader, there is no software inside the AVR that is listening to the AVR's serial port or waiting for the Arduino IDE commands. With out that software, you must use the AVR's built-in hardware mechanism to program the AVR. That built-in hardware works over the SPI port, not the serial port, and uses a different protocol.
That is awesome! Kudos to you good sir.

When I finally start learning how to do Microcontroller stuff, this will be on my list of projects. (Though I doubt it'll look as nice.)
SinAmos4 years ago
Oh, I like this and need this or do I?