Running The Raspberry Pi On Batteries

This is a wider topic than High Altitude Ballooning – there are many applications where operation is needed away from a mains supply – so I thought it would be good to describe my approach to the problem.

But first … Following these instructions WILL void your warranty. Failing to follow them properly will make you wish you still had that warranty! DO NOT hack your Pi like this unless you accept the risk!

Which Model Pi

This is a really easy one. Use the model A. Even with a wireless LAN dongle added, the model A still uses less power than the B. I’m struggling to think of a battery application where the model B would be a good choice. A model A runs on about 115mA vs 400mA or so for the model B.

What about under-clocking?

Don’t bother. It makes almost no difference to the Pi’s power consumption.

Any Power-Saving Tips?

You can save 20mA or so by switching off the PAL/HDMI outputs. Add this to your startup:

/opt/vc/bin/tvservice -off

I just need 5V from the batteries, right?

You could do that, but it’s probably not the best option. Doing so means you have an external regulator (battery –> 5V) and the Pi’s 3.3V regulator (5V –> 3.3V), so 2 places for the precious battery power to be lost.

This is where the 5V input on the Pi goes to:

  • The 3.3V regulator (which then feeds regulators for the remaining voltage levels
  • The USB port
  • The HDMI connector
  • A battery sense pin on the BCM2835

That’s it. So unless you’re using USB peripherals, all the 5V supply is doing is powering the 3.3V regulator. It can be much more efficient to do away with one of the regulators and just operate the Pi on 3.3V.

Even if you are using USB peripherals, they may actually run happily from 3.3V. I have a couple of WLAN dongles and both run just fine like that.

If you do feed 5V to the Pi from batteries, you need a 5V regulator between the batteries and the Pi, and most 5V regulators need in excess of 6V going into them before they can produce that 5V. So now you’ve got 6V or more from your batteries that just ends up as 3.3V on the Pi. In other words, only half the voltage you started with is doing anything useful, and the difference is lost as heat. Bottom line: it’s a waste of power and means you need much bigger batteries than you otherwise would.

So I Can Supply The Pi From 3.3V Only?

Correct. It’s entirely possible to ditch the 5V supply and run the Pi from 3.3V only, using a single regulator between the batteries and the 3.3V line. You still need some voltage on the 5V line, to keep the BCM2835 happy via its VSense line, but 3.3V is plenty for that.

OK, How?

Using an separate voltage regulator, bypassing the Pi’s own 3.3V regulator. There are two options – a linear regulator (as on the Pi, but better) or a switching regulator.

Linear Regulator

Linear regulators are cheap and simple, and produce no EMC (radio interference), but are usually less efficient than switching regulators. The reason is in the process of dropping the input voltage down to the output voltage, the difference is lost as heat. For example, suppose you are using 4 AA batteries to run your Pi. Those produce around 6V together (depends on the type of battery, and the current being used, and how much charge they have left) but this is a typical figure. With 6V from the battery and 3.3V powering the Pi, the efficiency of the regulator is 100 * 3.3/6 which is 55%. Not very good. What does happen though is that as the battery voltages goes down, this loss reduces and the efficiency goes up.

When you choose a regulator, an important thing to look for is the “dropout voltage”. When the difference between the input (battery) voltage and the output voltage drops below this figure, the regulator stops regulating. At that point the output voltage will start dropping and the Pi will soon stop running.

Many regulators are advertised as “LDO” which stands for “Low Drop Out”. Early linear regulators had a dropout voltage of 2V and anything less than this seems to be regarded by the manufacturers as “low”. I disagree. For example the 3.3V regulator on the Pi has a dropout of 1.2V, meaning that the 5V line has to stay above 4.5V (3.3 + 1.2) at all times. With so many dodgy USB power supplies on the market this requirement isn’t always meant, thus causing random crashes and other effects.

A much better LDO is the MCP1825S. This has a dropout voltage of less than 0.2V. So, using one of these to supply the 3.3V line, you only need a battery voltage of 3.5V. If you’re using 4 AAs then they will be almost completely flat by the time they drop this low. So, using a good LDO the Pi can continue to work until the batteries are very flat indeed. This is a good thing as it extends the run time.

With the above in mind, what happens if you add more batteries in series? Say you use 6 AAs instead of 4. The voltage to the LDO is higher, which makes it less efficient. All you’re doing is heating up the regulator! The run time will be virtually identical. To get more run time with more batteries in series, you need a switching regulator.

Switching Regulator

Switching regulators aren’t so simple, but these days they are very cheap. They do produce some EMC (radio interference), but in my experience not enough to cause a problem with my trackers. Your mileage may vary. Their big advantage though is efficiency – at least 70% and often higher, compared to typically 50% or so with a linear regulator.

A common switching regulator chip is the LM2596. You can buy these as modules on ebay for just over £1, and they are very simple to use. They are adjustable so you MUST adjust to 3.3V BEFORE connecting to a Pi. That done, they are simply wired to the batteries on the input side and the Pi on the output side.

The dropout voltage for these devices is quoted at about 1V, and efficiency (at full load into 5V) at 73%. So, would these be a good choice for running from 4 AA batteries? Probably not, because the efficiency then is not that much higher than a linear regulator, and the relatively high dropout voltage means that the Pi will stop before the batteries are actually flat. For more AAs, or for running from a 12V lead-acid battery, these are clearly the best option.

How Long Will My Device Run on Batteries?

You can calculate this for a linear regulator from:

Time = Battery_Capacity / Load_Current

and from a switching regulator from:

Time = (Battery_Capacity * Efficiency * Battery _Voltage) / (100 * Load_Current * Pi_Voltage)

Some examples then. My radio trackers typically use around 200mA, an AAA battery has a capacity of 1200mAh (can supply 100mA for 12 hours for example), and an AA is 3000mAh. A switching regulator is about 70% efficient. So:

4 AAAs and linear regulator = 1200/200 = 6 hours

4 AAs and linear regulator = 3000/200 = 15 hours

6 AAs and switching regulator = (3000 * 70 * 6 * 1.5) / (100 * 200 * 3.3) = 28 hours

Notice that adding just 2 AAs and changing to a switching regulator nearly doubles the run time!

For my balloon flights, weight is often an issue. A switching regulator adds weight and, more importantly, it means I have to use at least 1 more battery (because of the higher dropout voltage). Hence I often use a linear regulator even though it’s less efficient. I don’t need a very long run-time I just need it running for long enough for me to find it!

Step By Step – Linear Regulator

This is how I do it; you may wish to do it slightly differently – for example applying power via the GPIO connector. I prefer to wire direct to the Pi, starting with a 0V wire going to the 0V test point (TP2):

P1080209

Next, you need to take out that existing 3.3V regulator. All you really need to do is cut the legs so it’s out of circuit:

P1080210

However I prefer to remove it completely (it saves a bit of weight!). After cutting the legs, hold the board vertically (so the regulator can fall off easily), get a nice hot soldering iron with a large bit, apply some solder to the bit (to help with conduction) and apply to the tab at the top of the regulator:

P1080214

If you’re doing it properly the regulator should fall off after a couple of seconds. Do not hold the iron there for more than about 4 seconds – you may lift the pad off the board altogether. Once the regulator has gone, desolder the bits of leg that are left so the 3 pads are all clear. Next, cut off the capacitor to the left of the regulator – this is the large round metal component. It’s not needed and it’s in the way.

Now, solder a short piece of wire between the large pad and the small one to the right. What you are doing here is connecting the 5V and 3.3V rails together.

P1080218

Next, prepare the regulator. This is the MCP1825S 3.3V regulator I mentioned earlier. If you use a different model check the pinouts – they will probably be different!. We aren’t connecting to the tab, just the 3 pins. From left to right, they are Vin (battery +), GND (0V) and Vout (3.3V). bend the Vout pin down and make a right-angle as shown below. Cut the other pins short (cut at the shoulder), and tin all the pins (apply some solder):

P1080220

The bent pin will be soldered to the large pad. This places the new regulator above an unpopulated part of the Pi, however to be safe place some insulating tape on the board so there’s no danger of shorting anything out. Apply some solder to the large pad on the board, then hold the regulator on the board so the bent pin is on that pad. It should now take just a moment with the soldering iron bit on that pad to solder the regulator to the pad. Once it’s in place, solder the centre pin to the remaining pad vacated by the old regulator – this is the GND connection. Finally, solder a flexible wire to the remaining pin – this is the +ve line from the battery.

P1080225
I strongly suggest you fix this wire down so that no force can be applied to the regulator if the wire is moved. I like to tie a knot in the wire then run it through the mounting hole in the middle of the Pi.

And that’s it!

Step By Step – Switching Regulator

  • Remove the regulator as above
  • Solder the 3.3V and 5V lines together as above
  • Connect the “OUT-” pad on the regulator to the TP2 (GND, 0V) hole on the Pi
  • Connect the “OUT+” pad on the regulator to the TP1 (5V and now 3.3V) hole on the Pi
  • Connect the “IN-” pad on the regulator to the “-” terminal on the battery
  • Connect the “IN+” pad on the regulator to the “+” terminal on the battery

What If I Do Need 5V?

Well, first, check that you do. My USB WiFi dongles don’t – they run just fine on 3.3V.

If you do need 5V, you have 2 options:

  • Leave the 3.3V regulator in place, and supply 5V to the Pi as usual (preferably using a highish battery voltage – 12V say – and a switching regulator
  • Use TWO switching regulators, one for 3.3V and one for 5V. You do then need to remove the Pi 3.3V regulator as above

65 Responses to Running The Raspberry Pi On Batteries

  1. Pingback: Run the #RaspberryPi on 3.3V of power | Raspberry PiPod

  2. Pingback: Get your Raspberry Pi to use less juice! - Hackalizer

  3. Paul Beech says:

    Great work and superb reliable information Dave :-)
    Could you name names on the WiFi/WLAN dongles?

    • dave says:

      I thought I had 2 different ones (they were bought from different places) but they both say “COMFAST”. One was bought from CPC. Apparently it’s quite common for the chip inside to be designed for 3.3V use, but my only experience is with this one.

      • Anthony says:

        Dave, can you provide a lsusb description of your wifi dongle – Im having great trouble getting one to work at 3.3v…

  4. John Beale says:

    Based on my examination of a Ralink RT5370 based device (found in cheap <$10 USB-WiFi dongles, available with or without external antenna) it uses two voltages internally: 3.4V and 1.5 V. So it could likely be made to run on 3.3 V. See photo here: https://picasaweb.google.com/109928236040342205185/Electronics#5764833029813612466

  5. Pingback: Links: Alternative ways to power a Raspberry Pi » TechNotes

  6. Jeffry says:

    Why destroy a good working regulator?

    Maybe next time use this, so you could restore the board if needed:
    http://www.amwittools.nl/gereedschap/product_images/n/972/99040046_tinzuiger_800x600___46898_zoom.jpg

  7. mimin says:

    Hi,
    Thanks for this excellent article. May I ask a question about WiFi dongle?
    If your RPi will fly with baloon, why do yo need WiFi dongle? How do you send the tracking information?
    Thanks.

    • David Akerman says:

      That’s just for developing the software! It flies without WiFi (not legal here). Instead it uses a low power radio link that is allowed.

  8. Stu Summerfield says:

    thankyou,

    very very useful info that I have been trying to get my head around for a while now. Although not limited by weight I am to a certain extent by size and needed to find a way to drag out 48hrs worth of battery life for stand alone rfid tag reader systems. Brilliant, you’ve made my day now all I have to do is convince my Prof to let me spend some more of his money ;)

  9. burningchairs says:

    Hi Dave,
    Is there any reason you didn’t use the SMC version of your LDO regulator? It seems to have the same pinout, and therefore less PCB mods

    • David Akerman says:

      Remember that I don’t actually want a direct replacement – I’m changing the Pi so that both 5V and 3.3V rails are tied together. That means that Vin on the regulator has to be isolated from the 5V rail. So the wiring I need is different enough from the original that a direct replacement doesn’t make it any easier.

      The suface-mount versions of the MCP1825S actually have the same pinouts as the TO-220 version I used. It would have been slightly easier if they’d match the original regulator.

  10. Tom Bullers says:

    Dave,
    Really helpful article – and nicely laid out. Thanks for sharing.

    I’m putting together a robot with a Pi on board and was considering powering it with rechargeable NiMH AA cells. (probably Sanyo Eneloops because of the good reviews). NiMH batteries put out 1.2 V so could I drive the Pi directly with 3 batteries at 1.2 = 3.6 Volts and avoid replacing the regulator?

    Could I also put 3 more Eneloops in parallel to give me a longer run time? Thanks very much for your help.

    -tom

    • dave says:

      Might work but I wouldn’t risk it. You’d need to find out the max voltages for all components on the 3.3V line.

      I’d use 4 in series plus that regulator.

      Yes you can parallel them up (just make sure they’re all charged, or all discharged, before you first connect them together).

      Dave

  11. Shaun says:

    How long do you think I could run a Rpi off 4 AA batteries with a screen that draws 400mAh using this method?

  12. Olivier says:

    Many thanks for this article. I’m currently thinking about a way to maximize the running time on batteries for some embedded project but I’m surprise how long you can run your Pi with only 6AAs batteries :/ With two USB devices (a webcam and a 3G dongle) I can only run the model B about 10 hours with a 9000mAh 5V Li-ion battery.

    Here is a french reference running the Raspberry Pi on batteries : Comment alimenter votre Raspberry Pi avec une batterie

  13. Pingback: Running The Raspberry Pi On Batteries | Dave Ak...

  14. Dave says:

    Excellent Article, thanks

    You mention that you track your Pi with a low power radio link, can you provide some information on what hardware/software is needed to achieve this?

    Do you (or Can you) also use the link to control the Pi remotely?

    Thanks

    Dave

  15. bob says:

    Why can’t I use the battery pack I use for charging my phone while on the go. If it charges my phone surely it will power my pi and still leave me with my warranty

  16. bob says:

    I just noticed. Is that blood on the fc sign above the word power?

  17. Stuart says:

    Super article!

    Many thanks!

  18. Stuart says:

    Can you still supply power via the standard micro-USB input after following your howto?
    (I’m guessing yes … after a little extra soldering!)

    • konaya says:

      If you supply it with 3.3V through the µUSB-port, then yes. If you connect it to a standard USB-port, thus putting 5V on the 3.3V line, then no. I’m not sure if electronics still smoke when dying from being overvolted nowadays, but be sure to let us know! ;)

  19. Andy Crofts says:

    Another power-saving method?
    Well, being on’t Dole, I can really only afford one or two Pi’s. As shipping costs to Finland increase that to nearly double the UK Pi cost, I opt for the B-model.
    development at home is OK, using a meaty powered hub, but when my madcap schemes need testing in the field, I want to run off batteries.
    Is there any way of turning off the ethernet chip (the one that’s ‘missing’ on the ‘A’ version)? Not as efficient as your method…but every milliwatt counts. Does give obvious advantages (Pi back to normal easily, and ½ Gig of Ram…

  20. Ricardo Antunes says:

    I haver just got a couple of new model As and found that the voltage regulator is glued to the board! This won’t make it as easy to remove the regulator that cames on the Pi and will have to leave it in place.

    • Dave Akerman says:

      They’re soldered on, and can be unsoldered with a hot soldering iron and a large bit.

      Or just cut the legs off, though then it’s a bit more difficult to connect the new one.

      • Ricardo Antunes says:

        I have tried the soldering iron several times and for longer than the 4 seconds you recommend and it didn’t release the regulator! I will try again with a better iron but I really think it is glued in place. Maybe it is a new “feature” of new versions!

  21. Sebastian says:

    hi great article… i learnt a lot in very shot time.
    I had a littel theory about improving the efficence. If i take 3 AA batterys (4.5V) in serie and and connect them 3 times parallel (9 Battery) would the running time of the pi be longer?

    • David Akerman says:

      3 in series will work but will stop before the batteries are completely flat, and yes putting 3 sets in parallel will give you 3 times the run time. However a better option would be to put 9 in series and use a switching regulator (£1 from ebay), as that will keep going till the batteries are completely flat.

  22. Patrick says:

    Thanks for this article.
    Just a question : can i power , with the same power supply (5V) , both the Rpi board (via micro-usb) and other modules (like http://www.abelectronics.co.uk/products/3/Raspberry-Pi/27/1-Wire-Pi) for example.
    I would separate 5V and ground and connect rpi and modules in parallel
    Thank you.

  23. Excellent Article

    I just need to think about that, and may be integrate the option on the next batch of Arduipi Board (http://hallard.me/arduipi-the-shield-that-brings-arduino-to-raspberry-pi/) so we can remove regulator on Pi Board and power the Pi in 3V3 from ArduiPi external power or by Lipo with lipo charger on ArduiPi board. Sounds good to me this idea.

    Internet is really a large source of inspiration and ideas, thank you for your article, I will try to power my Pi with Lipo after changing the regulator.

  24. Taha Amin says:

    kindly check this Running a Raspberry Pi from 6 AA Batteries without losing warranty
    http://www.raspberrypi-spy.co.uk/2013/02/running-a-raspberry-pi-from-6-aa-batteries/

    • David Akerman says:

      Yes, 6 works of course, and yes no warranty issues. However for some applications 4 is better – less cost less weight less space needed.

  25. angelo says:

    Does the model b LAN functionality continue to work after this mod?

    • David Akerman says:

      I’ve no idea, and to be honest it wouldn’t really make sense to do that. The idea is to squeeze a bit more life from the batteries, but with a model B you’re throwing away 70% of their capacity before you start. If you need a network connection add a Wifi dongle, and if you need more USB add a small USB hub. You’ll still be way below model B consumption even with both added.

  26. Laudenclear says:

    Hi,
    First – Thank you so much for sharing this interesting stuff. Regarding your remark in Switching Regulator instructions: “Solder the 3.3V and 5V lines together as above”.

    Would it be possible to just solder the GPIO terminals of +5V and +3V3 in order to achieve this?

    Thanks!

  27. Erik says:

    Would you be able to provide information about the low power radio link. I am just starting a project that will involve streaming form RPi but have little experience.

  28. Pranav says:

    “Once it’s in place, solder the centre pin to the remaining pad vacated by the old regulator – this is the GND connection.”
    Although that’s correct, on the actual picture you have soldered it to the GND pad vacated by the capacitor. That’s an easier way to do it. You probably meant to type capacitor anyway. :)
    Cool hack though! Loved it!

  29. Samir Sogay says:

    Hi Dave,
    Thanks for a nice article. Could you tell me if there is a possibility of using spare smartphone batteries which have some 2000 MAh capacity and give around 3.3 to 3.7V and how? Also, I am compiling the run time of RPis powered by batteries under various situations. Since you have undertaken many projects, could you provide your data so that I can list it to be helpful for everyone?
    babaawesam.com/2013/11/23/raspberry-pi-on-battery-uptime-compilation/
    Thanks

  30. LogicalOctopus says:

    If you were really concerned about the weight then why wouldn’t you remove all of the jacks and interfaces that aren’t required? The audio jack, the composite jack, the ethernet port, the gpio pins… I don’t think the regulator is very much by comparison.

  31. jarrah says:

    You mentioned that 3.3v power can be supplied via the GPIO pins rather than being directly soldered. Would you mind explaining what needs to be done differently to the instructions you gave please? My intended project would be easier for the power to be removable.
    Thanks.

    • David Akerman says:

      Just connect 3.3V to the 3.3V and 5V pins on the header, and 0V to 0V on the header. That’s it.

      • jarrah says:

        Hi Dave, thank you for a very quick reply to my question.

        Just to double check I understand you correctly, I would connect the battery’s red positive cable to pin 1 and pin 2, and the negative black cable to Ground on pin 6 on the GPIO header?

        Would the linear regulator still have it’s Vout soldered to the large pad and 0V to the old capacitor, along with that short piece of wire between the large pad and the small one to the right?

        What would I do with the Vin pin on the regulator now that it won’t be soldered directly to the battery cable?

        Thanks in advance again.

        • dave says:

          You just connect 3.3V from the regulator to the 3.3V and 5V pins on the header, and 0V from the regulator to 0V on the header. Battery voltage goes to Vin and 0V on the regulator. If the battery-regulator lead is more than a few cm you’ll need a 100nF capacitor there too. No need to do anything to the existing regulator or associated circuitry.

          This is probably something not to mess with if you on’t understand exactly what you’re doing – very easy to fry the Pi.

  32. Samuel says:

    Hi,
    great overview. But why not use a buck boost converter? It’s a little more expensive but it allows varying input voltages and batteries can be leached totally empty. This means there is also no dropout voltage.

    Here an example: http://www.pololu.com/product/2119
    The efficiancy is also higher > 90 %

  33. Hi,

    Thanks, very helpful tips: I need to leave the LAN running for my rather more terrestrial off-grid server application, but can at least save about another 10mA by turning off the status LEDs as here: http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=72070

    Rgds

    Damon

  34. alex says:

    Thanks for this. And sorry for a lame question: If I am using an external regulated 3.3 PSU, would I still need the regulator?

  35. John Doe says:

    What if I need to power an LCD screen with that PSU as well?

  36. Jay Busch says:

    I don’t mean to be a pest, but I have a question about battery life calculation. When you measure battery run time in your post, you have a AA assumed to be about 3000mAh, and when you have 4 of them, you leave the battery capacity at 3000mAh, not multiplying it by 4 for the additional batteries. Even if you cut capacity in half with the linear regulator, you get 1500mAh per battery, right? Shouldn’t that be 6000mAh for 4? Or have I goofed and missed something?

    • dave says:

      They’re in series, so the current caacity is the same. What changes of course is the voltage. So for 1 cell you have 1.5v (roughly) and 3000mAh; for 4 cells you have 6V and 3000mAh.

      For a linear regulator the voltage doesn’t matter so long as it’s above the output voltage + the dropout voltage (0.2V for this regulator). So the run-time calculation is straightforward – current capacity (3000mAh) divided by the current consumption.

      For switching regulators it gets a lot more complicated, as the current drawn varies with voltage. Lithium cells are nominally 1.5V but vary a lot between 1.8V when new and about 1.1V when nearly exhausted. The voltage also drops with current and when cold.

      • Jay Busch says:

        Oh! That makes much more sense, thanks! I knew I missed something. Thanks for the quick reply!

  37. Jay Busch says:

    Alright, I’ve got a silly question about LiPo batteries for the Pi: Can you use the connector to charge the batteries from the Pi’s micro USB port and also run the Pi? i.e. Having a 2A micro usb cable plugged into the wall, powering the Pi, would it also charge the LiPo?

    I know the dangers and hazards of charging a LiPo battery unattended, but that’s what I would hope some other protection circuits can help with down the line.

    Sorry if this a stupid question, but thanks for any guidance!

  38. Joseph says:

    I am curious. I have a garden that has no power. I was looking at the possibility of making a motion detector hack from an old digital cam when I came across the Raspberry Pi. My thoughts are using the noir camera and the ability to make some sort of a PIR motion detector and perhaps an option for stills vs video captures. All of this would have to be on battery power and curious if you know of anyone that has done something similar or not? {Perhaps even the option that the batteries are solar charged so that it might stay in place long term? Another hunting trail cam had a wireless memory in a separate box so that if the camera was stolen you would still have a history on a separate SD card.. Any ideas anyone has is very much appreciated… Sincere thanks for this page… Joseph

    • Joseph says:

      I would also like to make a connection with an IR array with this already extensive request.. Is the Pi ‘A’ still the best choice?

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>