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

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.

<p>Wondering if anyone could offer me advice - wired as diagram - 2.2ohm load resistor, 1.25V NiMH AAA battery (voltage measured by multimeter), F12N1OL FET.</p><p>Arduino reads around 0.9V and calculated current to be around 380mAh - measured current is 125ma with multimeter and battery voltage around 1.25V.</p><p>Load resistor confirmed at 2.2Ohm on multimeter.</p><p>Total resistance battery --&gt; load resistor --&gt;fet --&gt; ground (when fet held at 5v manually) is 6Ohms</p><p>Tried adjusting ardunio programme to 6Ohm load but didnt make any more accurate with voltage.</p><p>What am I doing wrong?</p><p>many thanks</p>
<p>Actually we can recondition batteries in <a href="http://batteryguide2016.batteryrecover.com/" rel="nofollow">simple way</a></p><p>Thank you Gregory ! :)</p>
<p>I make it for li-ion </p><p>code on http://trax-palicaru.blogspot.ro/</p>
<p>I'm in test the schematic just with for 2 battery, phically I put just one :))</p>
<p>Nice project!</p><p>But there is a little indistinctness:</p><p>It is assumed that the VREF Voltage is permanently 5V, but this would never happend! (Depends on the power supply....)</p><p>Remedy: Use the internal VREF 1.1V and use the variable:</p><p>Code getting the real internal voltage (sorry, original author is unknown to me):</p><p>long readVcc() {</p><p> // Read 1.1V reference against AVcc</p><p> // set the reference to Vcc and the measurement to the internal 1.1V reference</p><p> #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)</p><p> ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);</p><p> #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)</p><p> ADMUX = _BV(MUX5) | _BV(MUX0);</p><p> #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)</p><p> ADMUX = _BV(MUX3) | _BV(MUX2);</p><p> #else</p><p> ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);</p><p> #endif </p><p> delay(2); // Wait for Vref to settle</p><p> ADCSRA |= _BV(ADSC); // Start conversion</p><p> while (bit_is_set(ADCSRA,ADSC)); // measuring</p><p> uint8_t low = ADCL; // must read ADCL first - it then locks ADCH </p><p> uint8_t high = ADCH; // unlocks both</p><p> long result = (high&lt;&lt;8) | low;</p><p> result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000</p><p> return result; // Vcc in millivolts</p><p>}</p><p>So with this function you get back a int value like 4988 (4,98V), so you have to exchange in the code the lines like:</p><p>[482] return map(analogRead(battery[batteryNum].batteryVoltagePin), 0,1023,0,5000);</p><p>into </p><p>return map(analogRead(battery[batteryNum].batteryVoltagePin), 0,1023,0,readVCC());</p>
<p>Hi matthiasl2,</p><p>Great modification, much more accurate and easier than changing 5000 in code !</p><p>I modified like this</p><p>long readVcc() {<br>ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);<br>delay(2); // Wait for Vref to settle<br>ADCSRA |= _BV(ADSC); // Start conversion<br>while (bit_is_set(ADCSRA,ADSC)); // measuring<br>uint8_t low = ADCL; // must read ADCL first - it then locks ADCH<br>uint8_t high = ADCH; // unlocks both<br>long result = (high&lt;&lt;8) | low;<br>result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000<br>return result; // Vcc in millivolts<br>}</p><p>and</p><p> return map(analogRead(battery[batteryNum].batteryVoltagePin), 0,1023,0,readVcc()); </p><p>and</p><p> return map(analogRead(battery[batteryNum].fetVoltagePin), 0,1023,0,readVcc());<br></p><p>Thx !!!! :)</p>
<p>Would it be possible for You to post the entire code with the changes?</p>
<p>@BrianH. Thanks for this instructable. After dabling myself with a similar project using the Arduino IDE monitor and relais to switch the load I came across your project. As has been commented before I must commend you for writing such clear code. It enabled me to adapt the code to make use of all four battery bays that are in the box of the commercial battery charger that I used to hold the batteries. I've used an arduino pro mini controller which has 8 analog inputs so I made the most of it.</p>
<p>2frabo: Can you share your code for four battery bays, please? I can rebuild the same old-charger :) Thank you in advance.</p>
<p>This looks like a similar product:</p><p>http://www.aliexpress.com/item/Rechargeable-battery-capacity-tester-1-5V-battery-tester-battery-tester-with-power/32328616303.html</p>
<p>Want to ask if this circuit (project) charges and then discharges the battery? And if yes, can I make multiple desired amount of cycles of charging discharging process?</p>
<p>It does not charge the battery. It discharge it.</p><p>By discharging, it can measure the battery capacity.</p>
<p>Hi.</p><p>I was able build it, however when not using 1 battery (1 transistor) it shows the other 2 are not connected, but it shows nore than 1V and the mAh start to increment even if there's no battery in the compartment.</p><p>Any help will be appreciated.</p><p>Regards,</p>
<p>This is how the project looks like</p>
<p>Hi Brian,</p><p>Great idea, great job!</p><p>Just finished to build it on breadboard and it looks like it's working \o/.</p><p>My main goal was to test 18650 batteries (Li-Ion / 3.7V) . So I modified as folow:</p><p>- 10 Ohms Load resistor. (10W)</p><p>So around 370mA discharge current, wich should give around 6 hours in theory to discharge a 2500mA cell. 3.7V x 0.37A = 1.4W Power (so 10W is fine and is around 45 degrees celcius during discharge)</p><p>- I used a MTP50N06V Mosfet and Arduino Nano clone</p><p>- I modified variables in code to match Nano pins and LOAD_RESISTANCE -&gt; 10 MAX_VOLTAGE -&gt; 4300 and NIMH_MIN_VOLTAGE -&gt; 3600 (NIMH could be renamed later) </p><p>So need further testing, and moving all to the stripboard...</p><p>Great work Brian.</p><p>Thank you</p>
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: https://www.instructables.com/files/deriv/F03/0UHH/HCV8LF9Q/F030UHHHCV8LF9Q.THUMB.jpg <br>can help?
<p>Have you installed the PCD8544 library?</p><p>If not, put the directory PCD8544 downloaded from <a href="https://github.com/carlosefr/pcd8544" rel="nofollow"> https://github.com/carlosefr/pcd8544 </a> into your Arduino library folder.</p>
<p>Is it possible to use a coil relay instead of MOSFET?</p>
<p>My circuit is slightly different because instead I used Rload 2.5&Omega; 2.2&Omega; (code changed). 2M&Omega; has been changed to 2.2M&Omega; (only one was available). The transistor is STP80NF55-06 (0.0065&Omega;).<br><br>I question what I'm doing wrong that the circuit detects battery and works only 3 seconds and then shows you a &quot;test complite&quot;. Unfortunately, Arduino I am still too weak to deal with it. My English is not better :(</p>
<p>Hi </p><p>I created the circuit with a bit change in schematic &amp; code and added a push button to trigger test; so before pushing the button it only displays the battery voltage &amp; 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)</p><p>the more strange thing is after the test finishes that 0.2 comes back again!! and 2.7v becomes 2.9v !! </p><p>Why this happens? am I doing something wrong?</p>
<p>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.</p>
<p>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?</p>
<p>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.</p>
<p>Is it possible to modify this so that it can be used to test Lithium Ion batteries for cell phones?</p>
<p>Hi brayanH. </p><p>Thanks a lot for your good and useful project.</p><p>I'm bigginer. Is it possible for you to give me this project with 2x16 lcd and in a circut without Arduino board?</p><p>thanks.</p><p>Email: sadeghghafoori@yahoo.com</p>
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. <br> <br>Please help. Thank you.
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.
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.
you are definitely right, thanks <br> <br>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
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.
What about higher voltage, like Li-Po or Li-Ion, would that be possible? <br>Otherwise nice circuit, I also have some Ni-Mh to test
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.
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?
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?
@ PsychoDrake <br>Hi, <br> <br>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. <br>posting as a new topic, as it doesn't let me to post as a reply for an unknown reason...
very nice project, one small correction and one small question <br> <br>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 :) <br> <br>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 ?? <br> <br> <br>thanks again for the nice project :)
There are<u> two ways</u> 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 <a href="http://en.wikipedia.org/wiki/Resistor" rel="nofollow">http://en.wikipedia.org/wiki/Resistor</a>). 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).<br> <br> If you choose to use a different value for the resistor, the code must be modified appropriately.<br> 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.<br> <br>
Hey, Cool TUT<br>But The Code Isn't Opening In <br>Arduino IDE<br>Please Can You Send It To:<br>arduinocode@gmail.com OR<br>customer.support@labsvisual.com
You should be able to download the code from page 5 of the instructable.<br>Click on Rechargeable_Battery_Capacity_Tester.pde<br><br>If you are using Windows, It downloads with a weird filename (ending in .tmp)<br>you will need to rename it to &quot;Rechargeable_Battery_Capacity_Tester.pde&quot;<br><br>You will also need to get the file PCD8544.h it's a library from code.google.com<br>(google search for this file)<br><br><br>
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!<br> <br> 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:<br> <br> 1 VCC<br> 2 GND<br> 3 SCE<br> 4 RST<br> 5 D/C<br> 6 DNK(MOSI)<br> 7 SCLK<br> 8 LED<br> <br> What connection changes do I need to make to use this LCD?<br> Thanks in advance,<br> Mike
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.<br> <br> &diams;The pin labeled LED-&nbsp; on my diagram does not exist - I assume that it is internally connected to the GND wire.<br> &diams;The pin labeled Vout on my diagram does not exist, so it can be ignored and the 4.7uF capacitor can be omitted.<br> &diams;RES is the same as RST (Reset)<br> &diams;On my diagram SDIN pin (<u>S</u>erial <u>D</u>ata <u>IN</u>) is labeled DN(MOSI)<br> <br>
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! <br>lszxy100@qq.com <br>
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! <br>lszxy100@qq.com <br>
This is awsome, I want to try it!
Where did you find the battery holder
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 :)
The code is on page 5 of the instructable - I just verified that it can be downloaded successfully.

About This Instructable




More by BrianH:Car Podcast downloader and player The Household Informer Rechargeable Battery Capacity Tester 
Add instructable to: