Introduction: Arduino Uno R3 Battery Tester
This simple project is intended to help you in answering the lifelong question "Does this battery have any juice left?". Although popularity of single cell batteries (such as AA, AAA, C and D cell) is diminishing, there are still many small devices like TV remotes, flashlights, and other small portable electronics that run on these forms of power.
Step 1: Hardware Required
In order to make a battery tester, there are a few things you will need:
-Three 560 ohm resistors
-One 2.2k ohm resistor
-One green LED
-One yellow LED
-One red LED
-a breadboard
-various jumpers (connecting wires)
-One Arduino Uno R3 Microcontroller with usb cable
This project will cost somewhere in the $30-$40 range, however the most expensive part is the Microcontoller (~$30), which is of course re-programmable so this cost can be displaced over future projects.
These items can be found on easily on Amazon.com or Sparkfun.com
Step 2: The Wiring
A little wiring is required to get this circuit operating, thankfully the Arduino is supplying the power so there is no need for an external power supply, that being said be careful with other projects as the Arduino can't source a large amount of current. The Schematic is also slightly open ended to allow the user to connect the probing wires or a wiring harness to various battery sizes. Attached is an electrical schematic drawn up for the project, courtesy of John Boxall at the Arduino Workshop.
Step 3: The Code
The attached photo contains the code you will upload to the Arduino. To upload this code simply download the Arduino sketch IDE from Arduino's website (http://arduino.cc/en/Main/Software).
If you want to challenge yourself, I suggest taking the logic from the sketch language and making a C program. To do that you will need Atmel Studio 6 (free and on Atmel's site) and a bootloader (attached, courtesy of Purdue ECET), you will also need to note that the Arduino Uno R3 uses an ATMega328p microprocessor.
Attachments
Step 4: Finishing Up
Once everything is wired and the code is uploaded, simply hook the battery positive and negative ends of the battery or wiring harness to the positive and negative leads of the wires.
If a battery such as a AA cell is fully charged it will be near 1.6 Volts, if the voltage measured is greater than or equal to 1.6V then the green LED will briefly turn on, indicating the battery is fully charged, if the voltage is greater than 1.4 Volts and less than 1.6 Volts then the yellow LED will turn on, indicating the battery has some charge, and if the voltage is less than or equal to 1.4 volts then a red LED will briefly turn on, indicating the battery no longer has a significant charge. This process can be conducted indefinitely as long as there is power supplied to the Arduino from either a wall-jack or a computer.
19 Comments
2 years ago on Introduction
To be accurate, you need to drain the battery while measuring; that is, put a load on it. But that load depends on the type of battery (AA, AAA etc). So, there’s more work to be done!
7 years ago
Is there soldering required?
Reply 5 years ago
No there isn't no soldering required your good man! :)
6 years ago
uploade a text file with the code pls
7 years ago
I would put a high value (around 100k) resistor between A0 and GND to avoid floating values when the battery is not connected (analog input is very sensible). You can add some "if's" to this sketch to check Li-Ion batteries. Nice projects, thanks for sharing.
7 years ago
Is it possible to repeat the code over and over until the red LED comes up? Also, would it be possible to attach some device to the same battery that is being tested? Please answer fast!
-J
7 years ago
I am new to Arduino and i bought a kit containing useful items related to the Arduino. Things such as resistors, a button, LED lights, etc. So far I only have 330 Ohm resistors and 10K Ohm resistors. Do you know if this project would still work by using 330 Ohm instead of 560 Ohm and 10K Ohm instead of 2.2K Ohm?
7 years ago
for what reason are we using 2 Kohm Resistor ?
thanks
7 years ago
for what reason are we using 2 Kohm Resistor ?
thanks
7 years ago
I wonder how can I change the circuit so that there will be charging/discharging cycle, and it will be as simple as this circuit?
8 years ago on Introduction
Can i use this application in some locally available Arduino clone?
8 years ago on Introduction
Hi I'm new in this arduino world and I would like to know why are you multiplying 0.0048*analogValue.
Thank you! :D
Reply 8 years ago on Introduction
because analogRead return a value between 0 and 1023.
1023 = 5V
0 = 0V
so to convert the analogRead's value to volt you need to multiply analogValue by 5/1023 (0.00488)
:)
9 years ago
Just be careful not to use a battery with high voltage or high amps
Reply 9 years ago on Introduction
High amps doesn't hurt Arduino, because of the resistor, and high internal impedance of ADC module, so these "high amps" won't go out the battery.
But high voltage is some kind of problem. For that I'd use zener diode, just like in my comment below ;)
9 years ago on Introduction
I would add one zener diode after the A0 resistor just to be sure, that if some genius connects 12V battery (car or little from flashlight) it won't burn your arduino ;)
But despite this it's simple and great project ;) Hope there will be more like this on i'bles.
Reply 9 years ago on Introduction
Excellent idea!
9 years ago
This is a nice project. If you want to make it even less expensive, this project can be made with a single chip (plus rwsistors and leds) like the attiny85, which costs under $1 (you will need some way of programming it, though)
Reply 9 years ago on Introduction
Arduino can be easily used for programming ;) But if someone doesn't have one, STK200 is veery cheap option, and USBasp is quite cheaper than Arduino, and can be widely used ;)