Solar Powering a Raspberry Pi

I support Folding@Home and World Community Grid because I have compute resource available and I want to be able to help where I can.

But, there's a challenge with grid computing projects: they work by burning energy to solve mathematical puzzles that address real-world problems.

I don't mind the cost - I can afford to donate some money to help with research into curing diseases, but I don't like the idea of the impact I'm having on the planet.

What to do?

Solar power is one answer, so time for a prototype to see what that's like in practice.

What do I want to achieve?

I already contribute to World Community Grid with a Raspberry Pi 4 and a 3B+ running 24x7. They run using Wide Input Shims from Pimoroni and a general purpose 12 Volt 4 Amp power brick. All told, I'm reading about 11 Watts at the wall with both Pis running at full tilt.

I want to take that and run it from a solar panel and battery. I want the battery to stay within sensible parameters to prevent too much deep discharging even if the weather is bad. And I want a sensible sized solar panel that I can use for other things.

The battery

The battery is the most important piece of the puzzle for me, so I'll spend some time on it here.

What kind of capacity do I need?

If I'm running over the winter, I have 11W that will need to be drawn every day for around 14 hours. Let's call it 12W, because at 12V P=VA tells us I need to draw a steady 1 Amp.

Yuasa make good quality automotive and industrial batteries. Importantly, they also publish really good datasheets. I'm going to refer to the datasheet for their REC50-12 cyclic battery.

How do battery capacities work?

An ampere-hour is a way of understanding how much electrical charge you have available to consume. Yuasa say this particular battery is a 50Ah battery, with a maximum discharge current of 185A over the course of a minute. For the sake of example, it's safe for me to draw 50A from the battery!

If I did draw 50A from the battery, it would last an hour. If I drew just 1A it would last me 50 hours.

From this, because I'm working at 12V it's easy to work out that 1A for 14 hours is 14Ah every winter night, but that's just part of the story.

How does discharging a battery affect its life?

The datasheet gives us the expected life data, which ranges from 1400 cycles at 25% discharge to just 300 cycles at 100% discharge.

I'm going to drain the battery nightly, so a "cycle" is the same as a night for my use case.

If I bought a 14Ah battery with the cyclic life Yuasa specify I'd ruin it in less than a year! At the opposite end of the spectrum, if I wanted it to last 1400 cycles (nearly 4 years), I'd have to keep within the 25% discharge spec, which at 14Ah would be a 56Ah battery.

At about £110 delivered for the Yuasa, that's an expensive test, but I reckon I can get a different brand battery for about half that, so I did the obvious thing and went for a 7Ah battery and changed projects!

My test project is now going to be a 12 month timelapse on a Pi Zero W drawing 80mA. I'll still get the bigger battery when I'm ready, but £25 for the 7Ah battery was a simpler investment for this test.

80mA for 14 hours is about 1.1Ah, which would need a 4.4Ah or higher battery to stay within the 25% discharge limit. I can test the theory with this new project, then apply it to the off-grid-grid-compute project.

A word on battery safety

The batteries I'm talking about are "sealed lead acid", which means they contain all kinds of nasties.

You do need to take some precautions.

Even "sealed" batteries have a low-pressure vent to allow gas to escape, and gas is formed mostly when charging. Also, some gas can vent when the battery is hot, which can be during use or charging. The gas in question is hydrogen so allowing that to build up in an enclosed space with electrical equipment can be dangerous - bear that in mind.

The solar panel

I wanted a solar panel that:

  • works for this project, and
  • is useful for camping trips or other projects.

I considered this an investment instead of a test, so in the end, I went for a hoofing great big 60W panel and charge controller kit from Photonic Universe. Job done.

Whether I buy the 7Ah battery or the ~50Ah battery, this will charge it. Fast. On a not very sunny day.

The charge controller

The charge controller is simple to use: connect the battery to the controller, connect the load to the controller then connect the panel to the controller.

Safety first: to prevent any surprises, I always connect ground (negative) connections first, that way I never become the route to ground for current.

The controller mediates between the three and protects all of them, up to a point. The load is powered from the battery or the panel, depending on where power is available - if the panel has excess power to spare while charging the battery (or if the battery is charged) the load will be powered directly from the panel. If the panel can't provide enough power, the load is powered from the battery.

I said the charge controller protects them up to a point: it's a good idea to add fuses in to protect the battery and the load (and the controller itself), so add a fuse that matches the charge controller (10A in my case) placed close to the battery positive terminal, and another to protect the charger from an over-enthusiastic load.

What type of fuse? Well, I went to Halfords (a well-known UK automotive chain store) and bought an in-line fuse holder for car blade fuses. They're designed for 12V and come in values up to at least 30A, so perfect for my needs. Halfords actually do a good range of well priced 12V electrical gear.

The results

Everything works like a dream. I'm testing in November, and I don't have very good placement of the panel, but with my 7Ah battery and 1Ah drain over night the battery is recharged by about lunchtime. This means the panel is powering the Pi during the morning and charging the battery. I do have to try a bigger Pi with a bigger load - that'll be a follow-up post, I reckon.