Hello everybody, I’m the CTO of SwitchDoc Labs Dr. John Shovic and I’m here today to talk about solar power and the to Raspberry Pi.

But first a few comments. Let’s have a science joke. An atom walks into a bar, comes in and sits down at the bar, there’s a couple of ladies in the bar and the bartender over on the other side says, “Hey, see that atom over there? Well, don’t pay any attention to him, he’s really a bad guy, you know, atoms make up everything!” So there you have it, that’s the science joke for the day.

Let’s start talking about solar power and the Raspberry Pi. This is meant to be an introduction because this is a pretty complex topic. We’ve written many articles on this on the SwitchDoc.com blog over the years, but now we’re going to give you a little introduction. This happens to be, a Raspberry Pi 3 with our Grove Interface on top of it, the Pi2Grover. We build solar systems on them. We often will develop using a Raspberry Pi and then go down to the lower power, like the Raspberry Pi zero, the Raspberry Pi zerow, or sometimes even the older Raspberry Pi A. All of those guys use like a third as much power as this.

This really takes a lot of power. So it isn’t a great choice for a solar powered Raspberry Pi. You can still do it of course. It’s going to take more solar panels, more battery power, and more sunlight to run this. This Raspberry Pi essentially allows us to do all sorts of things and it’s kind of cool to put it on solar power if you’re building a solar powered weather station or something like that. Or if you want to stick some unit out in the forest to photograph wildlife, or something like that. You can do all those things with the Raspberry Pi but you still have to provide the solar power. We’re going to talk a little bit about how you do a solar powered system. Remember, this is just an introduction and we can go into more depth about these things in the future.

So what do you need? What’s in a solar power system? Well, of course you have the the Raspberry Pi. Then you’ve got to have some solar panels. These are some solar panels we sell at SwitchDoc Labs. Inexpensive things that are really durable. They really are! This brings you a 330 milliamps full blast and this brings you about a 110 milliamps. Sounds like a lot. But you’ve got to look at the big picture before you say, that’s actually a lot of power because it isn’t. What else do you need? Well, you got to have a battery. Why? Well, the sun doesn’t shine all the time. Plus you’ve got clouds and things like that that can affect your light. You don’t want your computer’s jumping up and down, up and down. So you’ve got to have some kind of a battery.

This happens to be a lipo-battery from Adafruit. It has quite a bit of storage. It’s got about 6600 milliamp hour. Oh, what’s a milliamp hour? Well, you think about it this way, current is measured in milliamps. More specifically its measured in amps but thousanths of amps for these types of computers. Raspberry Pi might take 100 milliamps. That means about a tenth of an amp, or 100 milliamps. So if you have a battery that stores and has a capacity of 6,600 milliamp hours. That means that you can run the Raspberry Pi for 66 hours at a 100 milliamp out of that battery. Now it turns out it doesn’t quite always work that way. You’ll get maybe 80% of the power under the battery, but fundamentally that’s how you’re sizing the battery you’ll need. You can’t accurately measure this in current, you need to convert to power, which is voltage times amp.

So a 6,600 milliamphour battery will run a Raspberry Pi for quite a while, but you have to charge it right? We’ve already looked at these solar panels. There’s one more big piece of the puzzle. We have to have a solar power controller. Now, what do we mean by that? Well, it has a number of different functions. One of the main functions is to charge the battery. I’m sure you’ve heard of lipo batteries catching fire and things like in laptops and those Hoover machines. Well, that does happen and it’s almost always traceable to either the battery is damaged or they didn’t properly have their controller sized. Well, our controller is specially designed to charge lipo batteries so it charges them safely. It won’t charge them too fast, it won’t overcharge them, and it’ll take it up above 4.2 volts.

If they’re very, very low, it’ll slowly charge them up. We even have our controller a spot to put a thermistor on it so it will not charge it if it’s below zero or below zero degrees Fahrenheit or something like that. All of these things affect lipo batteries. So we’ve got to have a controller. Here’s one of the controllers we produce.

This is called SunControl and it has a number of interesting features. First of all, this is where the lipo battery plugs in. Here’s where the solar panels plugin, just as we’re talking about here. And then there are a few other connections that are used for other things. Here’s where the power goes to the Raspberry Pi. And then there are all these little white connectors here. Well, these white connectors are things that are necessary for solar powered Raspberry Pi systems.

Let’s go back to the real first issue of building solar power system. Well, you have to figure out how big to make the system. And we’ve written several articles about this with some formulas you can use to determine that. But let’s just run through this from a theoretical point of view or an abstract point of view. So you get the point. Now I’m using the word power here specifically. That’s because Power is Voltage x Current.+

That is Power. So if I say a solar panel generates a watt and a Raspberry Pi uses a watt, then those are measured the same way. But if I say a solar panel generates 300 milliamps, that’s 4 volts or 6 volts or whatever, I can’t directly compare that 600 milliamps to the Raspberry Pi, which might be using 600 milliamps, it’s not the same thing. The Raspberry Pi is using 600 milliamps at 5 volts where the solar panel may be generating 600 milliamps at 4 volts. So the power is not the same. If they’re both right at 5 volts, 5 volts times 600 milliamps is about 3 watts. OK? A Raspberry Pi using 600 Milli-amps times 5 volts. So that’s 3 watts. So we measure things in watts when we look to keep everything the same because the current isn’t the same.

The voltage that is pushing that current down through the line that comes from Ohm’s Law, if you’re interested in that sort of thing. So how do we size a Raspberry Pi System? Well, the first thing you have to do is you make an estimate on how much sunlight you’re going to have. Then you have to look at your solar panels and with that kind of sun, how much power is it going to give? How many milliamps is it going to supply? Once you know that, then you look at your battery and say, well, I’ve got to store some of this for the nighttime. And the rest of it I’ll use to run the Raspberry Pi, but I have to store up this battery too. Now it turns out the way solar panel systems really work is that you’re kind of charging the battery all the time and discharging the battery all the time.

So what I’m saying is true, but that’s not exactly how you’d see it. If you do look at all the currents involved and all the voltages. You’ll see that power going into the battery and power going out into the load. The rest of it is supplied by the solar power panels. So your solar panels can power your Raspberry Pi directly through a controller because you got to charge that battery too. But if there’s a cloud or anything, the power comes from the battery and a controller handles that movement from a solar panel to a battery. And then when the cloud goes away, you go back to solar power. Having that battery in the system also handles one other wonderful thing. And that’s what happens when it’s dark out. When night comes. If you want your Raspberry Pi to run overnight, you’re going to have to run it all through the night.

You’re going to have to look at that and figure out how much power it’s going to take and how many solar panels you need to generate that amount of power that will go into our lipo-battery that will run the Raspberry Pi at night. Now if you’ve got solar panels on your house or your charging into a big, Tesla battery or something like that, those are all running at 12 volts and we’re dealing with 6-volt solar cells here, which are different. But it’s really the same principle. You charge up the battery, you discharge the battery at night. During the day, you use some from the battery when you have to, but you’re using the solar panel most of the time. So it’s really the same principles and the sizing principles we’re discussing here are really the same thing too.

So the same questions. I want my Raspberry Pi to run overnight. You figure out how much current your system uses. Which can be done with our SunControl Board. There’s a circuit on there that measures the current going into the battery, coming from the solar panels and how much is going into the Raspberry Pi. So you can look at that and you can look at how much is going in the Raspberry Pi and figure out how much you’re using. Why am I not giving you an exact value? Because it depends what you have hooked up to a Raspberry Pi. One of the biggest current sinks or power sinks you can hook up to a Raspberry Pi would be a Raspberry Pi camera. So you want to shut that off when you’re not using it right? If you’re using it all the time, you’ve got to have bigger batteries and bigger solar panels.

So you have to know what your system is doing. To conclude, let’s go back to this board. Now, this board has a couple of interesting things on it. First of all, it has what we call a Watchdog Timer. This happens to be a Watchdog Timer right here. What that means is if your system gets lost, it’ll reboot the system. If you have a software problem, a hardware problem, or just a glitch it’ll reboot your computer. That makes your system more reliable if you’re going to stick this remotely controlled solar panel system way up on top of your house or out in the woods somewhere and it’s nice to have a little more reliability. But as far as the solar power system goes, it’s these connectors that make the real difference.

This connector is a control for what we call USB switch and it sits there and checks the battery level. When the battery level gets low enough, it actually goes in and shuts off the Raspberry Pi. Oh, that’s kinda cool. So you know, the battery gets really low, it shuts off the Raspberry Pi. Then when the battery level gets high enough again, which uses something called hysteresis. So it might turn off at 3.5 volts and turn on at 3.9 volts. That way if you just go over 3.5 volts, you turn on the Raspberry Pi and sucks the power down, the voltage goes back down and shuts right off. Again. We avoid all that by putting a hysteresis circuit in there so it turns off at 3.5 on at 3.9. This means the battery has to charge quite a ways to get up to 3.9 to turn the Pi on so you don’t get this, Bam, Bam, Bam, Bam, Bam, Bam. By the way, that massive number of rebooting the Raspberry Pi will kill your SD card.

It’s a real problem and it will really kill your system, so you’ve got to design around that. How do we design around that? Turning on the machine, this USB power control built into the Sun Control Power Board does that for you. It’ll shut off the Raspberry Pi and turn it on at the higher voltage so it won’t go Bam, Bam, Bam, Bam. But there’s one more thing we have to talk about and that is the Raspberry Pi likes to be shut down with a shutdown command or a halt command rather than just turn off the power. Why is that? If you just turn the power off in a Raspberry Pi, you could actually corrupt the SD card and then the machine will never boot up again until you fix the SD card. This is a whole nother set of processes. So what we want to do is monitor the power in the system.

Because we can do that with the Sun Control Board, we can look at the voltage, we can look at the currents involved and we can look at what our battery voltage is. When the battery voltage gets down to 3.52 or something like that, somewhere above where the system will shut down. We issue a halt command to the Raspberry Pi and it turns off safely so you don’t mess up the SD card. It still uses quite a bit of current even when it’s halted and that will eventually turn off the battery. And then everybody’s happy.

So let’s summarize. What do you have to have for a Raspberry Pi power control system. You need solar panels, batteries, a solar powered controller, and of course a Raspberry Pi. That’s what you need to build a solar panel system.

Then you have to wire them together and there’s some software involved in order to make your system work reliably. What else do you have to do? You have to figure out how big the system is going to be, figuring out how much current, how much power your system is going to require, and then size things appropriately along with the assumptions of how long/ how much sun you will have. What are the efficiencies through the system? Roughly about 80%. You lose about 20% of the power is going through a controller to get to the Raspberry Pi. That’s a typical number and that’s what I use in my calculations that you’ll see on the website, so you have that information. The third part is designing your system so it brings down and brings up the Raspberry Pi safely.

That’s handled by the USB Power Control plus software watching the Raspberry Pi. Voltage software in the Raspberry Pi watching the Raspberry Pi voltage or watching the battery voltage if the battery voltage gets down to a certain point, it shuts the computer down,it goes nappy time until once again, the power comes up and the USB Power Control turns it back on again.

Now that’s an introduction to solar power. I’ve built a lot of small and a lot of medium-sized solar power systems. I’ve never built a farm or anything like that, but I have built a lot of little computers that run on solar power and I’ll tell you, no matter what you do, someday there’s going to be enough clouds in a row to make your solar power system get down. It’s called “brown out” and we’ve got to take care of that.

That’s what things, like using the USB board and monitoring the voltage, will help prevent.