Know The Charge in your battery Using Arduino Uno.!

This is  one of the coolest project on my blog. Yes, just as the header says with the help of an Arduino and breadboard and couple of jumper wires you can predict the charge left in your battery (Li-ion or AA) without plugging them into any sort of electronic devices.


  1. Arduino UNO
  2. breadboard
  3. 3 x100 ohm resistors
  4. 1 x 10k ohm resistor.
  5. 1 x zener diode(10k)
  6. jumper wires
  7. Basic Knowledge of  how zener diode works.


I’ll familiarise you with zener diode so you won’t have to refer to any book or other source to know about it.

Diodes are electronic components which will let current flow in just one direction.

A Zener Diode is a special kind of diode which permits current to flow in the forward direction as normal, but will also allow it to flow in the reverse direction when the voltage is above a certain value – the breakdown voltage known as the Zener voltage.

Zener Diode Circuit Symbol

The Zener voltage of a standard diode is high, but if a reverse current above that value is allowed to pass through it, the diode is permanently damaged. Zener diodes are designed so that their zener voltage is much lower – for example just 2.4 Volts. When a reverse current above the Zener voltage passes through a Zener diode, there is a controlled breakdown which does not damage the diode. The voltage drop across the Zener diode is equal to the Zener voltage of that diode no matter how high the reverse bias voltage is above the Zener voltage.

Voltage against current graph plotted for a typical Zener diode
Now we have a pretty basic understanding of zener diode.! Let’s get on with our project 😀
int greenLed = 2; //initialising the pins on the board and assigning the variable values
int yellowLed = 3;
int redLed = 4;

int analogValue = 0; 
float voltage = 0;
int ledDelay = 1000;

void setup()
  pinMode(greenLed, OUTPUT);

void loop()
  analogValue = analogRead(A0); //asking the board to read the input from A0 pin
  voltage = 0.0048*analogValue;  // the value from this pin will be between 0-1023.
 We will need to do a calculation to covert this to a variable so we simply 
multiply the analogueValue by 0.0048 to do this.

if( voltage >= 1.6 )
    digitalWrite(greenLed, HIGH);
  else if (voltage > 1.2 && voltage < 1.6)
    digitalWrite(yellowLed, HIGH);
  else if( voltage <= 1.2)
    digitalWrite(redLed, HIGH);  
  digitalWrite(redLed, LOW);
  digitalWrite(yellowLed, LOW); 
  digitalWrite(greenLed, LOW);

this is pretty much it you can make more accurate predictions of the charge in your battery by assigning some more LED’s on your breadboard and making the rerquired changes in your code.

For instance, You can add 3 more LED’s and making the required assignment changes from the very beginning of the code and then you can simply add more else if statements and segregate the sections into which you want to divide the voltages. It will be remarkable if you are able to do this little variation by yourself you can e-mail me or comment and I will comment the required  code in the comment section as per your requirement..


Thank you!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s