Jun 192013

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)

5200 & 2200 mAh USB battery packs from RS

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 https://raspi.tv
# https://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')

# create log file, overwriting any previous one
item = 'Battery log data'
logfile = open('battery_log-RS.txt', 'w')
logfile.write(item + '\n')

while True:
    logline = str(strftime("%Y-%m-%d %H:%M:%S", gmtime()))
    print "adding %s to log file" % logline

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…

screen bash
python battery_test_time.py

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.

LEDs lit on battery pack, pi and wifi dongle

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

small pack ~ 2hrs 40 minutes, larger pack ~ 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
  • ipads
  • tablet computers
  • Kindle
  • 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

  52 Responses to “Pi duration tests and review of two new lithium battery packs”

  1. Nice Report, hellped me to unterstand W and Amp. ;)
    These Battery packs are verry cheap, maybe i will try one.

  2. Thank you for this! I’m *very* interested in how they’d work as a UPS (charge while using), so I’m looking forward to your update.

  3. […] also trying them out as a ‘UPS’ as they can be charged at the same time as being used. Read the test results here Related Posts via TaxonomiesProduct review: a Slice of Pi for #RaspberryPiTesting the #RaspberryPi […]

  4. Good stuff, thanks!

  5. Make sure you test power failure in “UPS mode”. I have a very similar device made my duracell and then the input voltage drops its briefly drops the output voltage too, causing the PI to power cycle. Apparently this is a very common behaviour for these USB battery packs.

    • Good call – yes I will. If that happens, I wonder if adding a large cap would help?

      Update 1: I just pulled the plug on the charger and the Pi didn’t skip a beat. Will try this repeatedly over the next 2-3 days to see if it’s always like that. :)

      Update 2: Pulled the plug again @ 1750. No led flickers, then logged in by ssh. Everything as it should be.

      Update 3: Still going strong after 26 hours and two “artificial outages”

      Update 4: 47 hours into test. Just pulled the plug again. The Pi kept going nicely and the battery was showing all three LEDs lit = fully charged. Looks good so far.

  6. I love the smaller pack, great form factor, you could build that into a lot of projects.

    • Yes indeed. It can power RasPiCamcorder 2 quite nicely ;) Would it fit in your cine camera?

      • Thats exactly something I’m going to check out ;)
        I was really hoping to have done some more on that but my workshop floor cracked up so I’ve been digging up concrete instead :(

  7. At last – the elusive 5v battery!

    With these kinds of products, I think, lithium technology is coming of age. They’re not exactly cheap – the smaller one is almost twice the price I paid for an ordinary li-po of similar capacity – but against that you don’t need a separate charger, don’t have to worry about cell balancing and don’t need additional circuitry to regulate the voltage up or down to 5v. All in all I would say they are quite a good buy. And while I don’t approve of RS’s charging practices for credit card / PayPal customers, I’m inclined to think their product descriptions are probably reliable.

    This was an interesting review, Alex – thank you.

  8. Hey, how about Nokia DC-16 USB Charger ?

    because those two RS product not available in our Region (India)

    • Looks nice, but it’s much more expensive. The 2200mAh Nokia pack has the same nominal capacity as the small RS one, but almost as much money as the larger RS one.

  9. I’m very interested in battery powered Pi… more to the point I’m interested in getting the battery into a neater form factor. It would be easy enough to print a case with extra space for a battery but the great big looping USB cable to connect battery to Pi is a bit of a passion killer.

    anyone seen a smaller neater cable?

    • I think you’d be better off making your own cable with USB-A plug one one end, connected to 5V and GND on header P1. Then you could almost eliminate the external cable altogether. It’s only for power, not data, so no need for all the shielding that goes on a standard USB cable.

  10. […] a UPS  Raspberry Pi Hardware, Review  Add comments Jun 222013   At the end of my previous blog post, I mentioned that I was going to test the large pack to see if it was suitable as an […]

  11. Not that it matters now, but you could have added a sync http://stackoverflow.com/questions/15983272/does-python-have-sync after each call to logfile.close to reduce the risk of corruption.

    And it’s purely a stylistic thing, but I’d add ‘import os’ and then change

    # create log file, overwriting any previous one
    item = 'Battery log data'
    logfile = open('battery_log-RS.txt', 'w')
    logfile.write(item + '\n')


    # delete any existing file
    if os.path.exists('battery_log-RS.txt'):
    write_log('Battery log data')

    Actually, I’d probably have just written such a simple script in Bash:

    rm -f "$LOGFILE"
    function write_log {
        echo "$1" >> "$LOGFILE"
    write_log "Battery log data"
    while true; do
        logline=$(date +'%Y-%m-%d %H:%M:%S')
        echo "adding $logline to log file"
        write_log "$logline"
        sleep 60

    Anyway, hauling myself back on-topic ;-) these battery-packs look interesting – Painless Portable Pi Pentavolt Power Packs!

  12. And I’ve now just watched your video review too.
    I’m considering a project in which I’d need to “mod” the smaller battery pack to make it a bit shorter and directly solder on connection wires – how easy/hard do you think it would be to hack the battery out of its metal case? Would doing so be likely to damage / puncture the battery in the process?

    • It seems that the metal is solid and continuous, so the only way in/out is through the plastic end caps. The USB end one could probably be prised off, but the one at the other end is flush, so nothing to “get a purchase” on. I’d think it might be “interesting” trying to take one of these apart. ;)
      I’ll send you an email about how to use the same code plugin I use in my posts. It works in comments too.
      (See I’ve edited your comment above – the indents were all still there, but just displayed wrongly.)

      • Sounds like it might be an “interesting” project for one weekend then ;-) Hopefully once the end caps were ‘loosened’ the battery would just slide out, and it hasn’t been glued to the metal!

        • My battery (the smaller one) turned up today. Turned out to be fairly easy to get apart (although I’ve obviously voided any warranty!). The end-caps are just two pieces of 1mm-thick sticky-backed plastic, and once those are prised off (you’ll need to use a knife or something to get the bottom one off – it’s a bit fiddly), there’s two metal end-plates each held on with four tiny screws. And then once all 8 screws are removed, the whole assembly just slides right out :)
          Here’s a picture of the insides: https://www.dropbox.com/s/ijc9xp0v5l77z17/RS-battery-guts.jpg
          The battery itself measures 66mm long, with a diameter of 18.5mm. Just need to work out now where suitable places on the circuit boards will be for soldering permanent connection wires…

  13. Funny thought just occurred to me – I wonder if anything ‘bad’ would happen if you connected the battery output to the battery input (on the same battery), or if it would indeed try to ‘charge itself’? ;-)

  14. i have just started a test using an Anker® Astro3E Mobile Battery Pack 10000mAh from amazon i cant get screen to work so i am using “nohup python tesp.py &” and i will get 2 logs as nohup creates its own output log

    • Let us know how long it lasts for :)

      • Hi running time accoring to time stamps 18 hours, 24 minutes and 30 seconds i have a raspbery pi b with a 7dayshop WiFi which has a Ralink Technology RT5370 chipset according to lsusb.

        I was wondering if we could do a pratical realistice load test say for example photos for a timelapse?

  15. RS has released a 10400 mAh-pack now ( 775-7517 )
    Considering buying, but it also has to support “charging while charging” and RS-site has no easy way to contact them with.

    Anyone know?

    • Have you tried downloading the data sheet on that product? It usually has a PDF download for each product

      • The datasheets for 775-7508 and 775-7517 are almost identical, so I’d guess that the 10400 mAh model uses the same/similar controller board as the 5200 mAh model, just with more/bigger batteries? I could be wrong of course!

        I giggled when I read in the datasheet that “This power bank is mainly for charging when the portable products are with less power. Can be used to charge anytime, anywhere and be the good friend of people.”
        Some of my best friends are batteries…? ;-)

        • A spot of Chinglish there? I knackered a lipo over the summer by leaving it connected to my portable screen for several days. I was upset because it was one of my RC flying batteries, not because it was my friend ;)

          • “…knackered a lipo…”
            Presumably that’s because you didn’t have an over-discharge protection circuit, which isn’t a problem with these RS batteries? Just to avoid any confusion :)

            • It was one of my Radio Controlled plane flying lipos. They have no protection circuitry on whatsoever (it’s usually in the ESC).

              Nothing to do with the products reviewed here, which certainly DO have protection circuitry.

  16. A problem with the smaller battery pack is that it doesn’t have any “charge level” indicator, when it gets flat enough it just suddenly cuts out without warning (and switches off the blue LED). It doesn’t even flash at you to warn you it’s getting low :-(

    But as I’ve already hacked-apart my battery pack, maybe I’ll follow one of Alex’s other tutorials and hook up an ADC directly to the battery, and then monitor at what voltage it cuts out, so then I’d be able to “safely shut down” my Pi before the battery’s discharge protection circuit pulls the rug out from under me ;)

    • I was pretty sure the indicator led changes colour on the small pack Andrew. Does yours not do that? blue fully charged, green halfway and red for red alert :)

      • Not that I recall… but then I haven’t spent several hours just staring at the LEDs, waiting for them to change colour ;) (i.e. it _might_ be that they change colour, but I only notice the battery has cut out when I turn round and find my display has gone black, because the Pi has been rudely powered off). Maybe
        if I get round to doing the ADC battery-voltage monitoring circuit, I’ll also set the PiCamera to periodically ‘log’ the colour / status of the battery’s LEDs too ;-)

        AFAICT the blue LED means the pack is ‘switched on’ and providing 5V output, the red LED means the pack is charging, and the green LED means the pack has finished charging and is fully charged. I tend to operate my pack in “portable mode” rather than “UPS mode”.

  17. Hi Alex,

    interesting test !
    As extra info, check out my experience with the newer version of these RS powerbanks.
    I’m using the 10,4 Ah type (RS 775-7517) now for several months as “UPS” (i.e. connected to a 2,1A/5V RS power supply on the input, and feeding an RPI on the output). I’m having several configurations : RPI as webserver with lit-up display, RPI as surveillance camera, and RPI as sensor concentrator. This in a house with at least two power cuts a week… all configurations still running fine. So I’d say that the RS 775-7517 is a pretty reliable solution for any RPI installation.
    And if ever needed, the button on the powerbank can also be used as a “hard reset” for your RPI.

  18. Hello,

    it’s actually possible to use several different USB power bank models as UPS. My Pi is now continuously running for more than half a year by using this method.

    I’ve written a daemon program (GPL licensed) which even allows you to shut down the Pi on power outage, monitor the power supply status, and to compute the current battery charge level quite accurately. This is all possible by using a simple trick which enables the Pi to detect a power outage.

    Watch a short demo video of this UPS and download the program for free from http://raspi-ups.appspot.com

    @Alex I’d be very happy if you’d consider writing a post about this on raspi.tv – I think many people are interested in having a battery-powered Pi, including the ability to shut down the system properly on power outage or when the battery becomes low. Feel free to link to the demo video on youtube if you like :-)

Leave a Reply to alex Cancel reply