I’ve got a couple of new battery packs in from RS. As part of my testing, I wanted to see how long they could power a Pi at idle, with nothing but the battery pack and an Edimax wifi dongle connected.
I know how much power this uses because I’ve made measurements in the past.
Model B with just Edimax = 2.0 Watts at idle
Model A with just Edimax = 0.81 Watts at idle (included for completeness – this test is on model B)
I just want to know roughly how long it lasts
Amps, Volts, Watts and milliAmp.hours are all very well, but what people really need to know is…
For how long can this battery pack power my Pi?
These packs have built-in protection circuitry, so I’m not measuring the battery voltage. This circuitry prevents over-discharge, over-charge and gives short-circuit protection. The pack will shut down when its low voltage threshold is reached.
The Python duration test script
I wrote a very simple script, which is mostly a cut-down version of the test I did previously with an ADC and unprotected lipo).
This new script logs a record in a file, on the SD card, once per minute. When the power gets cut off, hopefully the last entry in the file will tell us how long the Pi was on for.
That’s the idea anyway. Here’s the script…
#!/usr/bin/env python2.7 # script to log to a file every 60 seconds # by Alex Eames http://RasPi.TV # http://raspi.tv/?p=3516 # the idea is that when the power gets cut, we'll be # able to see what the last reading was and work out # how long the battery powered the Pi for import time from time import gmtime, strftime def write_log(logline): logfile = open('battery_log-RS.txt', 'a') logfile.write(logline + '\n') logfile.close() # create log file, overwriting any previous one item = 'Battery log data' logfile = open('battery_log-RS.txt', 'w') logfile.write(item + '\n') logfile.close() while True: logline = str(strftime("%Y-%m-%d %H:%M:%S", gmtime())) print "adding %s to log file" % logline write_log(logline) time.sleep(60)
The only thing which can scupper you is if the file system corrupts when the battery pack “pulls the plug”. This could happen, but you would be unlucky if it did. (Luck seems to be related to SD card quality and overclock settings ;) )
Ensure that the program ‘screen’ is installed
Put the above script on your Pi (/home/pi is a good place)
Methodology – how the test was run
I used the battery pack fresh off the charger, connected it to the Pi with the supplied, short, USB to micro-USB lead. Then pressed the power button on the pack. After the Pi booted up, I logged in by ssh (no monitor attached) and typed…
I checked it was working properly, and
This detaches you from the screen session, but leaves it running, so you can log out.
Then I logged out, to avoid using excess power through the wifi dongle.
Then it was just a question of waiting for it to “conk out”, occasionally logging in to check up on it. You get a nice visual indication on the battery pack’s blue led, the wifi dongle’s blue led and the Pi’s red power led.
How long did they last then?
I did this test with both packs, here are the results…
The small pack (RS part number 775-7504)
It took about 2 minutes to boot, login and get the script running. The first log entry shows 17:36:24 and the last one 21:07:36, which makes about 3 hours 33 minutes altogether. That’s easily long enough to be useful.
Since we know that the model B with Edimax dongle takes 2.0 Watts, we can derive a capacity of
2.0 * 3.55 = 7.1 Watt.hours from the little battery pack.
Dividing that by nominal voltage of 3.7 V gives us 1.92 Amp.hours or 1920 mAh. Since the pack has 2200 mAh nominal capacity, I’m assuming it cuts off at a safe level to preserve the lithium cells. If you do this, you never get the full rated capacity out of lithium cells – by definition. There’s always a compromise between squeezing the last drop out of them and how many cycles they last for.
The larger pack (RS part number 775-7508)
I was a bit slow this time and took about 3 minutes to get going. 21:41:08 logged start time, 06:31:36 logged finish time. So that’s 8 hours 53 minutes (8.883 hrs)
8.883 * 2.0 = 17.77 Watt.hours
Dividing by nominal voltage of 3.7 V gives usable capacity in Amp.hours
17.77 / 3.7 = 4.80 Amp.hours or 4800 mAh.
The pack is labelled 5200 mAh. As already mentioned, you only ever get full rated capacity out of a lithium pack if you over-discharge it. The protection circuit prevents you from doing this.
But none of that matters much. All we really care about is how long it can power a Pi.
The bottom line is…
- the smaller pack can power a Raspberry Pi model B, with Edimax wifi dongle, idling for about 3.5 hours.
- The larger pack lasts nearly 9 hours at idle.
Under heavier load, for example watching a 1080p video with omxplayer, the Pi model B uses ~2.64 Watts.
Under these conditions, from a full charge, when new…
- the small pack would give you about 7.1 / 2.64 = 2.7 hours ~ 2hrs 40 minutes
- the larger pack would give you about 17.77 / 2.64 = 6.7 hours ~ 6 hrs 40 minutes
So now you know. :) The smaller one is perfect for handbag or pocket. The larger one would power two Pis at once for a typical length Raspberry Jam.
How much do they cost?
The smaller pack is £13.50 + VAT, the larger one £26 + VAT. I can see these being very popular. The small one is a very convenient size and weight as an emergency phone charger.
What else is included?
You get a USB to iphone charge lead and a USB to micro-USB charge lead. So you can charge pretty much any USB device. You can recharge the power packs from pretty much any USB 5V source as well.
The larger pack has two USB output ports.
What else can you use them for?
You can use them to power or charge almost anything that takes a “USB” 5 Volt feed.
- mobile phones
- tablet computers
- Nintendo DS
- Raspberry Pi
I used the small one, just now, to keep my video camera alive when its battery indicator changed to the red, scary, flashing symbol.
Charge while using
They can also be used whilst being charged, which makes me wonder whether or not they’d be good as a Pi UPS? That is going to have to be tried. It’d work, as long as the pack’s input charging rate is above the output charge rate. I’ll post an update to let you know how I get on with that test.
If you want to get the updates faster, you can follow me on Twitter