My simple Ni-mh battery discharger mah calculator Arduino project

Having found some old Ni-mh batteries, I want to buy a La Crosse Technology BC-700 Alpha Power Battery Charger to do the discharge test to find out their working capacity, but the charger costs about $35, and I don't really need it, so I decided to make my own dis-charger using my Arduino uno. Here is the result, I hope anyone with knowledge about this in term of electrical circuitry and software programming can correct me if there is anything wrong. Thank you in advance :slight_smile:

#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);

int leds[8]={0,1,2,3,4,5,6,7};
int Vohm[2]={A0,A1};
int Button[4]={A2,A3,A4,A5};

int sec=0;
int minu=0;
int hr=0;
unsigned long time=0;
unsigned long pstimer=0;

float DV=0;
float BV=0;

int ma=0;
float mah=0;
float mahnow=0;
//========================================================================================================================

void setup() {  
lcd.begin(16,2);

for (int x=0; x<8; x++){
pinMode (x, INPUT);
}

pinMode (A2, INPUT); // battery voltage
pinMode (A5, INPUT);// resistor drop voltage
}


//========================================================================================================================
void loop() {
  

unsigned long timer= millis();
 if(timer-pstimer > 1000){
   sec++;
   
   float BV1 = analogRead(A2);
   BV = BV1/1023*5.18;  

   float DV1 = analogRead(A5);
   DV = DV1/1023*4.96;    
   
   ma=DV*1000;
   
   mahnow=DV/3.6;
   mah=mah+mahnow;
   
   lcd.setCursor(10,1);
   lcd.print("    ");


   pstimer = timer;
 }  
 
if(sec==60){
 sec=0; 
 minu++;
}

if(minu==60){
 minu=0;
 hr++;
} 
  

char szTime[7];
sprintf( szTime, "%02d:%02d", hr, minu );
lcd.setCursor(0,0);
lcd.print( szTime );

if (BV>0.5){
lcd.setCursor(6,0);
lcd.print(mah);}

lcd.setCursor(13,0);
lcd.print("Mah");

lcd.setCursor(0,1);
lcd.print(BV);

lcd.setCursor(5,1);
lcd.print(DV);

lcd.setCursor(10,1);
lcd.print(ma);

lcd.setCursor(14,1);
lcd.print("Ma");

if (BV>1.2){
digitalWrite(2,HIGH);
digitalWrite(4,HIGH);
digitalWrite(6,HIGH);
}
else {
digitalWrite(2,LOW);
digitalWrite(4,LOW);
digitalWrite(6,LOW);
}

if (BV>0.9){
digitalWrite(2,HIGH);
digitalWrite(4,HIGH);
}
else {
digitalWrite(2,LOW);
digitalWrite(4,LOW);
digitalWrite(6,LOW);
}

if (BV>0.5){
digitalWrite(2,HIGH);
}
else {
digitalWrite(2,LOW);
digitalWrite(4,LOW);
digitalWrite(6,LOW);
}



}

Looks nice. I have been wanting to do this.

I have one of those La Crosse chargers, but it is still useless for discharge tests, because it only shows the discharge capacity while discharging. Once the lower limit is reached the charger flips to charging and clears the discharge data from the screen, so unless you are watching the charger during the time of that change you can't view the actual battery capacity only the charging capacity which is not as accurate.

jroorda:
Looks nice. I have been wanting to do this.

I have one of those La Crosse chargers, but it is still useless for discharge tests, because it only shows the discharge capacity while discharging. Once the lower limit is reached the charger flips to charging and clears the discharge data from the screen, so unless you are watching the charger during the time of that change you can't view the actual battery capacity only the charging capacity which is not as accurate.

Thanks for the feedback, here is the result of this battery test. It was a 2500mah, and my test shows it only has 1500mah capacity now.

test with a 750mah battery. seems to me, the result is good.

Hi,
is the battery connects directly to the resistor??

Cool project. Please remember, it's mAh (m for milli, not M as in Mega)

// Per.

Battery capacity is normally specced at the C/10 rate, which means the battery needs to be discharged at a current which is equal
to its mah rating / 10 , so a 200 mah battery would be discharged at 20 ma.
Also , discharging a battery into a resistor wont give a constant current discharge rate , so the result will be slightly incorrect, depending on the resistor value.

I also want to build a battery discharger using an Atmega328p. I do not want to open a different topic for this so I will write here.

  1. As somebody already remarked in a post, discharging an 1.2 V battery through an 1 Ohm resistor means that an 1.2V/1Ohm = 1.2 A current will flow through the resistor in the beginning and when the battery is discharged (for example, it no longer generates more than 0.9 V) the current will be 0.9 A, way too much for a 2500 mAh, 1.2V AA battery as a continuous current.
    To measure capacities closer to the printed value (2500 mAh) a 10 Ohm resistor should be used.

  2. I(t) = V(t)/R,
    Capacity = Integral(I(t)dt) = (1/R)*Integral(V(t)dt)

As the only thing the micro-controller measures is V(t) across the battery, the formula that gives the real capacity is:

Capacity = (T0/R) * ( V(0) + V(T0) + V(2T0) +...+ V(nT0) ) where V(n*T0) = 0.9V and T0 = 30 sec., for example.

Anyway, I am looking for a more professional schematic where you can set the discharge current (ex. 250 mA) and the stop discharge voltage (ex. 0.9V) using the LCD and a few (2 - 4) navigation buttons.