I recently wrote a piece for MAKE magazine’s projects section. The text of the article follows; you can see the whole thing on the MAKE site
The versatile system-on-a-chip Raspberry Pi board seems to have something for everyone: plenty of ports for display, sound, and USB peripherals; a pin header for relaying inputs and outputs from the physical world; and space for a dedicated camera module, which makes it great platform for all sorts of video experiments.
Still, there’s one thing the Raspberry Pi doesn’t come with: a good battery power supply. Powering the board from a wall wart is fine when there’s AC power handy — but a long-lasting and reliable battery source is essential to getting the Pi away from the desk and out in the world, where it belongs. You can buy compact Pi battery packs, like the Smart Power Base (Maker Shed #MKMTS01 at makershed.com), but I decided to build a big one — and in this project I’ll show you how you can too.
At around $40 the basic Pi board is cheap enough, but accessories (like a case, a camera, and a powered USB hub) can easily double or triple that cost. That’s one reason why I chose to power it from the same rechargeable batteries my heavy-duty cordless drill/driver uses. These 18-volt batteries are about the size of a softball — big enough to supply power for a long run, and tough enough to stand some rugged treatment. And they have another thing going for them: I already own them (along with their charger), and I suspect lots of other folks do too. Since I’m not sending my Pi aloft (yet), weight isn’t an issue. But there’s another challenge.
Trial and Error
To use these powerful batteries, you need to bring their 18 volts (or so) down to exactly 5 volts, which the Pi requires. There are several ways to do it, and I tried a few of them. First off, I made a circuit with an a 7805 linear voltage regulator I happened to have in my drawer. This IC is familiar, cheap and simple; it also fails at the task miserably, because it isn’t very efficient at voltage conversion. Mine heated up like a hot plate within minutes, letting off a smell like burning French fries and crashing the Pi (which, fortunately, was not damaged).
I also tried using a car-power charger for an iPod. The gadget I had, which sits in what used to be called a cigarette lighter socket, was rated for up to 24 volts input, and promised to deliver 1,000 milliamps at a 5-volt output: just what the Pi ordered! But alas, it didn’t work: The Pi crashed or lost contact with the server after it had run the camera for just a short time. I suspect that the charger didn’t deliver the power it was rated for, and the Pi, with the camera and the wireless dongle, simply overwhelmed it. It was time to find a better way to get power from my battery — and here’s how I did it.
- After checking forums and doing a web search, I found a set of components that worked well: Efficient switching regulators (such as the OKI-78SR Series by Murata) have now largely replaced the old 7800 series ICs. I chose Murata’s model OKI-78SR-5/1.5-W36-C, which delivers 1.5 amps at a 5-volt output. It can handle a range of input voltages from 7V to 36V, needs no heat sink, and is around 90 percent efficient.
- To complete my power converter, I added a 220µF electrolytic capacitor to help smooth the output and compensate for spikes in power demand; a mini on-off slide switch; a small red LED and series resistor, to indicate when the unit was powered; and a female USB-A jack (so I could use the same power cord that came with my AC adapter to send 5-volt power to the Pi).
- I also got some 18-gauge stranded wires, with an inline fuse holder and 2-amp fuse, from an auto parts store. And I picked up a small square of perforated circuit board, plus some screw terminals. The schematic for my rather simple circuit is shown here
- Since it might have to endure travel, neglect, or active abuse, you’ll want to make sure the power supply is a rugged, self-contained module. First, fit the screw terminals for the input and output voltages onto the bare perfboard, with their thick leads poking through the holes. One terminal takes the positive voltage in, the second is a common ground, and the third provides +5V out.
- Next, place the switch. It may have tabs that can be slotted into the board, or lugs that are bolted on; either way, make sure it’s rigid. These are probably the largest components you’ll be using, so your board can be sized (or trimmed) accordingly. Mine is only about 1″ square.
- Building the rest of the circuit is easy; just pay attention to the pin numbers of the regulator and the polarity of the LED and capacitor. Try to keep the component leads short, make sure nothing can get loose, and be sure to get a good solder bond.
- Connect your rechargeable drill battery through the stranded wires and the 2A fuse to the screw terminals on the board. I used screw terminals so the wires can be replaced if they become frayed, or if a different type of battery is used.
- How do you connect the wires to the battery? It depends on your battery. Mine (for older 18V DeWalt cordless tools) has spade-like positive and negative terminals in its stem. By taking a standard female automotive-type wire connector and slightly widening the receiving end, I made it fit the battery terminals perfectly. If you have a different type of battery, it might take a little ingenuity to find out what connector will work best. You’ll want a good, tight connection that won’t come loose under a little strain or jiggle.
- Use a multimeter to verify which battery terminal is positive and which is negative. Make sure you connect them to the correct inputs on the converter board! The 2A fuse will give you some protection — but if you short it out or reverse the polarity, it may not save you from grief!
- Connect the circuit board’s power output to the Raspberry Pi, either through the board’s micro-USB socket, or by connecting directly to GPIO header pins 2 and 6.
- I prefer to use the USB socket: that way, you get protection from the board’s built-in polyfuse (which is bypassed if you use the header pins), and you keep the header free for other uses. Plus, if you need to locate the battery pack away from the camera, you can simply use an extended USB cable. However, if the circuit is constructed properly, it should work equally well supplying the GPIO pins.
- For this build I terminated the power output with a female USB-A jack, so I can simply plug my AC adapter’s power supply cord (USB-A to micro-USB) right from the battery supply into the Pi. I wired the jack on a short length of thin, 2-conductor cable, paying careful attention to its polarity (see diagram). I could just as easily have hard-wired the jack right on the board — but I opted for the screw terminals to keep all my options open.
- After my experience with the 7805, I wasn’t about to hook this gadget up to the Pi without testing it first. Initially, I just connected the battery with nothing on the output end, flipped the switch and let it “idle” for a few minutes. I couldn’t detect any heat, and I measured 4.95V at the output terminals. Next, I placed a light-up USB toy into the socket and turned it in. Its LED light glowed brightly.
- Finally I plugged the Pi in and booted up. It worked like a charm, both on desktop tests and in the field.
- Recently I’ve used this battery source to make time-lapse movies up to 8 hours in length, and I haven’t had any problems. After a day of recording, I can disconnect the battery and charge it up in about 2 hours.
- With a good-quality camera and a generous pin header for input and output, the Raspberry Pi makes a fun platform for any number of computer projects. But the various accessories you need to purchase (wireless dongle, AC power adapter, case, USB hub, etc.), let alone add-ons like a camera or TFT display, can strain an experimenter’s budget and seriously stretch the claim that it’s a “$40 computer.” Building this portable power supply that uses your rechargeable drill batteries plus about 20 bucks in parts, lets you get the Pi off your desk and out into the wild.