Interfacing a Raspberry Pi with a Radio Controlled car was on my list of projects so I need to experiment with powering the Pi from batteries. I had a number of basic requirements.
- Use AA batteries as I already had lots of rechargeables and chargers
- Reduce the overall cost low by keeping additional electronics to a minimum
The batteries would be required to power the Pi which needed 5V. AA batteries can vary in voltage from 1.2V-1.5V so some sort of voltage regulator was required to provide a stable 5V to the Pi. With the addition of a Bluetooth or WiFi dongle and some GPIO interfaces the regulator needed to provide 1A of current.
After some research I decided to buy a “UBEC”. In the Radio Controlled world this is a “Universal Battery Eliminator Circuit” but is really just a plain switch mode voltage regulator to everyone else. The device I bought from eBay was £5, provided 5V from an input of 5.5V-20V and was capable of supplying up to 3A. Perfect.
Next I bought a battery box. 4 AAs might struggle to provide enough voltage to the regulator so I opted for a 6xAA battery box. I already had plenty of rechargeable AA batteries so I grabbed some Sanyo Eneloop (NiMH) cells and charged them up. These batteries are great as unlike regular rechargeables they hold their charge even if left for months without use.
The final stage was simply connecting the battery box to the UBEC regulator and the regulator to the Pi. The UBEC came with a 3 pin connector. I carefully repositioned one of the pins so that they had a space between them. This allowed the connector to plug onto the Pi’s GPIO header and provide +5V to Pin 2 and 0V to Pin 6.
Here some photos of the basic setup I used to test my battery pack :
And the results? Well I ran two tests. I took a Raspberry Pi and plugged in an Edimax 7811 USB WiFi dongle. Then I connected the UBEC to the GPIO header. Finally I inserted the last battery into the battery holder to complete the circuit. I gave the Pi 60 seconds to boot and then connected to it using Putty via WiFi. I ran this command in Putty to constantly display the system uptime :
watch -n 60 uptime
Every minute the Putty window refreshed. This kept the WiFi connection active and proved the Pi was still operating. When the Raspberry Pi finally ran out power the last figure displayed in the Putty window gave the total time the Pi stayed powered.
- Model A (256MB) gave 16 hours 48 minutes
- Model B (256MB Rev 2.0) gave 7 hours 15 minutes
These are amazing results in my opinion. The Pi wasn’t asked to do any real work so I expect the times would be reduced in a real project but I was still impressed. If I doubled the number of batteries the Model A would probably run for 24+ hours!