Is there any way to use an Arduino + LEDs to give a reading for battery life. I am totally new to this; I know next to nothing. Any help would be greatly appreciated.
What type of battery do you want to detect battery life on?
Each major class of battery, e.g. zinc-carbon, cadmium, lead-acid, NiMh, LiPo, etc. (see List of battery types - Wikipedia or Electric battery - Wikipedia) have very different performance.
So, for each type of battery, you'll need to decide how to convert some measurements into a battery life estimate.
An Arduino has analogue-to-digital converters (ADC) to measure voltage, and with a bit of electronics, current. So it is feasible to estimate battery life.
HTH
GB
so how would setup a lithium polymer bat with an indicator?
i have a 3.7v 800mah li-po and im interested in making a low bat light so i know when its almost dead
According to Wikipedia on LiPo batteries, you need to detect the LiPo battery voltage dropping to 3V. At that point it should be shut off.
So, you'd start by calibrating the Arduino analog inputs to 3V. The battery can only be charged to 4.23V, so the analog input could be connected to the LiPo battery.
HTH
GB
so i should start with the anologread function and read the + terminal on the battery and set an if statement for when it hits 3v? that dont sond to hard what about a ni-cad or ni-mh would it b that easy or not?
so i should start with the anologread function and read the + terminal on the battery and set an if statement for when it hits 3v?
Yes.
that dont sond to hard
There are always things which appear when you try to do things for real, but this seems like a straightforward starting point.
Have you got access to a voltmeter or multi-meter?
I'd practice by using a potentiometer and multi-meter before trying a battery.
what about a ni-cad or ni-mh would it b that easy or not?
I don't know in any detail.
The Wikipedia battery type page will be a good place to start, and Google will help.
My recollection is some batteries types are quite hard to detect impending exhaustion, but aren't damaged if you don't get it right. Other battery types are easier to do (e.g. LiPo) but are permanently damaged if you get it wrong.
Of course there will be some that are difficult and easily damaged (otherwise where would the fun be ![]()
The harder ones maintain a very similar voltage until just before dying. I think, with some research and calibration, you could probably do that type too.
You could measure the voltage drop across a small value resistor (e.g. 0.1 ohm, with a suitable power rating) and hence calculate the current used, and get reasonably close (by measuring current over the time the battery is used, and knowing approximately what the battery capacity is, which is measured in Amp hours, or milli amp hours).
Questions to ask are what is the purpose, how will it be used, what is the cost of failure? If you can be specific and accurate, it'll get easier. If the list is long, try to prioritise them, and do a useful piece at a time.
HTH
GB
well i have a digital multi meter and i have about 4 or 5 li-po batterys so im set on that end but i dont have any resistors that low the lowest i have right now is 1ohm will this work? and the cost of failure is nothing if i burn up a chip or batt no big deal thats all part of the learning process. so how would i go about testing with a pot? i have a few around not sure of the value or how to measure it but i feel confident i can get it working with a little push in the right direction.
well i have a digital multi meter and i have about 4 or 5 li-po batterys so im set on that end
In that case you are good to go.
AFAIK LiPo's are very clear with their voltage when they are almost exhausted, so that all you need. You might get a diode to protect the Arduino from mistakes connecting the battery. (note a diode will drop about 0.7V)
but i dont have any resistors that low the lowest i have right now is 1ohm will this work?
You need a resistor if you want to measure something which is more complex, where you need to measure current.
Whether 1 ohm is useful, strongly depends on what is being powered and the power rating of the resistor. I would use a low value resistor so that it doesn't dissipate a lot of heat, or interfere with the thing drawing current.
If the resistor is 1 ohm, and rated at 0.25W power dissipation, then
P = 0.25W
= IV
= I(IR) (from Ohms law, V = IR)
= IIR
As R = 1
II = 0.25
So max I = square root of 0.25 = 0.5A
Give yourself plenty of headroom (i.e. don't use it for anything which draws more than, say, 0.25A)
so how would i go about testing with a pot?
I'm just suggesting you use the pot to simulate a battery as it runs down.
Connect the outside connections of the pot across a voltage (e.g. Arduino 5V or fully charged battery), and using your multimeter, adjust the centre wiper to just above the cut-off voltage.
Connect an Arduino analogue input to the centre wiper, and try your code against the voltage from the pot.
Also think about what happens when you wind the pot back above the 3V. What should happen?
This is much easier than running your LiPo's down to 3V ![]()
HTH
GB