SustainableWWW Logo
Blog post image

How to build a solar-powered Raspberry Pi with PiJuice

Raspberry Pi's are powerful little machines that you can use for lots of interesting stuff at home, but the fact is that they use electricity like any other electronic device. Luckily there is a way you can either minimize the amount of electricity your Raspberry Pi is running on or completely eliminate it, and that is what we are going to look at in this article.

In this article, we will go through how you can make your Raspberry Pi run entirely on solar using the PiJuice power management board.

1# Get yourself a PiJuice power management board

The first step to getting your Raspberry Pi running on solar power is to get yourself a PiJuice Power Management Board. If you click the link you will be redirected to Pi Supply's website where they have a whole kit containing a PiJuice Power management board and a solar panel. You can choose the size of your solar panel depending on your need. It comes as a 6 watts, 12 watts, 22 watts, and a 40 watts package.

The PiJuice HAT itself is the board we will be attaching to our Raspberry Pi's 40-pin GPIO header. Its job is to make sure our battery is charged and once the battery is full, it will power the Raspberry Pi instead of using the battery. This way we can run the Raspberry Pi directly from the sun as long as there is enough sunshine, and once the sun is out we will be using our battery.

2# Choose a solar panel to power your Raspberry Pi

The next step is to carefully choose the solar panel we want to be powering and charging our Raspberry Pi with. Choosing the right size depends entirely on your project, and if you haven't already chosen a solar panel size, we will discuss the different sizes here in this section.

By typing in the solar panel's output watts and voltage we can use Ohm's law to figure out how much current the solar panel will provide. In the following example, we will be using the 22 watts solar panel.

From the technical specifications, it says that this solar panel's regulated output is 5 volts and 20 watts. So in this Ohm's calculator, we type in the 5 volts and the 20 watts. This gives us a current (i) of 4A or 4.000mAh.

How big a solar panel does my Raspberry Pi need?

The size of the solar panel you need to power your Raspberry Pi depends on the model you are using for your project. 

Raspberry Pi Zero W has a minimum requirement of 6W and 5V and the recommendation is 12W and 5V. 

Raspberry Pi 3 and 3B has a minimum requirement of 12W and 5V and the recommendation is 22W and 5V.

So if you are planning on using a Raspberry Pi 3 or 3B for your project, we recommend using a 22W solar panel to power it. You can get away with less, but if you underpower your device too much you will see weird errors.

3# Pick the right battery for your project

Now that we have found the power management board and the solar panel for your project we need to figure out which battery would fit your needs. You see, depending on the requirements of your projects we need to find a matching battery in size, so that your Raspberry Pi won't turn off after only an hour or two. The intention is to make your Raspberry Pi run 24 hours/day only using the battery and a solar panel.

Lithium-Ion (Li-Ion)

Lithium-Ion batteries are generally bigger than for example lithium-polymer, but it also often cheaper and lighter. If you are building Raspberry Pi projects where the size and weight of the battery are important, then maybe Lithium-Ion isn't the type of battery you should go with.

Lithium-Polymer (Li-Po)

Lithium-Polymer batteries are usually more expensive than Lithium-Ion batteries, but they are smaller and can store more energy. If you choose a Li-Po battery, it is important that your charge controller is great at handling undercharge and overcharge, or else you risk explosions.

For a PiJuice project like this, we can use both Li-Ion and Li-Po batteries, but I will recommend using the Li-Ion type. The battery size can be anywhere between 3.7V-10V, which is ideal for solar-powered projects like this. Here is the 5.000mAh battery and the 12.000mAh battery.

4# Connect your Raspberry Pi to the PiJuice HAT

In this step, we will be attaching the PiJuice HAT to your Raspberry Pi's GPIO pins. You need to be careful when doing this so that you don't break or bend the pins. 

Start by first aligning the PiJuice HAT on top of your Raspberry Pi, and then carefully press the board onto your Pi's GPIO header. After the PiJuice board has been attached correctly you can use the included screws and plastic standoffs to secure/attach it to your Pi.

5# Connect the battery to the PiJuice HAT

Most PiJuice boards come with a small battery pre-installed. This is actually great because it makes swapping out batteries or replacing them easier and your Raspberry Pi can even be turned on while doing it.

If you did buy a bigger battery such as a 5.000mAh or 12.000mAh version, then you can add the capacity to your total by simply soldering on another battery terminal and connecting the new battery.

6# Connect the power source to your Raspberry Pi and power it on

Before attaching power to your Raspberry Pi. If you have a PiJuice case or similar case that fits the PiJuice power management board, then now is the time to assemble the casing. 

If you don't have a casing to your Raspberry Pi, then you can simply attach the power supply to your PiJuice board and power it on (Make sure to attach it to the PiJuice board and not the Raspberry Pi). 

To power on your Raspberry Pi, you click the small button labeled SW1 right next to the flashing LEDs. To safely turn off your Raspberry Pi you press and hold the same button for 10 seconds and then release it.

7# Install the PiJuice GUI software (optional)

As an extra step, you can install the PiJuice GUI software on your Raspberry Pi. It allows you to easily configure what should happen to your Raspberry Pi if the power is low or during other system events. You can also schedule your Raspberry Pi to do certain things such as wake up and go to sleep if the power reaches a certain level.

Before installing the software on your Raspberry Pi we recommend reading the readme file from PiSupply's GitHub page

To install the PiJuice software you simply open up a console and type the following into it:

sudo apt-get update && sudo apt-get upgrade

These two commands will make sure to update and install the updates on your Raspberry Pi before proceeding to the actual installation. Next, you copy/paste the code below to actually install the GUI version of the PiJuice software:

sudo apt-get install pijuice-gui

As an alternative to the PiJuice GUI you can also install the CLI version/headless which you can use in the console:

sudo apt-get install pijuice-base

If you prefer watching a tutorial video on how to install the PiJuice GUI, please take a look at the bottom of this article.

Wrapping up

You have now reached the end of this tutorial, and you should by now have a Raspberry Pi running 100% on solar energy and at night run out of the attached battery. 

We hope that you enjoyed this tutorial, and if you are interested in watching some videos about PiJuice, how to install PiJuice, and the GUI software then please take a look at the list below.

Last but not least we would like to thank you for reading this tutorial on how to make your Raspberry Pi run on solar power. We would also like to invite you to share this article with your friends and colleagues and to share your experience below in our comment section.