How to Turn Any Raspberry Pi (or SBC/Microcontroller) Project into a Solar-Powered Project
This guide will walk you through the steps to get your Raspberry Pi project 100% on solar power. Raspberry Pi on solar isn't a new concept, but when I was looking up how to size out my solar project, I saw many guides and tutorials riddled with electrical engineering calculations and concepts that were mostly aimed at solar panels to power an entire home. I was just trying to power a little Pi. Today, I'm going to try to keep it simple and aimed at your SBC project (I'll be referencing Raspberry Pi, but you can apply these steps to any SBC/Microcontroller). So, excuse me if I make egregious blanket statements (I'm welcome to feedback in the comments!), but this should work for 95% of the projects out there.
Tip for those in a rush: Step One is all you need. You can probably figure out the rest on your own, and if you get stuck, just come back and read the rest!
!! Soldering Required !!
You can probably buy your parts to line up and avoid soldering altogether, but most of the time, it's easier (and more cost effective) to solder. Besides the parts I will go over in the next section, you will need to have a soldering kit and basic soldering skills to assemble all the components. It's not hard to learn (check YouTube!), and you can get inexpensive kits online for $20 or less to test the waters.
This guide may start to get confusing, so here are the things you need up front. We will be filling in the ?? in Step One. I'll go over some equipment recommendations in Step Two. I'll demonstrate an example assembly in Step Three.
- Solar Panel:
- Solar Charge Manager Module
- JST Cables
- 5V Converter/Regulator (Optional/As Necessary)
- Other Optional Parts:
USB Connectors (To make a JST to USB power cable)
Step One: Determine Power Requirements
We're going to stick with 6V solar panels and 3.7V lithium-ion polymer (lipo) batteries. If you have a particularly power-heavy project requiring larger solar panels, you can use this guide just the same; 6V panels and 3.7 lipo batteries will cover most IoT projects, and this is what I will be referencing to minimize confusion.
For Raspberry Pi, you may need a step-up converter to increase your output to 5V; 5V is the recommended power supply voltage, but most small projects will work fine on 3.7V without impact to performance (or the annoying "low voltage" notice). You may see impact to performance if you have various USB devices also connected to your Pi.
The rest of your requirements will be determined with the following steps:
a. Determine a rough estimate of the following for your project:
How much current does it draw (milli-amps (mA))?
How many hours of sunlight will it get daily?
This will determine the size of your solar panel.
How many hours of darkness will it get daily?
This will determine the size of your battery.
Any peripherals you install will also draw extra power, so you will need to take that into consideration when estimating your power consumption. Here is an example with a Raspberry Pi Zero:
- Total Current Draw: 150 mA
- Total Daily Sunlight: 6.5 hours
- Based on Casio's sunlight calculation for the winter solstice in my location (assuming the device will need to function 24/7/365); but this doesn't necessarily guarantee I'll have 6.5 hours of DIRECT sunlight every day.
- Total Daily Darkness: 17.5 hours
- Subtracting the total daily sunlight from 24 hours.
b. Determine the size of battery required by multiplying your Total Current Draw x Total Daily Darkness. The logic here is that your device will need to store enough juice to get through the night. This will result in the minimum mAh required for your battery. Write this down, we will need it in the next step (and for battery shopping).
150 mA x 17.5 hours = 2625 mAh
c. Determine the size of your solar panel.
If you google "What size solar panel do I need?", you're going to get a lot of articles about home solar systems with calculations based on your annual kwh consumption. We don't need all that. So we're going to brute force this one a little bit. With all of our calculations in pocket, let's plug in our numbers:
*Credit: This was adapted from Footprint Hero's calculator.
Battery milliamp-hours (mAh): Calculation from step 1.b
Solar Panel Voltage (V): 6V (for this tutorial; adjust as necessary)
These remaining variables are what we need to play around with:
Solar Panel Wattage (W):
Start from 1W and increase until the "Estimated charge time" output is within your Total Daily Sunlight hours.
Solar Charge Controller Type:
This will depend on your budget and your system. I recommend MPPT, since this is more efficient, but you can toggle back and forth between MPPT and PWM for each step in Solar Panel Wattage to see your options.
Here's an example:
This tells me my solar panel needs to be at LEAST 4 watts to charge 2625 mAh in 5.58 hours without a load (i. e. device off). Now, if I were to get a 3000 mAh battery, I can assume that approximately 2625 mAh's of it will be charged within 5.58 hours, even if it will not be fully charged. However, if your system will need to BOTH charge your battery and keep your device running during daylight, sizing up one or two watts isn't a bad idea; see "Note for Persistent Devices" above.
Step Two: Go Shopping
a. Choose a Solar Panel.
We determined the minimum wattage in step 1.c, but shop around. You may decide to go bigger based on price/quality/availability. Here are some suggestions. If they don't have the exact wattage you're looking for (and you don't want to size up) you can find many other options online.
Quality/Durability: Voltaic Systems
I've found plenty of cheap solar panels on Amazon and eBay that get the job done. I can't speak for long-term durability, but these panels have worked just fine for my projects.
b. Choose a Battery.
We determined the minimum mAh in step 1.b. Again, shop around. However, keep in mind that many lipo batteries online are made for radio controlled cars and drones. These batteries will have the polarities (red wire and black wire) reversed. Here are some suggestions:
Plug and Play: Adafruit
Adafruit has everything in the correct polarities for SBC/microcontroller projects.
Most batteries on Amazon/eBay will have reversed polarities. It's easy to make your own adapter to correct the polarities. I'll go over that in Step Three. Amazon and eBay also has a larger range of mAh options if you have need a lot of power.
c. Choose a Solar Charge Manager Module.
This is probably the most critical component of your system. I would recommend MPPT over PWM; it's more expensive, but the little boards are pretty inexpensive to begin with. Some additional important things to pay attention to are:
- Input Voltage: This should match your solar panel voltage (6W for this tutorial).
- Output Voltage: This is the voltage that is drawn from your battery and outputted to your device. On a 3.7V battery, you're looking for at least 3.7V-4.2V output, but some will regulate output to 5V (meaning no need for a step-up converter!)
- Overcharge/Over-discharge Protection: Many lipo batteries come with overcharge/discharge protection chips; if your battery does not, ensure your solar charge manager does (or you add one inline with the battery separately). These are safety features; overcharging a lithium battery will result in overheating/explosion, and over-discharging a lithium battery will result in a dead battery that will be dangerous to recharge (which may also lead to overheating/explosion).
- Automatic Recharge: Some over-discharge protection chips will disconnect the load from the battery if the battery charge gets too low; if you do not have an auto-recharge function, you will have to manually disconnect and reconnect your battery every time the battery gets drained (as opposed to the battery being automatically recharged when the sun rises).
- Backflow Prevention: Schottky diodes are implemented to prevent the solar panel from leeching current from the circuit when it is not actively charging (i. e. at night), essentially like a check valve. Many solar charge managers have these built-in, but you can also install them directly on the solar panel.
- Max Charging Current: Compare this to the "Solar Charge Current" from the calculator above. 2 amps is a typical max charging current for small-scale solar charge managers, and this should be plenty for most Raspberry Pi projects.
Most small-scale solar charge managers you'll find online will use one of a few solar charge chips. CN3791 is a very common (and inexpensive) chip; here is the data sheet detailing most of the features above. If your solar charge manager does not use this chip, find out which chip it uses and look up the datasheet; the manufacturer/seller should be able to provide you with the exact chip model if you can't find it in the item description.
Here are some suggestions:
Ok, they state it's not 100% true MPPT, but it performs the same. The input voltage range is 5V-10V.
Not all of the modules listed on Amazon state whether they're MPPT or PWM. If it's not stated, I would assume it's PWM (as far as calculations go). There is also a larger range of voltage inputs available on Amazon and eBay, just in case you're not going with 6V.
d. Choose JST Cables.
Like the batteries, many JST cables online will have reversed polarities. Get both male and female; how many of each will depend on your project and what parts you choose. Here are some suggestions:
Plug and Play: Adafruit
Adafruit has everything in the correct polarities for SBC/microcontroller projects.
Most JST cables on Amazon and eBay will have reversed polarities. You can buy JST cables as-is and just cut, cross, and solder the wires to correct. Or you can buy JST cable kits to crimp your own cables in the correct polarities. The latter may be the preferred option if you have a bunch of projects that will require JST cables. You could also try carefully prying open a JST connector and reversing the polarities, but I haven't had any luck with this personally.
e. Choose 5V Converter/Regulator.
If you will be using the USB ports on your Pi, you should probably ensure you're at the proper voltage. For Raspberry Pi, that's 5V. If you're not sure you need this (most of my projects don't), you can try your project without it, then add this if you're having low voltage issues. Whether or not you'll need this may depend on your solar charge manager; check the output voltage there first to see if this is necessary.
Plug and Play: Adafruit
Adafruit tailors everything to SBC/microcontroller projects, so there will be minimal "figuring out" in terms of compatibility.
There is a large range of converters available on Amazon and eBay for various types of projects. Ensure the module you choose is compatible with both your input voltage (from your solar charge manager) and your output voltage (5V).
Step Three: Assemble
Ok, so we finally have all of our parts figured out. At this point, you can probably figure out how to put the pieces together, but if you're still lost and need an example, keep reading!
a. Lay out your parts:
b. Connect your components:
Here's a diagram of my plan. This is where soldering comes in handy; try finding a JST to micro USB cable with a power switch anywhere online! Here are some tips:
- I clipped off one of the outboard poles on my switch. I bought the switch based on size; this is definitely not the intended installation for this switch.
- You should be able to find your required polarity on your solar charge manager module:
- Insulate your solder joints! This can be with electrical tape, heat-shrink tubing, epoxy, hot glue, etc. Personally, I used electrical tape on the wire splices and hot glue on other solder joints (solar panel, switch, micro-USB connector). This helps prevent accidental short circuits and helps with waterproofing.
- If your solar panel came with wires already attached, you can either cut and splice them with a JST cable, or get an appropriate adapter. This will depend on your solar charge manager; some will use DC jacks instead of JST.
- You can actually solder the JST power cable directly to the Pi Zero's GPIO pins (5V and GND). Pi Zero's don't have onboard voltage protection, so it's not any more dangerous than powering via micro USB. Still, as long as your solar charge manager's output voltage is no greater than 5V, you should be able to safely solder directly to the GPIO pins with any model of Pi.
c. Test it out!
So here's what it looked like in real-life:
Once some sunlight hits your solar panel, check your solar charge manager module for a status light. This one has a "CH" light for charging. Also make sure your Pi is getting power.
NOTE: If your battery polarities are crossed, your solar charge manager may start getting VERY hot. This isn't normal. Abort and reassess your wiring.
Step Four: Weatherproof Your Case!
Sorry, this isn't actually part of the guide. Too many variables dependent on your specific project. However, liquid gasket makers are your friend!