# How do I get 5V for a Raspberry Pi from 4 D batteries?

I'm hoping to run a Raspberry Pi and a hobby servo off 4x1.5V D size Alkaline batteries. The batteries are brand new and at the moment I am measuring 6.5V from the 4 in series. I'm guessing each cell is about 8000mAh although they don't say on them. The servo in question is this one.

I have an LM7805 voltage regulator but I'm guessing even if I found it a heatsink it won't be able to handle the current, also I believe they stop being able to regulate properly if the input voltage is below 9V.

What are my options to use instead?

• While this can be made to work to a degree, be aware that the raspberry pi isn't really designed for battery power, and doesn't really have any meaningful power saving capabilities implemented – Chris Stratton Oct 23 '13 at 14:15
• Anticipated battery life less than a week? – pjc50 Oct 9 '15 at 13:57

The Raspberry Pi FAQ states:

Can I run power Raspberry Pi from batteries as well as from a wall socket?
Yes. The device should run off 4 x AA rechargeable cells, but there may be stability issues as the batteries lose their charge. Using 4 x AA Alkaline cells will result in 6v and it is therefore recommended to use a voltage regulator.

As your batteries clearly exceed 6 Volts at least when new, use a voltage regulator to drop the voltage just for the RPi down to 5 Volts, to stay within the 4.75 to 5.25 Volts recommended by the manufacturer.

Due to the very low voltage headroom available for regulation, a 7805 regulator will not serve the purpose. Instead, use a Low Drop-Out regulator, such as the ST Microelectronics L4940V5, which is designed to deliver 5 Volts from even a 5.5 Volt source.

As pointed out by @Ignacio in the comments, when adding a voltage regulator to the power path, one must incorporate not just the voltage regulator itself, but also any additional support components as suggested in the regulator's datasheet. For 3-terminal regulators this would typically be a moderately large value (usually 10 to 100 uF) electrolytic capacitor between input and ground as a reservoir capacitor on the input side, and typically a somewhat smaller value capacitor (1 to 10 uF are commonly seen) between Vout and ground on the output side of the regulator.

For the servo itself, if you have the option, select a servo for which detailed datasheet information is available. RC servos I have encountered have been rated for 6 Volts nominal, 4.5 to 7.5 Volt supply range, but that does not guarantee that this particular servo supports those specifications.

Assuming you get an RC servo that supports the 6.5 Volt supply upper limit (most commonly available ones seem to), simply connect the servo's supply and ground lines directly to the battery + and - terminals, in parallel with the voltage regulator you will be using for the RPi. In other words, do not use a voltage regulator for the supply to the servo.

Adding a moderately large value capacitor (10uF, perhaps) between the supply pins of the servo, in parallel with a reverse-biased diode, would help reduce EMI generated by the motor traveling back to the battery and thence to the RPi.

Since both the RPi and the servo will be supplied from the same battery without any isolation between them, mentioning that the grounds of the RPi and the servo must be connected together, is redundant in this case. If the servo were to be supplied from a separate battery altogether, shorting the grounds would be something to ensure.

• Perhaps a decent capacitor in front of the regulator as well, so that the servos don't brownout the RPi. – Ignacio Vazquez-Abrams Oct 23 '13 at 11:30
• Oh, absolutely. When adding a regulator, the OP needs to also incorporate the regulator's supporting parts as per its datasheet - including reservoir and filter capacitors. Thanks for making that explicit. – Anindo Ghosh Oct 23 '13 at 11:49

I suggest not to use a linear regulator but a buck/boost DC converter module instead.

There are three reasons for it:

• a buck/boost converter will continue to supply 5V even if your battery voltage drops below 5V.

• They are much more efficient than linear regulators like the 7805 family. This lets you operate your device longer from the same set of batteries.

• There is rarely a need for a bulky heat-sink.

There are some nice pre-built modules out there that you can just drop into your design.