Laptop Battery Analyzer /Recycler




I started out , when at work they had pile of battery packs for laptop computers , that no longer worked. Well I know that most (not all ) Battery packs for Laptops are made up of a bunch of 18650 Li-Ion Battery Cells , and it is usually only one or 2 cells that go bad in a Pack making the entire battery pack no  good. So I grabbed a Bunch of them and took them apart. My use was going to be to use them to power some Bicycle lights. Figured I would charge them up and shouldn't be too hard to find the bad cells using an Volt/Amp Meter , this Worked but not well by any means ,I  soon discovered that a lot of the cells would take a charge , but not much of a charge , found this out the hard way with bike lights that went dark too fast.

So I came up with this Idea of using a Computer , with an analog input, and would read the out put of the battery across a load over time to determine how much energy the battery cell could store.   My first attempt was using an old PC with a Metrabyte DAS-8 A/D board . It was basic , I would manually connect the load start teh data collection, stop it after time , and then using excel determine the amount of energy in the Cell.  But I wanted to do this more automatically . I was using an Ardunio for another project ( which will soon have an instructable for it )  and realized it had all that I needed to do this . so I made the switch and it was a lot easier to wire up , program and took up a lot less space.

Step 1: Charging the Batteries

Charging LI-Ion Batteries
when charging LI-ION batties Be careful! they can be unstable and catch fire. I have never personally had this happen , but I don't care i always take the precautions, better safe then sorry. there are plenty of horror stories out  there. 
1) Never Charge unatteneded!
2) Charge out doors or some place some place pretty much fire proff ( I charge mine on the Bricks of my fire place or top of  Steel sheet )
3) AVOID drivect shorts
4) do not use a Physically Damaged Cell.
5) Dispose of Properly ( I take my To Home depot and deposit in there battery recycling bins )    
Most of the time I use  this simple charger from Deal Extreame (  I also will use a larger RC  Smart charger for doing multi cell packs , but that is a little beyond what this Instrucable is for.

Step 2: Parts List

 Parts List
- Adrunio Uno  or compatible ( ebay $20  )
- 16 X2 LCD display that uses a Hitachi HD44780 driver, They are very common, I have gotten several  from old HP servers and Rolm Phones, but one can Be purchased here. for $10
- An opto 22 Solid State Relay ( RED , 5 Vin )  I happen to have  an ample supply around my basement
- 18650 battery Holder , $2 eBay
-10 M ohm  1/4 watt Resistor (  or something large just to be used as a Pull down )
- 4 Ohm 6 watt  Resistor
- 1 push Button, momentary contact  switch (not Shown )
-  6  to 10 V 500 ma , Power supply , Wall wart style to power the adrunino (not Shown) 

Step 3: Theory and Operation

Theory and Operation

Li-Ion Batteries , when charged under no load have a Voltage of about 4.2 Volts , that quickly drops to about 3.9 Volts under load and slowly drops as the charge is used . a Li-Ion Battery cell is considered fully discharged then the under load Voltage get below 3.00 Volts.
So what i do it have the battery attached to one of the Adruino's Analog Input's , and read the No-load value. at the same time waiting for the start Button to be pressed. If the voltage input is above 3.00 volts when the Button is pressed the test will start. 
When the test starts  the Solid State relay is energized with switch the 4 ohm resistor to be a load directly across the battery. the Voltage is then read every half second and using ohm's Law current ,  I=V/R,  R= 4 ohms and V is read from the Analog input. Since this reading is taken every half second , we know there are 7200 1/2 seconds in an an hour , we just take the current  multiply it by 1/7200 of an hour and accumulate all those reading and until the Voltage  is below 3.00 volts , at that point the Relay is shut off and the grand total of how many maH of energy was released is displayed

Step 4:

4) After getting the parts together First thing to do is prep and connect the LCD dispaly , I used the basic setup of an LCD display as seen  on the Ardunio tutorial page ( ) I however do not use a Potentiometer for brightness control, I just connect Pin 3 to Ground . I also Do not use the same Pins. I don't use the High end Pins, because i had ideas of putting an Ethernet/SD card Shield on and recording the data from each Battery as it was being tested , that however has not come to fruition .

back to the matter at hand the LCD display .
Pin   Destination
1   - GND
2    + 5
3       GND
4   -  Digital Pin 2
5 -     Digital Pin 3
6,7,8,9,10  No connection
11   - Digital Pin 5
12  -  Digital Pin 6
13 - Digital Pin 7
14    Digital Pin  8
15     + 5  
16 -- GND 
that will take care of wiring the LCD

Step 5:

next I take the Battery Holder . I attach the negative to Ground , and the Positive to Analog Input 0 .
Between  the analog 0 input and ground i put a 10 M ohm resistor . I use this as a Pull down resistor, helps elivate noise especially when there is no cell in the holder .
Next I take the Solid state relay , attach the input "-" to Ground, and the input Positive to Digital Pin 1 . now I take the Positive ( If your SSR has  polarity on the output some do some don't )  output Pin of the Solid state relay and attach it to the Positive terminal , and  between the Negative terminal and Ground put the 4 Ohm 6 Watt Resistor , this will be the load resistor and give it some space because it can get hot.

finally attach a Push button between +5 and digital Pin 0  ( I actually use a SPDT  ) Push button and attach the other pole to ground , that can cause a Noise spike to trigger it, or you could just use another 10 M ohm resistor as a pull down it will work too. I know its overkill, just a habit from years of work.

that Completes the wiring , next is he code and here it is . Because I'm using Pin's 0 and 1 , you might have to disconnect those to pins while you down load the program , other wise it might not load.

Step 6: The Source Code

Here is the source code for the Analyzer 

A battery life cycle tester using an Lcd as output  

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd( 2, 3, 5, 6, 7, 8 );
const int buttonPin = 0; 
int sensorPin = A0;    // select the input pin for the Battery
int sensorValue = 0;  // variable to store the value coming from the sensor
const int relay=1;
int buttonState = 0;
float mah = 0.0;
long timestart  ;

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Battery life tester");
  pinMode(relay, OUTPUT);
pinMode(buttonPin, INPUT);

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  digitalWrite(relay, 0 ); //set the LED-relay off
  while (buttonState == LOW ) {
  sensorValue = analogRead(sensorPin); // read the battery
  //  the voltage
  buttonState = digitalRead(buttonPin);
//  if (buttonState == HIGH) {
//    if (bb > 0) { bb=0; } else { bb=1; }
//  }
  lcd.setCursor(0, 1);
  lcd.print(" Volts");
  } //end get ready loop 
  digitalWrite(relay, 1 ); //set the LED-relay on
  lcd.setCursor(0, 0);
  lcd.print("Testing              ");
  lcd.setCursor(0, 1);
  lcd.print("                         ");
  mah = 0.0;
  timestart = millis( );
  while ( ((sensorValue*4.98)/1023) > 3.00 ) {
     lcd.setCursor(0, 1);    
     lcd.print(" V ");
     sensorValue = analogRead(sensorPin); // read the battery
     mah = mah + (((sensorValue*4.98)/1023)/4 )/7.2;
     lcd.print(" mAh ");
     delay ( 500 ) ;
     lcd.print((millis( )- timestart)/1000); // time since test staarted
  } // end battery drain
    digitalWrite(relay, 0 ); //set the LED-relay off

  // final results
   lcd.setCursor(0, 0);
   lcd.print(" mAH ");
   lcd.print((millis( )- timestart)/1000);
   lcd.print(" S ");
   buttonState = digitalRead(buttonPin);

Step 7: Run It

First put a charged battery In the Holder .  Note the voltage  above 3.0 

Step 8: Out the Battery Under Load

Press the start button and watch and Wait. On top displays the seconds that have elapsed  83 seconds in this case 
the current voltage reading ,3.64 Volts , notice how much it dropped under a 1 amp load. and finally how much energy in Millamp Hours has been discharged, 21.06 Mah .

Step 9:

And when it completes , the Top line has the total Energy that was in the cell, 629.24 Mah  and how long it took, 2788 seconds or 46 Minutes and 28 seconds. in this case this is not a battery I would keep . I don't keep any under 1000 Mah,. and  it has reset it self just waiting for you to press the button again and start the test going again.   

Step 10: What I'd Still Like to Do .

I would like to record the data Points to an SD card and then have the data accessible from a Web page through an Ethernet Shild ,  thats Why I didn't use Pins 4, 9, 10, 11, 12, 13 they are used for the ehternet/SD shield. but that is for a later time.

Arduino Challenge

Participated in the
Arduino Challenge

2 People Made This Project!


  • Frozen Treats Challenge

    Frozen Treats Challenge
  • Beauty Tips Contest

    Beauty Tips Contest
  • Pets Challenge

    Pets Challenge

36 Discussions


1 year ago

Good project. The readout of capacity is great for comparing cells and sorting the good from the bad. Since the cell voltage drops by around 25% (from above 4V to 3V) as it discharges, a constant current load will be needed if accuracy is important.

1 reply

Reply 11 months ago

Since it measures the voltage each time, I don't see why a constant current load is necessary to make it more accurate. It knows the time elapsed, the voltage, and the resistance of the load. Why would a constant load make it any more accurate?


2 years ago

What is 7.2 mean?


2 years ago

Hi, there is any way to use this fantastic system to test the whole laptop battery instead the single cell?



2 years ago

why pin out of relay is 3.5 V. not 5V. but pin button is 5V. when i using relay. relay is flashing, because this relay is logic 5V


3 years ago

Hi, been trying to make this with no sucess. Get all sqaures in the lcd.

I,m new to arduino and coding has not sunk in yet. Would be nice to have some info on how to get around this



3 replies

Reply 3 years ago

The black squares mean the LCD was not initialized. In this case, it's a sign that it is mis-wired. On review, there appears to be an error in the schematic.

Pin 4 of the LCD (RS) should go to Pin 2 of the Arduino.

Pin 5 of the LCD should go to ground.

Pin 6 of the LCD (E) should go to pin 3 of the Arduino.

Double check your 4 data lines. They appear correct in the schematic.

The key is the "LiquidCrystal(rs, enable, d4, d5, d6, d7) " command. Review it and your wiring.

Let us know what you find.


Reply 3 years ago

Hello, i`m noob in to arduino,

I wana do this project, but i dont have this tipe of display, i have an SPI display 1.8 128*160, is it hard to change the program to display data on this display, Thank you!

Roger GaudreaultSergeF1

Reply 3 years ago

You may have shorted two pins on the lcd, and double-check your variables in the code. This project is not too hard to make, it was my first arduino project (after blink :)

I suggest you use Fritzing to draw your shematics. Much easier to breadboard.

Look at the arduino website, and read, read, read.


3 years ago

I made a more polished verison of this same thing for doing way more batteries.

John Bond

3 years ago

This is an AMAZING device and can even be improved a little.

I made a very similar device to test powerbanks at work about 18 months ago.

A powerbank exploded in a user's pocket injuring him. We had relied on our supplier to test the devices. We set up a fairly rigorous testing regime. We tested not only our units but also the competitor's units and got to learn a huge amount about powerbanks

We eventually got hold of the exploding powerbank and found it was a fake copy of one of ours, very similar outside but without any protection circuit inside.

Some notes:-

* Our Chinese powerbanks seldom fail and when they do, they fail safe

* They usually have an efficiency in excess of 83%

* The power delivered is very smooth. Less than 10mV spikes. 0.4V to 0.7V total voltage variation throughout the cycle

* Some of the competitor's powerbanks are not very good (read "dangerous!")

Features I incorporated that may enhance any power measurement device:-

* We rapidly sample 1000 times (to increase accuracy) and record the average, the max and the min in a spread sheet

* This is repeated 40 times a second until the unit is discharged

* We use a variable load (mosfets and some opamps) but have found that we always run it at 1 Amp. The technicians can then compare different powerbank models against each other.

* Our customers sometimes ask us to test units that have been returned to them and the units generally (almost always) pass. The weak link in powerbanks is the power cable.

A word of caution - Our company has come to rely on this simple device more than the sophisticated equipment used by our suppliers (not a good idea). We have challenged new suppliers on the results. The suppliers tend to get very annoyed when they discover out test equipment is an Arduino and some opamps, lying loose on a workbench...


3 years ago

For anyone interested, here's a similar, but also totally different, project that I did using an Arduino to test and compare the amp hour capacity of some popular brands of AA batteries:


3 years ago

Nice job mi amigo! A further advancement is to use at least three different loads, capture the data and run it into a spreadsheet so you can look at the different curves to determine "Quality" of the battery. The performance of a battery changes with the load. Performance is dependent upon on its equivalent series resistance (which changes with temperature). Something else to capture and compare is temperature of the battery under load. This will give you a good idea of the quality of the battery. In a battery bank, I would not mix batteries that have wildly different load and temperature characteristics. Just some advance thoughts when dealing with Li-Ion battery recovery.


3 years ago

Hi there, can use this to measure how long can total energy that is in the cell power the arduino circuit?


3 years ago

Is there any limitation on the resistor used ? i am using a 5.6 ohm 10 watt resistor ... i read in a similar project that the resostance should be less than 4 ohm ... please clarify


4 years ago

I just can get an 3.9 Ohm 9W resistor.
I'm right that I must change this line

mah = mah + (((sensorValue*4.98)/1023)/4 )/7.2;


mah = mah + (((sensorValue*4.98)/1023)/3.9 )/7.2;
or is there something else to change?

1 reply
Roger GaudreaultTimoM

Reply 4 years ago on Introduction

I=V/R so I = sensorvalue (V) / Resistance (Ohm)

You are right. For more precision, check the total resistance of your circuit with a multimeter and use this value in your program.

I'm building this project, and I have the same problems than tony_roti. I'm wondering: Do we absolutely need a push-button switch? All my problems seems to come from here. I will modify the program to start automatically when the voltage is above 3.00 volts. Thank you splats for this nice project and all others for your constructive comments.

Does this work for 26650 batteries too? They basically have the same voltage, and just more mAh than 18650.


5 years ago on Introduction

I think that you must put a lcd.clear(); before final result are printing. And delete spaces in lcd.print(" V "); and lcd.print(" mAh ");
Why? Because if you test a cell with bigger capacity (4 digits), you won't be able to read the final digit of timing.