Monday 30 March 2015

ArduinoDay2015 #ArduinoD15 Quick project: Battery capacity tester

Last Saturday was Arduino Day and, of course, I felt obliged to build a little project. As there was just over an hour of ArduinoDay left in my timezone, I had to hurry up and make a few compromises.

The result was this rather simple circuit:

Somehow a relay with two sets of switches had made it into my sparkfun inventor's kit, So I used that second set to switch between two status LEDs, just for the heck of it.
The only thing not contained my (somewhat older) Sparkfun Inventor's kit was a suitable load resistor. I found a 15 Ohms resistor that looked like it could dissipate a few watts. For the 3.7V lithium cell I wanted to test, that should result in a current of approx. 250mA and around 1 Watt of heat that has to be radiated off.

If you want to build this, I'd strongly recommend to use thicker, shorter wires, because the lousy jumper wires and breadboard add an awful lot of resistance.

 int sensorPin = 0;  
 int sensorValue = 0;  
 int time = 0;  
 int rel = 13;  
 float cur = 0;  
 float cap = 0;  
 void setup()  
 pinMode(rel, OUTPUT);  
 digitalWrite(rel, HIGH);  
 delay (1000);  
 void loop()  
 sensorValue = analogRead(sensorPin);  
 float voltage= sensorValue * (5.0 / 1023.0);  
 if (voltage > 3)  
  cur = voltage / 15; //current through the 15 Ohms Resistor   
  cap = cap + (cur / 60);   
  delay(60000); //1 minute delay between readings.  
  digitalWrite(rel, LOW);  

The sketch cuts out at 3V to protect the cell from deep discharges. That is very safe, but it leaves some capacity in the cell. Keeppower's protection circuits cut off at 2.75V.

I then fed the Time/Volts (the first two columns) to LibreOffice Calc:
Gaaaah! This is one ugly graph. I suppose it is mainly because of contact issues. Thermal effects might also contribute.
On the other hand, the capacity measured is 776 mAh. Not far off for a 800 mAh cell. This is because the current is derived from the voltage drop over the 15 Ohms resistor. And that stays valid, even if the surrounding wiring is poor and adds extra resistance.

Warning: If you need to measure cells over 5V, you need a voltage divider. Otherwise you'll damage your Arduino board. Or at least the microcontroller chip.

Here is the link to my video:

Edit: 20150401 Corrected circuit diagram.


  1. how i know a capacity of battery in a android?

    1. That totally depends on your device. As the android devices I know have 3.7V batteries, you could use this circuit to check the capacity.

  2. what if i want to know the capacity of NiMH. releases 16v.

    1. Yes, that can be done: You need to make a voltage divider to reduce the voltage fed to the arduino to <5V. There is more than one way to do that, but I'd go for the following solution:
      a) Get 4 pieces of 15 Ohms / 2Watt resistors (higher Watt rating is ok)
      b) solder them in series:
      c) If the relay is switched on and you have a 16V battery connected, you should get around 4V at between the two left resistors and ground/(-). Double check that with your meter before connecting the analog-in pin.
      That should be it.

    2. thank you sir for your reply. may i know how can i contact you beside this site? i'd like to know something.

    3. You can contact me any time on google hangouts.

  3. Sir could I use this same circuit for my 3.7 volt Lipo battery

    1. Yes, absolutely no problem. Any battery (regardless of the chemistry) under 5V will be fine.

    2. Ca I email you to have a look at my set up?

    3. Sure, you can send it to andreas (dot) reischle (aT) googlemail (dot) com