Arduino Forum

Using Arduino => General Electronics => Topic started by: thelonelyprogrammer on May 01, 2013, 02:24 am

Title: Measuring battery life remaining with just an analogue in pin
Post by: thelonelyprogrammer on May 01, 2013, 02:24 am
Hi,
simple idea, unlikely to work.

When i test a battery with a multi-meter i measure its voltage, as the battery dies this decreases.

if i connect the battery that is powering my arduino into an analogue in pin as well as vin and ground can i not then estimated battery life remaining for the arduino with this read in value?

thanks
Title: Re: Measuring battery life remaining with just an analogue in pin
Post by: dkl65 on May 01, 2013, 02:41 am
I don't know if your method would work, but the Arduino can measure its own working voltage with this code: https://code.google.com/p/tinkerit/wiki/SecretVoltmeter.
Title: Re: Measuring battery life remaining with just an analogue in pin
Post by: DVDdoug on May 01, 2013, 02:48 am
That should work just as well as a multimeter.   (If it's over 5V, of course, you'll need a voltage divider.)

Batteries don't discharge linearly, but once you get a feel for the discharge pattern of your particular battery in your particular application, you should get useful results.


:D My laptop usually thinks there's 3 hours left right before it dies!
Title: Re: Measuring battery life remaining with just an analogue in pin
Post by: fungus on May 01, 2013, 08:22 am

simple idea, unlikely to work.


Correct.

Measuring battery life accurately is difficult, every battery is different.

Title: Re: Measuring battery life remaining with just an analogue in pin
Post by: oric_dan on May 01, 2013, 09:00 am
Battery life remaining isn't overly simple to determine, but it's still a good idea to monitor
battery voltage so you know when the system is about ready to crash. If you're using an
LDO regulator that's known to dropout when Vin gets down to 6V, then when it reads
6.25V, you know it's time to make peace with the world. Save the data to EEPROM,
shutdown activities, and go to sleep.
Title: Re: Measuring battery life remaining with just an analogue in pin
Post by: fungus on May 01, 2013, 09:17 am

Battery life remaining isn't overly simple to determine, but it's still a good idea to monitor
battery voltage so you know when the system is about ready to crash.


To clarify: Knowing remaining battery power is difficult unless you know which battery you're using and have watched it die before (this is how 'smart' laptop batteries work - they store their own discharge curve inside the battery). Even so, if the load is variable (eg. varying hard disk usage) the estimate is only approximate.

Detecting when the battery is actually in the process of dying isn't difficult - the voltage typically drops off very rapidly at the end.
Title: Re: Measuring battery life remaining with just an analogue in pin
Post by: MichaelMeissner on May 01, 2013, 02:03 pm

When i test a battery with a multi-meter i measure its voltage, as the battery dies this decreases.


It depends on the battery type.  Non-rechargeable alkaline batteries do tend to have a slope in voltage as the battery is drained.  Ni-mh/li-po rechargeable batteries tend to deliver the same current for most of the time, until the battery is almost depleted, and then it will start dropping off.  Here is a site that discusses the different types of batteries: http://batteryuniversity.com/ (http://batteryuniversity.com/)
Title: Re: Measuring battery life remaining with just an analogue in pin
Post by: CaptainJack on May 01, 2013, 07:19 pm
I did exactly what you suggest. I know which batteries I use for my project, I drained them once to measure voltage versus total current in mAh, so I can estimate how much juice is left. If you change the batteries you most likely have to make a new curve, but it's better then nothing. I can also display voltage left from my battery pack, most of the time that is my queue to change batteries, in order to keep my LDO working.