Tutorial: Solar Power – Sizing your Solar Panels for the Raspberry Pi

Tutorial: Solar Power – Sizing your Solar Panels for the Raspberry Pi

Sizing Your Solar Power System

One of the first things that comes up in a solar powered design is how to design the power system. The three main questions to be asked and answered are:

  1. How much power do I need?
  2. How many solar panels do I need?
  3. What size battery do I need?

The first thing you need to do when designing a solar powered system is to determine the power requirements for your solar powered design. Our criteria is that we want the SkyWeather2 Raspberry Pi to run all day and during the night. But we want the system to able to shutdown and restart itself when power is available.

The table below contains estimated power consumption for models of the Raspberry Pi, including a Wireless USB dongle. We are assuming in each of these that you turn the HDMI port off which saves ~20ma.

All of the above measurements include about 60ma for the USB WiFi Dongle! Parenthetical numbers are without the 60ma.

Based on the above, first we will lay out our assumptions for our Raspberry Pi ZeroW based design. The LiPo batteries chosen will store 6600mAh. Why choose the Zero W? It’s the lowest current consuming raspberry Pi that doesn’t require soldering.   In this next table, the numbers in parentheses are without the WiFi running.

Note that the Raspberry Pi 4B will take between 2.5W and 4W when running SkyWeather2.

And another chart from RasPi.tv showing current when doing various tasks:

 

Note that the numbers aren’t very consistent.  Another reason to measure your own currents.

Raspberry Pi 4B Solar Design and SolarMAX2

While the process is the same for the Raspberry Pi4B, it requires a much bigger solar power system and much more startup current.

Most DIY solar systems for the Raspberry Pi just won’t make it long term for the Raspberry Pi 4B, and in many cases won’t reliably startup and shutdown the Pi during the inevitable brownouts.

For this reason we suggest using a SolarMAX2 system,  a second generation Lead Acid battery (cheaper than LiPo by far) solar power controller system coming to Kickstarter in early September 2021.   It’s cheaper, more integrated and more reliable than the previous SDL generation, SolarMAX Lead Acid.

More on SolarMAX2 in an upcoming post.

 

Raspberry Pi Zero Solar Design

Assumptions:

  • -Four SwitchDoc Labs 2W 6V/330ma Solar Cells (total of 8W) (SolarMAX2 will give you a much larger range of panels)
  • -8 Hours of Sun running the cells at least at 70% of max Delivery of current to Raspberry Pi at 85% efficiency (you lose power in the charging and boosting circuitry)
  • -Raspberry Pi Model Zero takes 160mA on average (with the Wireless USB Dongle) – Removed OLED display.
  • -Raspberry Pi Model Zero running 24 hours per day
  • -6600mAh LiPo Batteries

Given these we can calculate total Raspberry Pi Model Zero runtime during a typical day: PiRunTime = (8 Hours * 70% * 1320mA) *85% / (160mA) = 39.7 hours.  Since we are above the 24 hours with four panels, we are good to go.

NOTE:   Picking 24 or even 48 hours does not mean your system will not shut off. Eventually, you will have a cloudy enough period that your SkyWeather system will shutdown.  You need to plan for this.

Our goal was for 24 hours, so it looks like our system will pretty much work. 16 Hours of running the Raspberry Pi Zero on batteries alone will take (160mA/85%)*16 Hours = 3011mAh which is comfortably less than our 6600mAh batteries can store. No effort was made to minimize the power consumed by the WiFi system. Your results will depend on what other loads you are driving, such as other USB devices, GPIO loads, I2C devices, etc.

Note that during the day, on average, we are putting into the battery about 7392mAh. This means a bigger battery than 6600mAh would be useful, but not very much.

So, on a bright sunny day, we should be able to run 24 hours a day. Looking at the results from SkyWeather  being out in the sun for a week, this seems to be correct. However, it will be cloudy and rainy and your system will run out of power. The next most important part of the design is how to handle Brownouts!

Note:   We are using currents and efficiencies to simplify the equations.   If you want to compare currents at different voltages (say 3.7V and 5V) then you need to compare power.  Power = Voltage * Current.  So if you have 100mA at 4V, that is 0.4Watts.  100mA at 5V is 0.5Watts.

Solar System Design

The four most important parts of verifying your Solar Power Design:

  • -Gather real data
  • -Gather more real data
  • -Gather still more real data
  • -Look at your data and what it is telling you about the real system. Rinse and Repeat.

The power system in SkyWeather consists of four parts:

  • -Four Solar Panels
  • -Solar Multipanel Connector
  • -One 6600Ah LiPo Battery
  • -SunControl Solar Power Controller, Pi Power Supply and Data Gathering system

We are using 4 4W/330mA Solar Panels from SwitchDoc Labs. You can use virtually any solar panel as long as they are 6V solar panels. And if you find that your unit is still not getting enough power during the day, then add another 2W panel!. The Voltaic Systems panels will run you about $40 a piece where the SwitchDoc Labs Panels will cost about $12 per panel. We have a lot of experience with the Voltaics panels in the tropics and they are good panels.

NOTE:   You need to look at the VOC (Voltage Open Circuit)  of any other solar panel you have.   If it is above 6V, you need to add in a 10W 5.6V Zener diode across the solar panels to protect your SunControl board and system.  Here is a link to an example 10W 5.6V Zener diode.  As of the writing of this manual, the ebay.com link below is sold out, but check back later.   We have a few of these on our shop.switchdoc.com website (https://shop.switchdoc.com/products/10w-5-6v-zener-diode).

Other sources (but more expensive!):

https://www.ebay.com/itm/1N3997A-5-6v-10w-Zener-Diode-Cathode-to-Stud-Polarity-DO4-DO-203AA-NAE/261213332106?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

https://www.mouser.com/Search/Refine?Keyword=1N3997

 

https://www.digikey.com/products/en?keywords=1N3997

 

Unfortunately, you can’t just put 10 1W 5.6V Zener diodes in parallel.  They aren’t identical and the one that is slightly lower will take all the current.   You can, however, stack them in series to aquire the appropriate volltage and power dissipation.  Such as stacking 2 5W 2.8V Zener diodes.

We selected a 6600mAh battery from Adafruit for this design. See the “Sizing your Solar System” step above. We are using a SunControl solar powered controller in this design.

SunControl combines the USB PowerControl, SunAirPlus and the SwitchDoc Labs Watchdog Timer into one board.    The INA3221 3 channel current and voltage sensor allows you to monitor all of the major currents and voltages in the system (Battery / Solar Panels / Load – Computer ). You can tell what your solar power project is doing in real time, while the USB Powercontrol circuitry shuts down and starts up your Raspberry safely (see brownout discussion below) in combination with the onboard watchdog timer.   SolarMAX also provides this great data gathering capability.

Solar Power Controller

SunControl Results

 

Here are some results from the SunControl board using the onboard INA3221 3 channel current and voltage sensor. You can see that the battery is almost fully charged and the solar cell voltage (actually a variable power supply on the test bench) is 5.19V and it is supplying 735mA.

LIPO_Battery Bus Voltage: 4.15 V 
LIPO_Battery Shunt Voltage: -9.12 mV 
LIPO_Battery Load Voltage: 4.14 V 
LIPO_Battery Current 1: 91.20 mA
 
Solar Cell Bus Voltage 2: 5.19 V 
Solar Cell Shunt Voltage 2: -73.52 mV 
Solar Cell Load Voltage 2: 5.12 V 
Solar Cell Current 2: 735.20 mA 

Output Bus Voltage 3: 4.88 V 
Output Shunt Voltage 3: 48.68 mV 
Output Load Voltage 3: 4.93 V 
Output Current 3: 486.80 mA 

Here is what all those values mean. You can ignore the Shunt Voltages:

 

Parameter Name Value Description Interpretation
batteryVoltage 4.15 Voltage (V) on LiPo Battery About 4.2V is a fully charged battery, ~3.3V is a fully discharged battery.  SunControl will shut off the system around 3.3V.
batteryCurrent 91.0 Current (mA) coming FROM the LiPo Battery (negative when charging) 91 mA coming from the battery.
solarVoltage 5.19 Voltage (V) on the Solar Panels Significant light on the solar panels.
solarCurrent 735.20

 

Current (mA) coming from the Solar Panels. + means from the panel into SunControl, – means nothing. Lots of current coming from Solar Panels.  3.8W
loadVoltage 4.93

 

Voltage (V) on the output of the USB Power Plug Voltage should be between 4.8 and 5.2V.
loadCurrent 486.90 Current (mA) into SkyWeather How much current is going into the SkyWeather system.

You can use this board to power your projects and add a servo or stepper motor to allow it to track the sun using photoresistors or timing to generate even more power.  We ran a test on tracking the sun to prove our point ( http://www.switchdoc.com/2016/05/sun-tracking-solar-power-part-1/ ).

Controlling the Raspberry Pi Power

The SunControl  Board contains  a controlled Solid State Relay to turn the power on and off to the Raspberry Pi.. The input to this cirucut was designed to come directly from a LiPo battery so the computer won’t be turned on until the LiPo battery was charged up above ~ 3.8V. A hysteresis circuit is provided so the board won’t turn on and then turn immediately off because the power supply is yanked down when the computer turns on (putting a load not the battery). This really happens!!!! You kill Raspberry Pi SD Cards this way.

 

Brownouts

In this important step, we are going to discuss the problem of powering down and up your Raspberry Pi. In Solar Powered systems, this is called the “Brownout Problem”.

One of the most important issue in designing a Raspberry Pi Solar Power System is turning on and off. The “Brownout Problem” is a real issue. Why worry? If you have a long string of cloudy days, you may run your battery down. You can compensate for this in your design by adding more panels and more batteries, but that can get really expensive and your system might still run out of power, just a lot less frequently.

Shutting Off the Pi

Shutting a Raspberry Pi off is pretty easy. When the battery voltage falls below some value, you just do a “sudo shutdown -h now” and your Raspberry Pi will shutdown cleanly. After doing the test talked about here ( http://www.switchdoc.com/2015/04/turning-the-pi-on-and-off-weatherpi-solar-power/ ) , we chose 3.5V as the voltage to shut down the Raspberry Pi.

Note that in most solar power systems, you need to monitor the battery voltage and not the 5V power supply because with most modern voltage booster systems, the circuitry will work very hard to keep the 5V going and then just give up crashing to a much lower voltage when it runs out of power.

Solar Power ChartShowing Shutdown Voltage and Startup Voltage on the Raspberry Pi

That means your computer would have little or no warning when the voltage is about to drop. By monitoring the battery voltage, you can tell when the battery is getting low enough and then shut down your computer safely. For LiPo batteries, this will be when your voltage gets down to about 3.5V or so. This can all be monitored with the SunAirPlus solar charge controller that we are using in GroveWeatherPi.

Starting the Pi

Enough about shutting down the computer. What about starting it up?

The Issue

You can’t just let the controller power up the computer. The problem is that the supply voltage will move up and down until there is enough charge in the battery to fully supply the computer. When the computer turns on (connecting a full load), you will pull the battery down hard enough to brown out the computer causing the Raspberry Pi to crash. This constant rebooting cycle can corrupt and ruin your SD card and cause your computer to never boot at all, even when the power is restored. We had this VERY thing happen to us 3500 miles away with Project Curacao. Arduinos are more tolerant of this, but Raspberry Pi’s do not like a ill-behaved power supply. You just can’t be sure of what state the computer will power up at without a good power supply.

This issue can be handled in a number of ways. The first is to use another computer (like an Arduino made to be very reliable by using a WatchDog – see the Reliable Computer series on switchdoc.com – http://www.switchdoc.com/2014/11/reliable-projects-watchdog-timers-raspberry-pi-arduinos/ ) to disconnect the Raspberry Pi’s power through a latching relay or MOSFET when there isn’t enough power. Project Curacao ( http://www.switchdoc.com/project-curacao-introduction-part-1/) used this approach.

We didn’t want to add an additional computer to SkyWeather, so we chose a second solution.

Power Your Pi Up and Down with SunControl

A second (and cheaper!) way of handling the brownout and power up problem is to use a dedicated power controller that will shut the power off to the Raspberry Pi and restore the power when the battery voltage is high enough to avoid ratcheting the supply voltage up and down because of the load of the Raspberry Pi. This is called Hysteresis. We have designed a circuit to do just this (called the USB Power Controller) in SunControl to do this.

The USB Power Controller Circuit in SunControl

The USB PowerControl circuit is a USB to USB solid state relay.

There is a hysteresis circuit so the board won’t turn on and then turn immediately off because the power supply is yanked down when the computer turns on (putting a load not the battery).

There is little software for this circuit. The only software used detects the battery voltage and decides when to shut down the computer. The USB Power Control Circuit takes care of shutting the power to the Raspberry Pi when the battery voltage gets low enough. Note that a shutdown Raspberry Pi still draws current (according to one quick measurement, about 100ma).  You still need to turn off the power, which this board will do.

One More Important Scenario

One last point. After thinking about the power down sequence, we came up with one more scenario. What if:

  1. The battery voltage reaches 3.5V and the Raspberry Pi is shut down.
  1. The USB PowerController Circuit will turn the power off when the battery reaches about ~3.4V.

However, what if the sun comes up at this time and the battery starts charging again?

Then the USB PowerController will never reach ~3.4V and will never turn off. And the Pi will never reboot. Not a good scenario!

We fixed this problem by adding a hardware watchdog timer.

For a tutorial on hardware watchdog timers, read the SwitchDoc series starting here. http://www.switchdoc.com/2014/11/reliable-projects-watchdog-timers-raspberry-pi-arduinos/

We used a onboard SunControl WatchDog Circuit to fix this problem. We set the RaspberryPi python to “pat the dog” (preventing the watchdog timer from triggering) every 10 seconds. The timer is set to trigger after about 60 seconds if it isn’t patted. The timer is connected the USB PowerControl circuitry down to ground which shuts off the Raspberry Pi.

Because of the hysteresis circuit on the USB PowerController circuit the Raspberry Pi will stay off until the battery voltage reaches ~3.9V and then the Pi will reboot. Now the above very bad scenario will never happen. By the way, there is no real way of using the internal Pi Watchdog to do this. You don’t want to reboot the Pi, you want to shut off the power in this scenario.

How to Hook All This Up?

The Solar SkyWeather Extender Kit has a detailed manual on how to set up and wire all this for a Raspberry Pi based system.

You can find the assembly manual here.

SolarMAX has a detailed manual on the product page.

Solar Power on SkyWeather

Block Diagram of SolarMAX Lead Acid

Block diagram of SunControl

SunControl Circuit Locations