Arduino True Battery Capacity Tester (Li-Ion/NiMH/NiCD/Pb)

313,316

358

90

 If anyone saw my last instructable "Simple Li-Ion Battery Power Tester" they can now upgrade to a computerized hi-tech version that is capable of measuring almost any type of rechargeable or none rechargeable batteries (but it will drain one charge from them in the process).
It can even connect to a PC and give you a full "Data-sheet" graph of the discharge and total capacity.
Note that this is my first Arduino project (I am not counting my "blink LED").

Step 1: This Is What You Can Get at the End...(just to Get You Interested)

This is the graph you can get from the text file sent to the PC during drain cycle.

Step 2: Lets Start at the Begining - Arduino

I really wanted to get this Diecimila copy Arduino board bit it took me ~2 weeks to get it by mail so I just had to start fast with my own bread-board Arduino so I purchased an ATMEGA168 and thought I could get it running without any more components .. to my suprize it didn't work and I just had to get another shipment with a 16Mhz crystal and two 22pf caps .. then I got the next ...

Step 3: Bread Board Arduino

I basically took junk apart and added the components one by one ...
most of the information can be found in the Arduino web page :
http://arduino.cc/en/Main/ArduinoBoardDiecimila
They realy have everything you need .
It took me about a week to get it up and running (bootloader / building an ISP cable and an RS232 cable ...) - you can read all about this in the site above .

Step 4: FET With 2.2Ohm Load

it was fairly simple to add a FET with "on" resistance of ~8mOHM (no barly any power disipation on it) and a 2.2 10W resistor .
I connected two A/D pins from the Arduino to the resistor poles and subtracted the values to get the exact volatge drop on the resistor .
Now I samples them every second and acumulated the current (I=DeltaV/R).
I also added a buzzer to indicate when charging was over and stoped the discharge .

Step 5: The SW

So I also connected and LCD (which I took apart from some other junk) and found the data-sheet on the net + a cool driver from the Arduino web page and started coding .
Auto detecting battery type by the voltage .

Step 6: Auto Detect Battery Tyoe

It will detect if it is NiMH/NiCD or Li-ION by the voltage range .
And then start the discharge cycle.

Step 7: Discharging...

The discharge can take anywhere from 30-120 minuets depending on batery capacity but at the end you get a true indication of battery capacity / quality .
Do you want to use that battery for your air-plain receiver or not ?
This is the diagram of the discharge circuit...

Step 8: Discharge Circuit

very simple with the 2 A/D connected on the two sides of the resistor /
Vr=Vbat-Vfet.


Step 9: My SW (free for Anyone to Use)

// include the library code:
#include


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// initialize the library with the numbers of the interface pins
int sensorPin = 0;    // select the input pin for the potentiometer (pin 23)
int sensor2Pin = 2;    // select the input pin for the potentiometer (pin 23)
int ledPin = 13;      // select the pin for the LED
int SPKPin = 6;
int sensorValue = 0;  // variable to store the value coming from the sensor
int sensor2Value = 0;  // variable to store the value coming from the sensor
float LiMinThreshold = 2700; // Lithium Minimal Voltage for load removal
float LiMaxThreshold = 4200; // Lithium Max Voltage for load removal
float NmhMinThreshold = 950; // NMH Minimal Voltage for load removal
float NmhMaxThreshold = 1600; // NMH Max Voltage for load removal
float SelectedMinThreshold = 5000;
int i;
int BatVoltage = 5000;
int FetVoltage = 5000;
long TotalCurrent = 0;
boolean done = false;
unsigned long PrevMillis ;
unsigned long MillisPassed ;

void CL2(){
  lcd.setCursor(0, 1);// Second line first char
  lcd.print("                        ");
  lcd.setCursor(0, 1);// Second line first char


void setup() {
  Serial.begin(9600);// start serial port to send data during run to the PC
  pinMode(ledPin, OUTPUT);//activation led and enable for FET
  pinMode(SPKPin, OUTPUT);//activation led and enable for FET
  lcd.begin(24, 2);// set up the LCD's number of rows and columns:
  lcd.print("Bat PWR Tester[Active]");  // Print a message to the LCD.
  lcd.setCursor(0, 1);// Second line first char
  lcd.print("Detecting Bat Type..."); // print voltage value
  delay(2000);
  lcd.setCursor(0, 1);// Second line first char
  lcd.print("                        ");
  lcd.setCursor(0, 1);// Second line first char
  digitalWrite(ledPin, HIGH);   // set the LED on
  sensorValue = analogRead(sensorPin);   // read the value from the sensor:
  digitalWrite(ledPin, LOW);   // set the LED off
  // Detecting battery type
  BatVoltage = sensorValue*4.887;
  if (BatVoltage > 4500){
    lcd.print("Warning high-V! ");
    done = true;}
  else if (BatVoltage > LiMinThreshold){
    lcd.print("Type:Li-Ion Bat ");
    SelectedMinThreshold = LiMinThreshold;}
  else if (BatVoltage > NmhMinThreshold){
    lcd.print("Type:NiMH/Cd Bat ");
    SelectedMinThreshold = NmhMinThreshold;}
  else{
    lcd.print("Unknown Bat V<1 ");
    done = true;}
  lcd.print("V=");
  lcd.print(sensorValue*4.887); // print voltage value
  Serial.print("DT[ms]"); 
  Serial.print("\t"); 
  Serial.print("Bat[mV]"); 
  Serial.print("\t"); 
  Serial.print("Fet[mV]"); 
  Serial.println("");
  delay(3000);
  CL2();
  PrevMillis = millis();
}

void loop() {
    if (BatVoltage > SelectedMinThreshold && !done) {
      digitalWrite(ledPin, HIGH);   // set the LED on
      sensorValue = analogRead(sensorPin);   // read the value from the sensor:
      sensor2Value = analogRead(sensor2Pin);   // read the value from the FET:
      FetVoltage = (sensor2Value*4.887);
      BatVoltage = (sensorValue*4.887);
      CL2();
      lcd.print("V=");
      lcd.print(BatVoltage); // print voltage value
      lcd.print("mV");
      //lcd.print(FetVoltage); // print voltage value
      TotalCurrent=TotalCurrent+MillisPassed/1000*(BatVoltage-FetVoltage)/2.2/3.6;
      lcd.print(" I=");
      lcd.print(TotalCurrent/1000);    
      lcd.print("mAH         ");
      delay(1000);
      MillisPassed = millis()- PrevMillis;
      PrevMillis = millis();
      Serial.print(int(MillisPassed));
      Serial.print("\t");    // prints a tab
      Serial.print(BatVoltage);
      Serial.print("\t");    // prints a tab
      Serial.print(FetVoltage);
      Serial.println("");    // prints a tab
      CL2();
    }
    else
    {
      done=true;
      digitalWrite(ledPin, LOW);   // set the LED off - stop loading
      lcd.setCursor(0, 0);// First line first char
      lcd.print("Bat Power Tester [DONE] ");  // Print a message to the LCD.
      CL2();//clear line 2
      sensorValue = analogRead(sensorPin);   // read the value from the sensor:
      BatVoltage = (sensorValue*4.887);
      lcd.setCursor(0, 1);// Second line first char
      lcd.print("V=");
      lcd.print(BatVoltage); // print voltage value
      lcd.print("mV I=");
      lcd.print(TotalCurrent/1000);    
      lcd.print("mAH            ");
        for (int i=0; i<100 ; i++){
          digitalWrite(SPKPin, HIGH);
          delay(1);
          digitalWrite(SPKPin, LOW);
          delay(1);
        }
      delay(1000);
    }
}

Step 10: The Schematics ...

All the schematics for arduino can be found on the Arduino web page (step 2).
you can Also find how to connect standard LCDs on the same site so no need to copy it all here.

Step 11: Please Support My Work by Voting for Me !

All and all prototype Breadboard and then moving it to a box and soldering it all together took me two weeks (night work 3-4 hours a day)

Thanks you for reading and feel free contacting me with any questions / remarks .

I am now an Arduino expert (naa I am not - 2 weeks XP )
But I have many new project I would like to do .

Arduino Contest

Second Prize in the
Arduino Contest

Share

    Recommendations

    • First Time Author

      First Time Author
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • PCB Contest

      PCB Contest

    90 Discussions

    0
    None
    KDMcMullan

    1 year ago

    I suspect the method is flawed. You're sampling the voltage at each end of the load resistor: FET drain end and also battery end. You say you use the difference to calculate the V drop across the load. I accept that this is correctly going to give you the V drop across the load, but I don't think that's the information you need. I suspect you really need the total V drop across the load and the FET all the way down to ground. The ground is, of course, 0V. So the Vdrop needs only to be measured at the cell itself. I don't see the need for the voltage measurement at the FET drain at all.

    1 reply
    0
    None
    Orleck

    Reply 1 year ago

    Sounds like you haven't read the comment policy.

    0
    None
    PeterK63

    2 years ago

    int sensorPin = 0; // select the input pin for the potentiometer (pin 23)
    int sensor2Pin = 2; // select the input pin for the potentiometer (pin 23)

    And what those potentiometers do, connected to the same pin 23 ? Precisions, precisons...

    0
    None
    picposter

    2 years ago

    Your Code is not Working properly and there are no shematics. Could be a bit more precise.

    0
    None
    oldskoolhead

    2 years ago

    some battery chargers have a test function

    0
    None
    nohopehere

    2 years ago

    The "vote for me" LED did not seem to work. :-/

    0
    None
    bart.szester

    4 years ago

    Hi all, I'm lookig for someone who would build a battery capacity trster for me. I need to test batteries 18650 3.7v, 18350 3.7v and 4.2v. I'm using them for my e-cigs. Can anyone help?

    7 replies
    0
    None
    chedgerbell an

    Reply 3 years ago on Introduction

    I've seen plenty of capacity "indicators" that give a guesstimate but not much in the way of ones that discharge with a load to determine actual capacity and none that will give you a graph.The ones I found are on ebay for $12.xx and $45.xx respectively and called:

    "1.2-12V battery capacity tester external load discharge capacity test 18650"

    and
    "Digital led Ni-Cd Li-Ion Pb Ni-Mh Battey Capacity Tester & Discharge Instrument"

    The prices are fine but I question the accuracy/quality and if they are actually the best/only available.

    0
    None
    moris_zenchedger

    Reply 2 years ago

    I now purchased the : BT-C3100.

    I am very happy with it . It can check any 4 batteries together ..

    Recommended!

    0
    None
    AlexYanbell an

    Reply 3 years ago on Introduction

    bell an, could you give any specific brand name or link plz,

    Thank you

    0
    None
    moris_zenbart.szester

    Reply 4 years ago

    you use 18650 for e-cigs?!?!
    That must be a huge e-cig :-)
    If you like you can ship some over and I can test for you .

    0
    None
    richard.kost.50moris_zen

    Reply 3 years ago

    18650 is the most common size for what are referred to as "mods" which are not the fake cigarette types. Other common sizes are 18350, 18500, and my peraonaly pref the 26650. I saw this build some time ago and recently came over to start compiling parts to build one myself.

    0
    None
    GaryH34

    3 years ago

    Any idea how much the project would cost if you had to buy all of the components?

    Also, do you have a picture showing batteries hooked up to your board (just wondering how you physically connect many cells.

    How many parrallel cells does it handle?

    1 reply
    0
    None
    moris_zenGaryH34

    Reply 2 years ago

    Sorry I dont .

    Only one every time .. or you can connect in parallel if they have same voltage but then you dont know capacity of each ...

    0
    None
    Menneset

    2 years ago

    The contest is over, but I would have voted for you just because of the LED comment. :)

    0
    None
    CarlosV46

    3 years ago

    Hi. what kind of resistor is used (2.2 ohms) Watts, tolerance %, (maybe a shunt resistor)?

    Thanks in advance.

    0
    None
    moris_zen

    3 years ago on Introduction

    It looks nice .. but a bit expensive .. to get something to test 12 i parallel is ~150$ :-(

    0
    None
    AlexYan

    3 years ago on Introduction

    Hi, can your capacity-meter test multiple cells simultaneously? I mean I max b6 allows to measure capacity and it is just ~30 $. The downside is that it tests one cell at a time. I have a few hundred cells to test so looking for a way (multy-cell testing device) to speed up the process. Can you give any suggestions?