Introduction: Make Your Pi Project Rechargeable...

The following aims to show how to make any Raspberry Pi project battery powered and rechargeable***. This isn't quite as easy as it should be because the Raspberry Pi requires just over 5VDC to operate properly. (It really wants 5.2 to 5.25 volts.) So we need to take the battery voltage of 3.7V and boost it to 5.2V. (Alternatively one could use a 7.2V battery and buck it down to 5.2V.) We also need a circuit to charge the battery. Luckily there are a couple of products that include both in one module. The one we're using here is the powerboost 1000C from Adafruit. It has an output of 5.2VDC which is perfect for the Raspberry Pi and has a 1 amp charging circuit (via micro USB) to recharge our battery without having to unplug it.

What you need-

***Another way is to connect a USB power pack to the Raspberry Pi. However, I have found this approach less than satisfactory for the Raspberry Pi... Most of the USB battery packs I see put out between 4.85 and 5 VDC. As mentioned above, the Pi requires slightly over 5 VDC. So what usually happens is that the Pi boots, but the little 'rainbow square' appears in the upper right corner of the display (see photo). This square indicates that the Pi is under-powered. Running the Raspberry Pi like this can cause anything from system instability to hardware damage. Notably damage to the SoC can occur from repeated under-powering. If you are going to use an 'off the shelf' USB battery for your pi try to find one that puts out 5.2-5.25VDC.

Step 1: Configure the Power Connection to the Pi

There are 2 possible ways to do connect the Powerboost to the Raspberry Pi -

  1. You can solder the USB A socket to the powerboost. (The module comes with the USB socket. But it's not soldered on.) If you choose this option then you can simply use any micro-USB cable to run your Pi.
  2. Solder the output of the Powerboost to the power +/- of a micro-USB plug. (see photo above). If you choose this option the the powerboost will plug directly into the Raspberry Pi micro-USB port. You can use an old Micro-USB cable and splice it to the Powerboost as shown. Power wires for the cables are usually red/black for +/-

Note - While it is possible to power the Raspberry Pi via the GPIO connector I do not recommend it as it bypasses the power protection circuitry of the Raspberry Pi. (i.e. the 5V pin of the GPIO connects directly to the SOC. See this thread on Stack Exchange.)

Once you've got this set up, unplug it. Once the battery is plugged in we will want to test the output voltage before plugging in the Pi for the first time.

Step 2: Connect the Control Pins (Optional)

You can optionally connect one or more of the control pins for the PowerBoost. The two pins you can use are -

  • EN - this pin is pulled high internally by default. You can connect a SPST switch to this pin and ground to create a 'power off' switch.
  • LBO - This pin is pulled high by default. But if the Powerboost senses low battery voltage, it goes to zero. Connect it to the digital GPIO pin of your choice via a 1K resistor to warn your Raspberry Pi when the battery is running low! Once you've got that connected you can download the 'off_button.py' script form this nice instructable and follow the instructions there to install the software, specifying the GPIO pin connected to LBO where the script says YOUR_CHOSEN_GPIO_NUMBER_HERE

Step 3: Connect and Charge the Battery

Now you can connect the battery to the Powerboost via the JST plug on the Powerboost. At this point the circuit is mostly complete. But if your battery is new I recommend charging it fully before proceeding to the next step. You can do this by plugging a USB charger into the micro-USB plug on the powerboost. If you have connected everything correctly, the yellow LED on the Powerboost will light to indicate charging. The light will turn green when the battery is fully charged.

AFA battery capacity, my personal experience is that the Powerboost + Pi + Wifi + keyboard ( + whatever else I plug in) uses around 1200-1500mA per hour during fairly heavy real-world usage. So a 5000mAH 3.7V flat pack battery is good for about a half-day of heavy usage or up to a full day of light usage if power saving is configured on the pi.

Step 4: Testing

Now we're ready to do some final testing before we plug in the Raspberry Pi. If all has gone well you should have a charged battery connected to the Powerboost. If you have installed a power switch turn it on and use a multimeter to test the powerboost voltage out (at the red/black wire on the right hand side in the photo above). It should read somewhere near 5.2VDC. If it doesn't have any or enough voltage out then check the following -

  • double-check all connections and look for loose connections, solder bridges or short circuits.
  • battery voltage should be at least 3.7VDC
  • Low voltage will be indicated by a rainbow square in the upper right corner of the HDMI display for the raspberry pi (see picture).
  • the Powerboost voltage out should be 5.2VDC (If the voltage is less than 5VDC then you may be drawing too much power. )
  • the EN pin must be HIGH for normal operation.If it shorts to ground the power supply will turn off.
  • If the LBO pin is low then the battery is low and must be charged. If you have connected the LBO pin to the Pi and set up the off_button.py script then the pi should power off automatically when the low-battery alert triggers.

There are 4 LEDs on thePowerboost which indicate different states and can help troubleshoot any issues.

  • When the Boost 5VDC supply is on the blue LED will light up
  • When charging the yellow LED will light up
  • When charged the green LED will light up
  • When the Battery is low the red LED will light up

Step 5: Fire It Up!

Now if all is well, you should be able to connect the Raspberry Pi (and flip the power switch if you included one in your project.) The pi should boot normally. If so, Congratulations! You now have a battery powered Raspberry Pi. To recharge simply take the USB power supply you used to power your pi with and plug it into the micro-USB port of the Powerboost instead.

If the Pi fails to boot or if the 'low voltage' warning* appears in the top right corner of the hdmi display then stop, go back and test the voltage with the pi connected, paying attention to the troubleshooting tips in the previous step.

Comments

author
Antonio MarioC (author)2017-07-26

Hi,

Interesting post, thanks. I would also know if in some way it is possibile to read the "capacity" of the external battery. I do not have practically any experience with electronics, the low signal can be monitored to support a 'clean power off', but I would like to do something like a real time monitor of the battery levels. If I use the 5000mAH 3.7V that you cited, what I have to add as hardware and software to monitor the remaining capacity in real-time?

I'd like for example to add a solar panel and monitor the level of the battery as it gets charged or discharged in real-time as a function of the panel production and the load absorbed by PI.

author
ZeynepÖ6 (author)2016-12-04

Hi!

I was wondering can I use the Powerboost 500C which doesn't supply maximum 1A output current. Is max 1A output current necessarry for this circuit design?

Thx by the way, this is a great project.

author
boffinry (author)ZeynepÖ62016-12-04

Depends on which pi you are using and what is plugged into it. The 500C is probably enough for the pi zero, but I recommend the larger power supply if you are using the pi 2b or 3. (the 2b CAN be made to work at <500 mA if there are no peripherals and HDMI is disabled though...)

To get an idea of the power usage specs for the different Raspberry Pi versions, check out this page - http://www.pidramble.com/wiki/benchmarks/power-consumption

author
KrazyK4 (author)2016-02-19

Is there any way it was easier to connect the battery to the Pi without the connectors in between?

author
boffinry (author)KrazyK42016-02-19

Yes. As mentioned in the intro, you can try to find a decent USB battery pack (the type used to recharge phones and such...) that puts out slightly over 5VDC. Warning - most portable USB batteries do NOT put out enough voltage. (In which case one will see the 'rainbow square' in the upper right corner of the display.)

AFA hooking a battery straight to the pi, that's not advisable. The voltage supplied to the pi should be regulated at 5 to 5.2 VDC. But batteries decrease in voltage as they discharge. So suppose for example you combine 4 AA NiMH batteries in series. Though rated 1.2V, they vary between 1.0 and 1.5V depending on charge. When fully discharged they are at 4.4V which is too low for the pi. But when they are charged up they could hit 6V which is too high. The power boost module regulates the voltage supplied to the pi and also acts as a charge-controller of the battery allowing the battery to recharge via microUSB.

author
KrazyK4 (author)boffinry2016-02-20

Thanks you!!

author
Malkaris (author)2016-02-16

That's a neat board. Does this behave like a UPS or just a rechargeable battery?

Specifically, with this setup it will run indefinitely while under power, but if the powersupply fails/shuts off the rpi is uninterupted and remains on battery power?

author
boffinry (author)Malkaris2016-02-16

Malkaris - That is correct. This set-up functions like a UPS and as long as the Powerboost is supplied with 5.2V via it's micro-USB the pi will stay powered. If it loses power then it'll switch to the battery. Once the battery has drained the LBO pin will go LOW at which point an interrupt can trigger shutdown. (optionally one could add an email alert to the shutdown script as well ;-)

author
Malkaris (author)boffinry2016-02-17

thanks, I had about given up when my C.H.I.P came and it has the charge control built in. but I still have two RPI that need love

author
wold630 (author)2016-02-15

Great project! Thanks for sharing.

author
boffinry (author)wold6302016-02-16

Thanks! Glad you liked it.