Introduction: DIY Arduino Battery Capacity Tester - V1.0

Picture of DIY Arduino Battery Capacity Tester - V1.0

[ Play Video ]
I have salvaged so many old lap-top batteries ( 18650 ) to reuse them in my solar projects.It is very difficult to identify the good cells in battery pack.Earlier in one of my Power Bank Instructable I have told, how to identify good cells by measuring their voltages, but this method is not at all reliable.So I really wanted a way to measure each cell exact capacity instead of their voltages.

Few week ago, I have started the project from the basics.This version is really simple one,which is based on Ohms Law.The accuracy of the tester won’t be 100% perfect, but it does give reasonable results that can be used and compared with other battery, so you can easily identify good cells in a old battery pack.

During my work I realised, their are lot of things which can be improved.In future I will try to implement those things. But for the time being I am happy with it.I hope this little tester will be useful, so I am sharing it with you all.

Note : Please dispose the bad batteries properly.

Disclaimer: Please note that you are working with Li Ion battery which is highly explosive and dangerous . I cannot be held responsible for any loss of property, damage, or loss of life if it comes to that. This tutorial was written for those who have knowledge on rechargeable lithium ion technology.Please do not attempt this if you are novice. Stay Safe.

Step 1: Parts and Tools Required :

Parts Required :

1. Arduino Nano (Gear Best )

2. 0.96" OLED Display ( Amazon )

3. MOSFET - IRLZ44 ( Amazon )

4.Resistors ( 4 x 10K , 1/4W ) ( Amazon )

5. Power Resistor ( 10R, 10W ) ( Amazon )

6. Screw Terminals ( 3 Nos) ( Amazon )

7.Buzzer ( Amazon )

8.Prototype Board ( Amazon )

9. 18650 Battery Holder ( Amazon )

10. 18650 Battery ( GearBest )

11. Spacers ( Amazon )

Tools Required :

1. Wire Cutter / Stripper ( Gear Best )

2.Soldering Iron ( Amazon )

Instrument Used :

IMAX Balance Charger ( Gearbest )

Infrared Thermometer Gun ( Amazon /Gearbest)

Step 2: Schematic and Working

Picture of Schematic and Working

Schematic :

To understand the schematic easily,I have drawn it on a perforated board also.The positions of the components and wiring are similar to my actual board.The only exception are the buzzer and OLED display. In the actual board they are inside but in the schematic they are lying outside.

The design is very simple which is based on Arduino Nano. An OLED display is used to display the battery parameters.3 screw terminals are used for connecting battery and the load resistance.A buzzer is used for giving different alerts.Two voltage dividers circuit are used to monitor the voltages across the load resistance.The function of the MOSFET is to connect or disconnect the load resistance with the battery.

Working :

Arduino check the battery condition, if the battery is good, gives command to switched ON the MOSFET. It allows current to pass from the positive terminal of the battery, through the resistor, and the MOSFET then completes the path back to the negative terminal. This discharges the battery over a period of time.Arduino measures voltage across the load resistor and then divided by the resistance to find out the discharge current. Multiplied this by the time to obtain the milli amp-hour ( capacity ) value.

Step 3: Voltage,Current and Capacity Measurement

Voltage Measurement

We have to find the voltage across the load resistor.The voltages are measured by using two voltage divider circuits.It consists of two resistors with values 10k each. The out put from the divider is connected to Arduino analog pin A0 and A1.

Arduino analog pin can measured voltage up to 5V, in our case the maximum voltage is 4.2V (fully charged) .Then you may ask, why I am using two divider unnecessarily.The reason is that,my future plan is to use the same tester for multi chemistry battery.So this design can be adapted easily to achieve my goal.

Current Measurement :

Current (I) = Voltage ( V ) - Voltage drop across the MOSFET / Resistance (R)

Note : I am assuming the voltage drop across the MOSFET is negligible.

Here , V = Voltage across the load resistor and R = 10 Ohm

The result obtained is in amperes.Multiply 1000 to convert it into milli amperes.

So maximum discharge current = 4.2 / 10 = 0.42A = 420mA

Capacity Measurement :

Stored Charge ( Q ) = Current ( I ) x Time (T ).

We have already calculated the current,the only unknown in the above equation is time.The millis() function in Arduino can be used to measured the elapsed time.

Step 4: Selecting ​Load Resistor

Picture of Selecting ​Load Resistor

The selection of load resistor is depend on the amount of discharge current we need.Suppose you want to discharge the battery @ 500mA, then the resistor value is

Resistance ( R ) = Max Battery Voltage / Discharge Current = 4.2 /0.5 = 8.4 Ohm

The resistor needs to dissipate a bit of power, so size does matter in this case.

Heat dissipated = I^2 x R = 0.5^2 x 8.4 =2.1 Watt

By keeping some margin you can choose 5W. If you want to more safety use 10W.

I used 10 Ohm ,10W resistor instead of 8.4 Ohm because , it was in my stock that time.

Step 5: Selecting the MOSFET

Picture of Selecting the MOSFET

Here MOSFET is act like a switch.The digital output from the Arduino pin D2 controls the switch. When 5V (HIGH) signal is fed to the gate of the MOSFET, it allows current to pass from the positive terminal of the battery, through the resistor, and the MOSFET then completes the path back to the negative terminal. This discharges the battery over a period of time.So the MOSFET should be chosen in such a way that it can handle maximum discharge current without overheating.

I used a n-channel logic level power MOSFET-IRLZ44. The L shows that is a logic level MOSFET. A logic level MOSFET means that it is designed to turn on fully from the logic level of a microcontroller. The standard MOSFET (IRF series etc) is designed to run from 10V.

If you use an IRF series MOSFET,then it will not fully turned ON by applying 5V from arduino. I mean the MOSFET will not carry the rated current.To tuned ON these MOSFETs you need an additional circuit to boost the gate voltage.

So I will recommend to use a logic level MOSFET, not necessarily IRLZ44.You can use any other MOSFET also.

Step 6: OLED Display

Picture of OLED Display

To display the Battery Voltage,discharge current and capacity, I used a 0.96" OLED display.It has 128x64 resolution and uses I2C bus to communicate with the Arduino. Two pins SCL (A5), SDA (A4) in Arduino Uno are used for communication.

I am using U8glib library to display the parameters.First you have to download the U8glib library .Then installed it.

If you want to get started in to OLED display and Arduino , click here

The connections should be as follows

Arduino --> OLED

5V --->Vcc


A4----> SDA

A5----> SCL

Step 7: Buzzer for Warning

Picture of Buzzer for Warning

To provide different warning or alert, a piezo buzzer is used.The different alerts are

1. Battery Low Voltage

2.Battery High Voltage

3. No Battery

The buzzer have two terminals, the longer one is positive and the shorter leg is negative.The sticker on the new buzzer have also " + " marked to to indicate the positive terminal.

The connections should be as follows

Arduino --> Buzzer

D9--> Positive terminal

GND--> Negative terminal

In the Arduino Sketch, I have used a separate function beep() which sends the PWM signal to the buzzer, waits for a small delay, then turns it off, then has another small delay. Thus, it beeps once.

Step 8: Making the Circuit

Picture of Making the Circuit

In the previous steps, I have explained the function of each of the components in the circuit. Before jump to make the final board, test the circuit on a bread board first.If the circuit works perfectly on the bread board,then move to solder the components on the protype board.

I used 7cm X 5cm prototype board.

Mounting the Nano : First cut two rows of female header pin with 15 pins in each.I used a diagonal nipper to cut the headers.Then solder the header pins.Be sure the distance between the two rails fits the arduino nano.

Mounting OLED Display : Cut a female header with 4pins. Then solder it as shown in picture.

Mounting the terminals and components : Solder the remaining components as shown in pictures

Wiring : Make the wiring as per schematic.I used colored wires to make the wiring, so that I can identify them easily.

Step 9: Mounting the Standoffs

Picture of Mounting the Standoffs

After soldering and wiring,mount the standoffs at 4 corners.It will provide sufficient clearance to the soldering joints and wires from the ground.

Step 10: Software

Picture of Software

The software doing the following tasks

1. Measure voltages

Taking 100 ADC samples , adding them and averaging the result.This is done to reduce the noise.

2. Check the battery condition to give alert or start the discharge cycle


i) Low-V! : If the battery voltage is below the lowest discharge level ( 2.9V for Li Ion )

ii) High-V! : If the battery voltage is above the fully charged condition

iii) No Battery! : If the battery holder is empty

Discharge Cycle

If the battery voltage is within the low voltage ( 2.9V )and high voltag (4.3V),discharge cycle start.Calculate the current and capacity as explained earlier.

3. Display the parameters on the OLED

4. Data logging on serial monitor

Download the Arduino Code attached below.

Step 11: Exporting Serial Data and Plotting on Excel Sheet

Picture of Exporting Serial Data and Plotting on Excel Sheet

To test the circuit, first I charged a good Samsung 18650-26F battery using my IMAX Charger.Then put the battery in to my new tester.To analyse the entire discharge process,I export the serial data to a spread sheet.Then I plotted the discharge curve.The result is really awesome.I used a software named PLX-DAQ to do it. You can download it here.

You can go through this tutorial to learn how to use PLX-DAQ. It is very simple.

Note : It works only in Windows.

Step 12: Conclusion

Picture of Conclusion

After few testing I conclude that the tester result is quite reasonable.The result is 50 to 70mAh away from a branded battery capacity tester result.By using a IR temperature Gun, I measured the temperature rise in the load resistor also,the maximum value is 51 deg C.

In this design the discharge current is not constant, it depends on battery voltage.So the discharge curve plotted is not similar to the discharge curve given in the battery manufacture data sheet.It only support a single Li Ion Battery.

So in my future version I will try solve the above short comings in the V1.0.

Credit : I would like to give credit to Adam Welch, whose project on YouTube was inspired me to start this project.You can watch his YouTube video.

Please suggest any improvements.Raise a comments if any mistakes or errors.

Hope my tutorial is helpful.If you like it,don't forget to share :)

Subscribe for more DIY projects. Thank You.


emreaytac (author)2018-01-14

Hi; I don't have 10 Ohm, 10W resistor. Can I use 10 Ohm, 11W resistor instead? Or should I use 2 pcs 10 Ohm, 5W resistors with parallel connection? I want to use 11W resistor if the results won't change.


ВалерийФ (author)2017-11-30

Can you give a connection diagram? accurate, simple.

xxreef made it! (author)2017-10-28

Great instructable, I redo It with some addition, for now I have tested only 18650 battery.

I add temperature control, and selection of battery type.

It's work good, but need help to debug and complete with new features ;).

BartoszD13 (author)2017-10-26

Can you give a connection diagram? accurate, simple.

Fredrik1997 made it! (author)2017-09-30

Thank you, nice tool! I think there is a fault in the wiring diagram, the two resistors are not connected to ground?

kordinaryus (author)2017-06-14

hi, can i use IRZF44N instead of IRLZ44? here is the datasheet;


MrEliptik (author)kordinaryus2017-09-30

I'm responding really late to this question, but it may help others.. The IRLZ44 is a logic FET. If you look in the datasheet, the VGSth is 1-2V, wich means that to be controlled, you need that amount of voltage. The arduino can easily provide that amount from one pin. On the other hand, the IRZF44N has a VGSth of 2-4V. And in some case it's not certain that the Arduino could provide that amount. To be sure, you could had a bipolar transistor, controlled by the arduino, that will trigger the FET.

ArmağanD (author)kordinaryus2017-07-29

you can use 5v relay

kordinaryus (author)kordinaryus2017-06-16

any idea?

Vitenuto (author)kordinaryus2017-06-18

Yes, you can use IRZF44N instead of IRLZ44 -> im using it too and it working (i think :D )

CristóbalT (author)2017-09-13

Hi. A silly question: Can I use this design as a current sensor? I have another design based on an arduino and I would like to measure its actual consumption (~ 1mA).

jarno.orasmae made it! (author)2017-08-28

I made one also :) I used 2x 10 ohm resistors to get 600 - 700ma discharge.

rohanrj (author)2017-08-27

Arduino: 1.6.4 (Windows 8.1), Board: "Arduino Uno"

FGQXC7WISCBU04F.ino:8:20: fatal error: U8glib.h: No such file or directory
compilation terminated.
Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

jarno.orasmae (author)rohanrj2017-08-28

It means you are missing U8glib library. Install that first.

alin115 (author)2017-08-26

Hi. nice project, I'm planning to make one for myself but there's a thing. I'm wondering if it's possible to add some codes to measure the internal resistance?

I'm still learning about how to calculate internal resistance of a battery properly, however, it seems like it shouldn't be a problem here cause we have the voltage, current and the resistance of resistors.

you know it's important to measure the internal resistance if you're going to make parallel battery packs.

iUYE made it! (author)2017-08-11

Hi. This is a nice piece especially if you are in doubt of a certain cell. I Managed to put it together on a bread board. I couldn't find a 0.96" OLED but i had acess to a 0.91" OLED and modified the code a bit to fit the text on the screen. Also i was not able to get a single 10Ohm resistor but instead used two 5 Ohms resistors in series at 5 Watts each. I hope there won't be any implication on the performance though. Am also yet to receive my 18650 battery holder. Am just using some neodymium magnets to make contact with the jumpers to the board. Currently testing my first battery. So far so good..

PanS3 (author)2017-08-04

Hello. Awesome project, thanks for the effort! I have one little question - if I would like to do it for multiple 18650 batteries - how should I modify this project? For example - having 4 or 8 batteries being tested at the same time? Any hints? Thanks in advance.

Inverted 18650 (author)2017-07-18

Why isn't the code made public? You must buy a subscription to see it. At least the inventer, Adam, shared it for free!

Vitenuto (author)2017-06-18

Why is in program current calculated by "(Bat_Volt - Res_Volt) / Res_Value"?

Because Bat_Volt (battery voltage) is the same like Res_Volt (load resistor voltage) isnt it? (If i assumed that voltage on MOSFET is negligible)

Anyway thank you for tutorial i made it and it working, i think, good -> i add battery LiIon charger module so i have one device with all.

gotes made it! (author)2017-06-14

Nice project.. The results are not perfect, but can give a reasonably good measurement of a cell's capacity. I found that powering the device with a 7V+ power supply on the VIN pin gave a more reliable 5V supply (mine was 4.98 as opposed to 4.5 from the USB). I also added time elapsed and power to the display. I didn't have a MOSFET so I just used a jumper to switch the load on and off. Obviously this requires that I pay attention to the voltage so I can turn it off at the right point!

deba168 (author)gotes2017-06-14

Congratulations !

Thank you so much for sharing your build.

AkhilS66 (author)2017-04-03

Can you explain for 12V battery

what will be resistors values used in that case.

gotes (author)AkhilS662017-06-13

I built mine based on a maximum voltage of 25V. I used 20k and 5.1k resistors. I basically had to go through all the various values of resistor I had available to try to find the closest match. For 12V I would go for a maximum of 15V as it's a multiple of 5. A good pair would be 15k and 7.5k, giving you a 1/3 divider. You will need to change the code in the sampling part of the sketch for the new divider ratio; change the multiplier from 2 to 3 (e.g. Bat_volt = 3* sample1 *Vcc/ 1024.0).

gotes (author)gotes2017-06-13

(Should probably be 3.0 rather than 3, to make sure it's interpreted as a float)

GlenL22 made it! (author)2017-05-30

Thanks, I made this tonight and have it running now. Looking at the serial data there is no actual time! Your Plotted data has time, is this something I have missed?

kordinaryus (author)2017-05-12


there are 4 resistors on the board, and 5 resistors on the schematic. what am i missing here?

aaronhernan (author)kordinaryus2017-05-19

Te big one. The load resistor.

SachinS119 (author)2017-04-08

I'm not able to find the code pls help

miclouff (author)2017-03-24


I would like to use a rotary switch to select 400mAh, 1A and 1.5A. I need to change the Arduino code ?

Aviyahalom made it! (author)2016-10-19

Excellent Instructable. Thank you very much. I constructed mine and it's working perfectly. Just a word to those who may be following the pictorial diagram of the circuit - there seems to be a connection missing between the 10k resistors and ground.

As you'll see from the photo below, I attached a TP4056 Lithium Cell Charger Module to the 18650. This prevents the battery from discharging beyond its recommended voltage.

LuizG25 (author)Aviyahalom2017-03-23

I have a job just like yours, but I stopped at the discharge, you found something?

deba168 (author)Aviyahalom2016-10-19

Congrats !

You are right, I missed the ground connection in the bread board circuit.Thanks for pointing out the error.

JitendraV6 (author)2017-03-17

hey man i could'nt find the sketch(code) for this project ?where can i get this pls rply soon..! thank you

hsurya (author)2017-03-07

Hi, can this circuit used also for measuring 12V VRLA Battery from 7ah - 200 ah ,Is it need modifying the circuit.Thanks

anthonyjclarke made it! (author)2017-03-07

Nice work! Works perfectly... I just see an inconsistency from reported Vcc on the OLED vs that of my Multimeter.. need to work out why... Is there some calibration required?

Livewire85 made it! (author)2017-01-17

Hi, Thanks for the great project I really enjoyed making it and it will come in very handy for testing all my old batteries, I have attached a photo of my made tester but as you can see there is quite a big difference between the battery voltage and the voltage the arduino is seeing, Im not using the exact mosfet you have listed im using IRLB3034 (have ordered one and just waiting for it to arrive) I was just wondering if there were any other options I could change to get the correct readings. Thanks

JitendraV6 (author)Livewire852017-01-26

Hey dude can i get d skecth n pin diagram ok ardiuno mini..
Rply soon

Livewire85 (author)JitendraV62017-01-27

Sorry but im not using this one anymore, it wasnt accurate enough for me

Livewire85 (author)Livewire852017-01-27

All the info is in the above project description.....make sure you click "see all steps"

JitendraV6 (author)2017-01-26

Hey man can i get d skecth...

Chewienator (author)2017-01-24

hi, can this work on other rechargable types of batteries? like Nimh, or nicd? i am thinking that it would need more settings for the high low voltage.

great instructable, will be building it soon.

deba168 (author)Chewienator2017-01-25

Yes it can be modified to work with other battery chemistry.

kennyheng (author)2016-12-27

Mr Deba, i got a question on tis board build ... how to actually read the capacity? "My case: i charge up my battery, did the voltage test and its at 4.16v then i put it in the this board, it sound up at 3.44v with 669mAh"

AchillesMyt made it! (author)2016-12-05

Thank you! This is really useful

deba168 (author)AchillesMyt2016-12-05

Thanks for sharing the pictures.

AchillesMyt (author)deba1682016-12-12

No problem! :)
I've uploaded a video on my YouTube channel talking about the project. Here's the link:

Please correct me if I've messed anything up :D

Thanks again! :)

botronics (author)2016-12-09

One thing I'm finding is once the battery reaches the low voltage point and is discharged, the program does not stop. When the cell voltage recovers, the program will reconnect the load resistor and continue to recycle. If left unattended, it may damage the battery. I would like to see the program disconnect the load and stop.

Romanio (author)2016-12-07

Hello! Mr. DeBa, this is a good project! I made a discharger with a Nokia 5110 display. I'm just starting to learn Arduino! Can you help with a sketch for nokia 5110? Thank you

AchillesMyt (author)2016-12-05

Thank you deba! :)

botronics (author)2016-11-27

Answered my own question. Moserial for Ubuntu works very well to log data from Arduino.

About This Instructable




Bio: I am an Electrical Engineer.I love to harvest Solar Energy and make things by recycling old stuffs. I believe ""IF YOU TRY YOU MIGHT ... More »
More by deba168:DIY Professional 18650 Battery PackDIY Acrylic RGB LED SignHow to Make a Bench Power Supply
Add instructable to: