Indicating weak batteries

Hi all, is it possible to measure the remaining energy in the batteries, which power the arduino? I need this for an outdoor project, a simple robot that makes panoramic images by moving a camera with two servos. This works very well so far - but: When the batteries get weak, the robot doesn't move exactly and the resulting image fails, which unfortunately is not easily visible from outside. The best thing would be, if my arduino could warn me, if it's batteries are too weak. The second best would be some sort of LED, that goes out (or on) when the batteries are too weak. Any ideas, hints, links? I tried to search myself but there are too many other similar topics with "batteries" :-( Thanks and best wishes, Christian

Depending on the batteries, you could monitor the voltage with an analog input and once it gets below X volts, light a blinky or something.

If the controller is directly powered from the batteries then it is possible to measure the voltage of the internal reference vs. VCC. This in turn allows to infer VCC without any external components. However if the controller is powered through some regulator this method will most probably fail.


There are several methods of measuring battery voltage and predicting remaining battery charge. However a lot of details need to be worked out and they are dependent of the actual battery chemistry being used, the batteries nominal voltage output range, batteries MAH rating, and other details. If you can better describe your power system in detail perhaps we can suggest effective power management methods you might include.


How about using a Voltage divider in case of the voltage is more than 5v and input it in Analog pin to get a reading between 0 to 1023 (0 to 5 volts), if we take Approximately let the max value be 1000 and divide it by 5 so every 200 point drop you will have about 1 to 1.5 volt of power drop, so one can Light up an LED when the reading goes below 200.

Thank you all for the answers! This is very helpful for me.

I think measuring the voltage with an analog input would be an easy first step. I will try to find some wiring diagram for this. With this method it would also be possible to measure the voltage drop when moving the servos which I believe is the crucial point. This would possibly allow to use different kinds of batteries/rechargeables.


However if the controller is powered through some regulator this method will most probably fail

Is this the case when I power my arduino simply with a battery pack (6 x AA) over Vin Pin?

@retrolefty Thank you for offering me further help! My batteries are connected very simple (see above). I'm using normal alkaline batteries now, but I'm thinking of taking rechargeables (NiMH) because they may be cheaper in the long run and possibly more stable regarding the voltage. Two servos are connected to the Arduino (Signal to digital pin, Power to 5V Pin) but only one Servo is active at once.

Thanks for helping! Christian

6*1.5V = 9V. If the controller is still alive there must be a regulator in front of it.


Udo, now I understand your argument. Between the controller and the batteries is the build in voltage regulator, at least in my project.

Yep, hence the controller will have VCC 5V as long as the batteries are above 6-7V. This makes measuring VCC pretty pointless. A voltage divider is not side effect free either as it will put additional load on the batteries. Something you clearly want to avoid while running from batteries.

This is tricky. Right now I avoid this issue completely. As long as there is power I will not measure it. Once it fails I know the batteries are depleted. However this is poor practice with rechargables.


Ok, thank you.
As voltage dividers are quite new to me, let me draw some kind of wiring diagram. could this work (though wasting some power)?

Vin — R1 ------ R2 — Gnd
Analog Pin

When I assume that the max. voltage from 6 AA Batteries is < 10V I could take 2 identical resistors to have max. 5V at the arduino pin. If I choose them big enough (>10k?) the wasted power should stay low.

In my project (motorized panoramic head) power consumption itself is not the crucial point, as I will turn it on, let it work for some minutes and turn it of again. It is only important to know if there is enough energy in the batteries to complete one cycle (up to 150 pictures) without getting slower during the process. This slowing down is fatal for the result and often not visible from outside, so I need some technical assistance …


another Idea (to reduce waste of energy): There is already a push button in my circuitry to start the motorized panoramic head. Could I use it as described below and avoid continuous power consumption, while still being able to use it as start button AND as voltage indicator?

Vin ---°button°--- R1 ------ R2 --- Gnd | Analog Pin

regards, christian

Of course this would work. But it would only measure while the button is pushed. Not really elegant but does the job. But if you drive a pan head then maybe you have plenty of power and need not worry about a little bit of battery drain?


Ok, thanks for all comments. I'm trying now the voltage-divider-into-analog-pin solution. let's see how this works on the long run ... best wishes, christian