Make a solar-powered Raspberry Pi for outdoor use

Wouldn’t it be nice to have a completely portable Raspberry Pi that you can take with you and operate completely off the grid on renewable energy? Provided that you get enough sun in your area, a solar-powered Raspberry Pi is in fact easy to make and use.

This guide is based on the handy PiJuice HAT, which is now in stock again and adds an uninterruptible power supply (UPS). You can chose any other UPS to get this working, as long as it is compatible with your Raspberry Pi. You will also need a solar panel, which you can connect to your Raspberry Pi.

Content

What you need

  • Raspberry Pi, I’m using model 4B for this tutorial, lower versions will need less current
  • SD card with Raspberry Pi OS (Buster or Bullseye), all setup and working
  • Pijuice HAT, available here, comes with a standard 1820mAh Lipo/ LiIon battery
  • Pijuice Solar panel, 6W or 12W depending on which board you use – more details below

Assemble the Pijuice HAT

The PiJuice HAT comes with spacers and the plastic encasing for the battery already assembled. All you have to do is attach it to your Raspberry Pi board.

Before you do so, check that the DIP switch on the bottom of the HAT looks like in the image below. The one I’m using here is for the standard Lipo/ LiIon battery that comes with PiJuice (BP7X). If you are using other battery models you can check here (scroll down to Battery profile) what the configuration should be.

Then put the PiJuice on top of the Raspberry Pi and push the female header onto the Raspberry Pi male header. 

Attach and fasten the plastic bolts that came with the HAT to secure it to the Raspberry Pi.

Remove the plastic pull tab that prevents the battery from making contact to its connector. And you are done.

Note that for Pi Zero, Pi Zero W, Pi B+, Pi 2B and Pi 3 you will also have to install a Pogo pin to activate the wakeup functions and use the SW1 button. More details on how to install it can be found here.

Installing PiJuice software on Bullseye

Now that the Debian-based Raspberry Pi OS has been upgraded from Buster to Bullseye, the installation of PiJuice software is unfortunately a bit more complicated than it was before. The debian packages have not yet been added to the Bullseye repository yet. Therefore the command line code used on their official github page does not work. However, if you are still on Buster or a previous OS version, just use the command line code.

Thankfully we can still install the packages from source directly. At the moment it seems that installing the packages via wget corrupts them. So the easy way is to just download them from the github repository.

Download the packages pijuice-base_1.7_all.deb and pijuice-gui_1.7_all.deb manually from the github website.

Change into the directory that you downloaded them into and type the following into your command line. Make sure to install the base package before you install the gui as the latter depends on the former.

sudo apt-get install ./pijuice-base_1.7_all.deb 
sudo apt-get install ./pijuice-gui_1.7_all.deb 

You now have to change two lines of code in the PiJuice software so it runs without errors as per this github post. These issues might already be fixed in later github versions, but I’m adding them here too.

In your copy of /usr/bin/pijuice_cli.py change line 116 from

if default is not None and default is not "":

to

if default is not None and default != "":

This is because Bullseye uses a later version of python3 than Buster.

Second, In /usr/lib/python3/dist-packages/pijuice.py in function _DoTransfer (lines 70-85) change the three occurrences of isAlive() to is_alive().

That should fix it for you and you can now run PiJuice software on your Raspberry Pi with Bullseye. For a complete guide on all the configuration options, please have a look at their website.

Which solar panel should I use?

Which solar panel you should buy mostly depends on the type of Raspberry Pi you want to power and the task you have in mind. If you want to get a feeling for how long the Raspberry Pi will run specific tasks on any given battery you can use the PiJuice Battery Discharge Time Calculator.

Solar panel current calculations

You can also calculate the amount of current a solar panel will produce using Ohm’s Law. I’ll skip the math here but you can easily find calculators on the internet that will allow you to calculate the current (I, in Ampere) if you enter the Voltage (V) and Power (P, in Watt).

Now check your solar panel’s specifications to get an estimate of how much current it will produce provided the sun is strong enough.

For instance, a 12 Watt Solar panel has a regulated max output of 5 volts / 10 watts (as per its specifications). If you plug these values into the Ohm’s Law Calculator you will get a current of 2A.

Raspberry Pi power calculations

Next we’ll check the Raspberry Pi 4B power supply specifications – here it says the the recommended current capacity is 3.0A. However, if you check the tables that list the typical amount of power the Pi 4B uses during any given task, it usually does not exceed 1.25A. So in sum you might aim to provide around 2.0 – 2.5A current for the Raspberry Pi 4B to be on the safe side and ensure it is being charged while running. You can provide less for older models or the Pi Zero.

A 12 W solar panel should be sufficient to keep your Raspberry Pi 4B running under normal load. However, for power-hungry projects you might consider buying one with a higher capacity. Equally, if you only want to charge your Raspberry Pi using the solar panel every now and then and don’t need it powered for hours at a time, a 6W solar panel (provides 1.0A current) might be enough for you.

Raspberry Pi 4B with PiJuice HAT and the 7 inch touchscreen

Testing Raspberry Pi 4B with a 6 Watt solar panel

I tested my Pi 4B with the official 7 inch touch screen attached on a 6W panel in direct sunlight. The panel was charging the HAT directly and not via the Raspberry Pi board for an optimal outcome. As per the calculations above the 6W panel provides around 1.0A current. Therefore it will not be enough to run and charge your Raspberry Pi 4B, but it should extend battery life.

With a few applications open and otherwise normal load, the device kept charging (blue LED on). But it could not quite match the power drain and overall the battery kept discharging. In idle, the loss was reduced but the Pi still lost power overall.

So realistically, with a 6W panel you might be able to extend the 2 hour standard battery life for an hour or so, depending on the task you are running. And of course you can use it to recharge your Pi’s battery while the Pi is switched off.

If it is important that the Pi stays on at all times, you might need to invest in a larger panel and/or additional batteries to ensure you have enough charge to last during the night and rainy days.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.