Lithium Ion 18650 Battery Capacity Checker

Posted on 23/01/2016 by Adam

I created this fairly simple circuit and Arduino sketch to check the labeled capacity of Lithium Ion 18650 batteries. It could easily be adapted to other types of batteries and discharge more than one battery at a time. If you power your arduino from a computer and monitor the serial port you can obtain results as it goes along and create pretty graphs of the results.

The Code…

* Battery Capacity Checker
* Uses Nokia 5110 Display
* Uses 1 Ohm power resister as shunt - Load can be any suitable resister or lamp
* YouTube Video:
* http://AdamWelch.Uk
* Required Library - LCD5110_Graph.h -

#include "LCD5110_Graph.h"
LCD5110 myGLCD(5, 6, 7, 9, 8);  // Setup Nokia 5110 Screen SCLK/CLK=5, DIN/MOSI/DATA=6, DC/CS=7, RST=9 Chip Select/CE/SCE=8,
extern uint8_t SmallFont[];
extern uint8_t MediumNumbers[];

#define gatePin 10
#define highPin A0
#define lowPin A1

boolean finished = false;
int printStart = 0;
int interval = 5000;  //Interval (ms) between measurements

float mAh = 0.0;
float shuntRes = 1.0;  // In Ohms - Shunt resistor resistance
float voltRef = 4.71; // Reference voltage (probe your 5V pin) 
float current = 0.0;
float battVolt = 0.0;
float shuntVolt = 0.0;
float battLow = 2.9;

unsigned long previousMillis = 0;
unsigned long millisPassed = 0;

void setup() {

  Serial.println("Battery Capacity Checker v1.1");
  Serial.println("battVolt   current     mAh");

  pinMode(gatePin, OUTPUT);
  digitalWrite(gatePin, LOW);

  myGLCD.InitLCD(); //initialize LCD with default contrast of 70
  myGLCD.setFont(SmallFont); // Set default font size. tinyFont 4x6, smallFont 6x8, mediumNumber 12x16, bigNumbers 14x24

  myGLCD.print("Please Wait",CENTER,24);

void loop() {

  battVolt = analogRead(highPin) * voltRef / 1024.0;
  shuntVolt = analogRead(lowPin) * voltRef / 1024.0;
  if(battVolt >= battLow && finished == false)
      digitalWrite(gatePin, HIGH);
      millisPassed = millis() - previousMillis;
	  current = (battVolt - shuntVolt) / shuntRes;
      mAh = mAh + (current * 1000.0) * (millisPassed / 3600000.0);
      previousMillis = millis();

      myGLCD.printNumF(battVolt, 2,50,10);
      myGLCD.printNumF(current, 2,50,20);
  if(battVolt < battLow)
      digitalWrite(gatePin, LOW);
      finished = true;
      if(mAh < 10) {
        printStart = 40;
      else if(mAh < 100) {
        printStart = 30;
      else if(mAh <1000) {
        printStart = 24;
      else if(mAh <10000) {
        printStart = 14;
	  else {
	    printStart = 0;
      myGLCD.printNumF(battVolt, 2,50,10);
      delay(interval * 2);

You’ll have to forgive the simple nature of this schematic – It’s my first time using Fritzing schematics.

Parts list

Nokia 5110 Module:
Arduino Nano Clone:
1 Ohm 10w Resistor:
Aluminium Clad Power Resistor:
IRF3205 Mosfet:
Prototyping PCB:
Terminal Blocks:

What Others Are Saying

  1. John 29/01/2016 at 21:41

    Thanks for the project and code, much appreciated.

  2. George 09/03/2016 at 09:46

    Adam, just what I am looking for! You must be psychic lol.

    I have ordered some 1, 33.3 & 6.8 ohm resistors to make this. I already have the rest of the bits. I am planning on using a 55V 49A IRFZ44N N channel Mosfet in place of the one you used, can you see any difficulties/differences in using this?

    Thanks again and keep up the good work.


    • Adam 31/03/2016 at 15:14

      Thanks George! I can’t see any issue in using that mosfet – this project is low voltage and current really.

      • Martin 12/06/2016 at 12:40

        To use a MOSFET as a switch, you have to have its gate voltage some voltage (Vgs) higher than the source. If you connect the gate to the source you are ensuring the MOSFET is off (Vgs=0).

        The MOSFET you selected (IRFZ44N) is a “standard” MOSFET and only turns on when Vgs=10V or higher (up to the maximum rating of 20V, which you should stay away from), so 10V-15V is common for Vgs for this type of MOSFET.

        If you want to drive this from an Arduino, which only outputs 5V, you will need a “logic-level” MOSFET. For this type of MOSFET, Vgs=5V is enough to turn it on. For example, the ST STP55NF06L would be appropriate and is comparable to the IRFZ44N, except the STP55NF06L is logic-level.

        You should also have a resistor in series with the Arduino output to limit the current, since the MOSFET gate is highly capacitive and can draw a big instantaneous current when you try to turn it on (or off). 220 ohms or so is appropriate.

        • Nick 29/09/2016 at 18:03

          70t03h 40 Volts ,60 amperrs work good its a mosfet from old maibord ASUS used to set v core of CPU. but most put 100kohm rezistor to Gate from surce too dischare the Gate. If not MOSFET remain ON after finish the sketch discharging to 0 volst the battery

          • Adam 11/10/2016 at 10:07

            That’s probably a very good idea if you are having trouble with that.

  3. George 12/03/2016 at 22:56

    Got it working, after blowing a mosfet (I didn’t think that was possible at these voltages). I used the 55V 49A IRFZ44N N channel Mosfet in place of the IR3025 that Adam used. After sorting out my missing common ground (not shown in Adams video but essential to get a correct reading between pins A0 and A1) it works perfectly.

    Thanks again Adam.

    • Adam 21/03/2016 at 14:21

      Hi George – thanks for your comments. Not sure how you blew a IRF3205 – this project should be well within it’s limits. I did mention the common ground between the 18650 negative and the arduino (It’s at about 2:08 – Glad to hear it has worked for you in the end though.

    • Eric Scherzinger 01/04/2016 at 03:44

      So is that a ground wire that is required from GND on Nano to Negative of battery?

      Could I use any of the GND pinouts on the Nano or is it one of them specific?

      I’m all built but voltage seems off as well. I was thinking it the ground. I wired exactly like the video.

      • Adam 25/05/2016 at 12:49

        You just need a common ground between the arduino and the cell being tested otherwise the arduino can’t accurately read the voltage. Any ground will do. 🙂

  4. Andrew J Wilson 22/03/2016 at 10:14

    Thank you for a very interesting little project, I have been meaning to build a super-set of this for a long time using an AVR prototyping board but using an Arduino looks simpler.
    One thing does present itself however, by drawing a symbol for a light globe which is a variable load you led yourself up the path of having a current sense resistor which is unnecessary with a fixed resistive load. OBTW, the little gold power resistor has a rating of , I assume, 10 watts when it is attached to a heatsink. That is why it is getting so hot even at 3 ~ watts. Put a heatsink on it and it will cease to be dangerous. 🙂
    Now all I have to do is convert from Bascom Basic to Arduino…
    Thanks again, keep up the good work.

    • Adam 31/03/2016 at 14:49

      Thanks for your kind comments Andrew.

      I built the tester out of spare bits sat in my components box and didn’t want to buy any special items. The idea behind the separate shunt resistor (which probably should have been a lower value, but not too low that the resolution of the Arduinos ADC couldn’t detect much voltage drop) was so I could change the ‘load’ for different components to adjust the current. I was looking at testing reclaimed batteries – discharging them at one amp or two can have a bearing on results.

  5. Eric Scherzinger 30/03/2016 at 04:07

    Great project build

    I am going to make three of them to help me in my 18650 capacity tests of 4600 Cells.

    If all goes well I will make more or find a way to do multiple cells with the same arduino if that is possible. I would love to use my solar as a power feed. I will most likely go from Solar Panels -> Charge controller -> Battery Bank -> Inverter -> 120V to 5V 2A USB Charger -> Arduino Nano.

    So here are the Parts I Ordered from :

    Battery Holder for 18650
    BH18650 5 C$7.50

    NANO ATMEGA328 5V 16M Arduino Nano v3 Compatible Pins Soldered
    ARD-NANOV3-328P 2 C$11.83

    Nokia 5110 Graphic LCD 84×48 LCD Blue Backlight
    LCD-NOKIA5110 2 C$11.51

    MOSFET Transistor N-Channel 60V/50A FQP50N06 (Hope this should work fine)
    FQP50N06 3 C$2.54

    CEM (Epoxy) Prototyping PCB 70 x 50mm w/ 432 Pads
    PCB-UNI7 2 C$1.71

    18-pin 1-row 0.1” Long Pin Female Header
    HDR18X1FL 6 C$2.70

    8-pin 1-row 0.1” Long Pin Female Header for Arduino Shields
    HDR08X1FL 3 C$1.42

    2pin 0.2” / 5.08mm screw terminal (5mm)
    DG126-2P 6

    Supplier did not have a Shunt ( 10Watt 1 Ohm Resister ) I do have 5W 100 Ohm but I will look for parts to match

    Supplier did not have a Power Resistor at 4.7 Ohm for a Load so I’ll have to find something to match or bulb, fan.


    From Toronto Ontario Canada, EH!

    • Adam 31/03/2016 at 14:55

      Thanks for the comment Eric.

      The design could be expanded on a Nano to test four cells without too much extra work (cell 1 shunt resistor connected at A0 & A1, cell 2 at A2 & A3 etc.). You’d be able to expand it even further using a Arduino Mega – 16 analog inputs so eight cells.

      I’d be tempted to get a DC-DC converter to power your setup – seems wasteful going from DC to AC to DC. Actually as long as your battery bank is 18 volts or less you could just hook it up straight to the raw pin of the Nano!

      Good luck in your project.

    • Jeremy 15/05/2016 at 14:57

      where did you end up getting the resistors? Your detailed list was very useful! thanks!

      • Adam 25/05/2016 at 12:50

        Ebay for cheap bulk resistors or RS components for specific values or higher precision. Thanks for your question.

  6. Dean 26/05/2016 at 07:42

    Hi Adam

    Could you explain print start to me, I can’t seem to understand what it does or how it works in the program.

    Thank you

  7. Martin 06/06/2016 at 09:13

    Hi Adam,

    thanks for your video and the nice explanations! 🙂
    Now built my slightly adapted version, but I can’t get the IRF3205 to properly turn off at the end of the procedure.
    The gate pin goes LOW, but it won’t switch off…also had no access with a pull-down or such.
    It seems as soon as I try to check the voltage level of the gate pin with the multimeter afterwards it then switches.
    Any ideas where I failed or is my MOSFET just faulty?

    Regards, Martin

    • Nick 30/09/2016 at 05:40

      Try to use 100 Kohm rezistor to pul dawn Gate from ground.

  8. David 13/06/2016 at 17:40

    Adam I have just seen your you tube 18650 capacity checker. Do you have wiring layout of the board it would be a grate help to me.

    Many thanks’

  9. Aaron Backer 27/06/2016 at 19:04

    First off – thank you for an excellent video with clear explanations, detail, and good pacing. As a self-taught hobbyist, I usually have to be reminded of basic algebra when it comes to calculating current, voltage, resistance, and power. So I particularly appreciated you spelling out (quite literally) how you arrived at component values.

    The arduino code is (despite your apologies) straightforward and easy to read. I’ll be adapting it for a standard 16×2 lcd display, and it’s easy to see where I’ll need to make changes.


    Couple quick questions –

    Admitting laziness: I could trace it all out, but I *always* have to go back and resolder/cut different bits. Hopefully without letting the smoke out of a component or two. Is there any chance you have a pic and/or diagram of your component layout and protoboard trace cuts?

    I did order some logic-level mosfets to make things easier. I was trying to figure out why the IRF3250 still worked, but then guessed because although it needs 10v to saturate fully, it still passes significant amperage when the gate is at 5v. (10? 15? looking here: Does this sound right?

    (I ask because I do have some other standard MOSFETs, but the gates don’t open at all until at least 6v, so they were a no-go…wanted to make sure I wasn’t missing something obvious)

    Again – congrats on a well done, and above all *USEFUL* set of tutorials!


    • Adam 25/07/2016 at 11:34

      Hello. Thanks for the kind comments.

      I haven’t a diagram for the layout of the arduino 18650 battery checker – I never thought I’d done a particularly good job of setting out the components to be honest! If I get a chance at some point in the future I will post something.

      That’s right, the IRF3205 is pretty well open at 5 volts. It’s also got a low RDS On, which means it doesn’t cause too much resistance in the circuit – we’re using the fixed value resistors for that. There are a few other choices of mosfet that others have tried. Probably the most popular is the IRLZ44N.

  10. padmakumar VENKATASAMY 02/07/2016 at 08:32

    Dear sir,

    I am planning to go for multiple cell testing module . Could you please guide me whether using REV3 AT mega 2560-16AU Board is good enough to handle 10 to 20 no’s cells testing at a time or AVR board advised to handle multiple cells testing .

    I also would like to know how can we take print out like you have shown in google sheet with curve

    • Adam 04/07/2016 at 09:37

      The current design of the circuit requires two analog pins per cell. With 15 analog pins on the Arduino Mega you’d be able to test 7 cells in total.

      You may wish to redesign the voltage sensing and place the shunt resistor just before the negative of the cell under test – knowing this is 0 volts you can simply use one analog pin to sense the voltage (and therefore the current) flowing through the circuit.

      The next question would be is the Arduino Mega fast enough to read all those analog pins, make calculations and output them without taking so long that the period between reads doesn’t get too long to make the whole thing less accurate.

      The script outputs the voltage reading and current over the serial port. I just dropped these results into google sheets and made a graph – simple really.

  11. Mike 25/07/2016 at 16:51

    Hello there!
    I’ve built this using an arduino pro mini and it works only if I use a 2n3055 instead of a mosfet. If I use a mosfet (I have the FQPF2N60C, IRFZ24N and the PHP3N20L) the circuit just turns the mosfet on once and then goes to the “end” of the script. The reading on the arduino’s analog in are also not the best although I have a 1k pulldown resistor on the analog input pins that I’m using. I’ve been reading about using a logic level FET but you used a IR3025 which is also not a logic level mosfet. What could I be doing wrong as I don’t want the 2n3055 to fry?

  12. Chief1829 03/09/2016 at 02:18

    I have been looking for something like this for quite some time now, sure wonderful to find your great project! I have most of the parts collected, and I want to get it done soon so I can sort all the 18650’s before our trip to Arizona for the winter. These horrid South Dakota Winters got to be too much for me, and being unable to shovel snow, it used to break my heart to see my wonderful wife out there shoveling that white crap. Now we simply get in our old Motor Home and head her to Topock Arizona, where we enjoy an average of 65 degrees every day, and long morning walks are so good for our health, I have a bunch of power bricks I made up from 18650’s so being able to test and sort them to have the best in the most important bricks is very important for our off grid days.

  13. Raul F. 07/09/2016 at 10:13

    Hi, Adam. Thanks for you work!
    I just want to make a question.
    When I remove the power from Nano, and the battery is still connected, the power goes from A0 through the internal clamping diodes, to the Vcc line. This can damage the arduino. Would you consider put a 10K resistor in series with A0?

  14. Steve M 07/09/2016 at 12:53


    I’ve crudely modified the code to deal with 4 batteries.

    The code is here:

    Not being much of an arduino expert myself, would you be able to give it the once over?


  15. K. Balazs 14/09/2016 at 08:08


    You definitely need a 100K pulldown resistor from the gate of the MOSFET (to ground). Also, you need to setMode(gatePin, OUTPUT); before using that port.
    Nice work though!


    • Bill Sherman 24/12/2016 at 06:47

      I too have discovered that setMode needs to be added to the program setup. Took me quite a long time to figure it out.

      • carlos 26/03/2017 at 22:15

        please hlep i’m less than newbie with arduino., how i do that? add the setmode thing

  16. Nick 30/09/2016 at 05:44

    Hi, Adam. Thanks for you work!

  17. Pingback: Lityum pil test cihazi yapımı-2 |

  18. Steve M 15/11/2016 at 21:41

    I’ve got my 4 cell version online and it’s been working great. My knock-off iMax B6 died, so I was incentivized to get this finished!

    I’ve posted my code here:

    Thanks for your work.

    • Adam 11/01/2017 at 10:26

      Excellent Steve – thanks for your hard work I am sure others will find it very useful.

  19. Adão 17/12/2016 at 15:39

    Hi Adam
    Nice job!!
    This will help me to reborn some 18650 from 2 laptop battery packs.

    Could you please help me? Im using Arduino Uno R3 and my D10 pin is HIGH but it did not trigger the mosfet, then I have no current flowing through mosfet (IFRZ44N).. In youtube I didnt see the 10Kohm resistor that you put in the Fritzing schematics (D10, between Gate and Source pins, right?).

    Checking with multimeter, the D10 pin has about 4.8v (ground-D10) and when attached to circuit, it has about 0.85v.

    I also have an IRF3205 and I will try put it in place of IRFZ44N to see what happens.

    Please let me know if I forgot something.

    • Bill Sherman 23/12/2016 at 17:25

      I had the same issue of low voltage on the mosfet gate. You need to add to the setup:
      PinMode (10, OUTPUT)

      Or the 10k will load down the ouput too much. It took me several hours to catch this mistake.

      Look up Pinmode on the Arduino site. It will explain why. I do like this program. It will shut down the battery discharging when it detects a low battery. Some others don’t and may ruin your battery.

      • Adam 11/01/2017 at 10:15

        Thanks for the feedback Bill.

  20. Dave Packham 28/12/2016 at 03:07

    is the Pinmode and 10k resistor really needed? I have mine build just like the video and I am getting results and it turns on and off like it should. same exact hardware as listed in your hardware list BTW

    Just needed to add the “Time” in seconds like to the serial output as i didnt see it in your code on this page and i do in your spreadsheet example. unless there is a newer version of cide?

    • Adam 11/01/2017 at 10:14

      No I manually added the time to the spreadsheet. Knowing I’d set it to sample every three seconds I just pre-populated that column.

  21. Dave Packham 29/12/2016 at 00:12

    OK.. maybe not turning off the gate. just to confirm do I need the 10k resistor to ground to pull it down really and turn it off?

    • Adam 11/01/2017 at 10:13

      Yes, it’s good practice and I missed it in the video.

  22. Bob_the_Chuck 28/01/2017 at 00:34

    why do you not use a logic converter for the LCD? The Arduino Nano blow out 5V on the Digital Ports. The 5110 get contrast Problems without logicconverter even when VCC = 3V.

    • Bob_the_Chuck 02/02/2017 at 02:34

      It is a litte improfment to put a Diode 1N4148 between the Arduino GND and the Battery/Mosfet GND.

      It prevent the Battery to power the Arduino when USB Power is off.

      Using a Arduino Pro Mini 3.3 Volt also good for 3.3V Nokia Display so there is no need for a logic converter prevent damage by 5V.

      By removing the Serial.print(current); Serial.print(“\t”); Serial.println(mAh); the Arduino Build in Plotter show great Information of discarging.

  23. Hais 09/02/2017 at 19:41

    Hi Adam ….

    I had a play with this this circuit on proteus isis sim software ….

    If anyone wants to have a play with it and have proteus …
    here is the project file

  24. Anthony Clarke 05/03/2017 at 10:01

    Hi Adam

    If I replace the 1Ohm resistor with a say 5 or 10, other than taking longer to discharge, is there any need to change anything in the code?


  25. Drew 21/03/2017 at 18:26

    I recommend you to put two, 4k6 ohms resistance in series with A0 and A1 inputs of Arduino. This way you will prevent a high current thru the pins whenever a Li-ion cell is connected, without having a power supply on the Arduino. (This will not affect the voltage measurement)

Leave a Reply

Your email address will not be published. Required fields are marked *