Since the Raspberry Pi is so small, and has a similar architechure to most phones, I was thinking it would be fun to see if I could run it from batteries. I wanted something that would give it a long run time, not something that would only run for half an hour. It would also have to utilize rechargeable batteries, otherwise, the
cost of the batteries would quickly outrun the cost of the Raspberry Pi. Also I have no abilities to build my own circuits, so it had to be something I could buy ready to use.
After doing a little searching, I was able to find this USB battery backup case. It uses 18650 lithium batteries. It’s meant for charging cell phones and other gadgets when they run out of power, so I figured it would work quite well for powering the Raspberry Pi. Most people in North America will probably be a little unfamiliar with these batteries. But I think they are great. They look like AA batteries, but are actually quite a bit bigger, are rechargeable, and run at a higher voltage. They are actually similar to the cells that are used in many laptop batteries. I had used them before for bike lights that I had purchased from that same site, and was really impressed with how much power they were able to hold. I don’t know why they don’t have batteries like this in North America. They kick the pants off anything you can find around here.
The battery backup case provides 5V at 1A and each of the batteries I purchased was rated at 2400 mAh and 3.7V. The battery backup case also doubles as a charger for the batteries. Plug into the USB Mini on the battery backup unit, and plug the other end into a phone charger (similar to what you use to power the Raspberry Pi, and it charges. The full size USB port is used for powering devices. Get a cable that is full sized USB on one end, and micro USB on the other end, and you can use it to power your Raspberry Pi. This is one of my main disappointments with the device. Had they used USB micro to charge the batteries then you could have used the same charger to recharge these batteries as you use to power your Pi, but the way it’s set up you need 2 different cables. This unit, like the Pi, comes without any cables. Luckily I had a few lying around.
My first use for the device was to test it for it’s intended purpose, to charge my phone. I charged the batteries in my old charger, as I was unaware that this device even had charge capabilities, and then put the batteries in the backup unit. Plugged it into my phone. Nothing. Pushed the button. Nothing. I really just thought the thing was completely dead. I decided to just Google for “dealextreme 129749” which is where I bought it and the SKU, and about 5 links down the page I found this page, which was somebody else who bought it and had the same problem. Of course, the page is in Polish, so what could I was stuck. Google Translate to the rescue. It did a fair job, good enough for me to figure out that if I hooked up USB mini port up to a charge or computer, that
the device would turn on, and start working. It did a pretty good job at charging my phone. It worked about as good as it does when plugging my phone into the wall. The batteries didn’t get hot at all, and there was a little bit of heat from the circuit part of the charger, but nothing worth worrying about.
Then it came time to try it out on my Raspberry Pi. I wrote a program in Python to record the current time to a file every minute, so I wouldn’t have to sit around watching and waiting for it to die. The program is as follows
import time i = 0 print('START!') while i >= 0: f = open('timelog.txt','a') nowstr = time.strftime('%Y-%m-%d %H:%M:%S') print(nowstr) f.write(nowstr) f.write('\n') f.close() time.sleep(60) i = i + 1 print('DONE!');
There’s obviously some testing code left in there, switch the condition of the while loop to “i < 5” if you just want to run a test and have it exit after 5 minutes. I opened an closed the file each iteration because I didn’t wanted to be reassured that the writes wouldn’t all disappear when the power cut out.
Now for the test. I started up my Pi, ran the time logging program in the background, and then let it run. I wanted to see how well it would do under minimal load. The results were pretty astounding. It ran for just under 5 and a half hours. Which once you count in the boot up time and me starting the test probably came in pretty close to exactly 5 and a half hours.
Being somewhat impressed, I wanted to now test it under full load. It would be easy enough to write a busy while loop to get it to use the CPU at 100%, but I wanted to stress out the GPU as well. So I posed a question on raspberrypi.stackexchange.com and one person suggested using Quake 3 to test it out. I figured that would use probably as many resources as possible, so I gave it a go. In the background I ran my python time logging program same as before, and in Quake 3 I ran a demo loop to max out the resources. I put the following in a file called demoloop.cfg located in the baseq3 folder for Quake 3.
set loop "vstr loop1" set loop1 "set timedemo 1 ; demo four ; set nextdemo vstr loop2" set loop2 "demo four ; set nextdemo vstr loop1"
Then I started Quake 3, and ran the demo loop by bringing up the console with “~” and typing:
exec demoloop.cfg vstr loop
The demo began to loop. I had to use some commercial .pk3 files because the demo wouldn’t run with the freely available files because missing maps. I watched for a while, using my laptop on the side. I didn’t expect it to last very long with the CPU and GPU undergoing so much use. Eventually I got bored and went to bed. In the morning, I woke up and checked the results. The total run time was 4 hours 23 minutes before the log program stopped logging the time, and I presumed the Raspberry Pi lost power.
All in all I have to say that I’m pretty impressed that I got such good performance out of this battery pack. The batteries stayed cool, even when running my Quake 3 stress test. This battery pack did quite a good job, and would probably work quite well for anyone who wanted to power their Raspberry Pi off batteries.