Tutorial: Solar Power for Raspberry Pi

This post will walk you though how to protect your Raspberry Pi while powering it from a solar-powered system, and provide some tips for reducing the power consumption. Our desired goal is to power the Raspberry Pi with only a small solar panel (which you’ll see is not easy considering how power-hungry these boards are), so we’ll provide you with the know-how and tools necessary to reduce the power consumption.

If you want a one-on-one conversation with someone from Voltaic about running small systems offgrid, you can schedule a consultation here:

Schedule an IoT Consultation

 

Items needed to run a Pi continuously from a small solar panel

  • A power management system – Witty Pi, Sleepy Pi, Solar Pi Platter or the system described below
  • A waterproof solar panel – most of our customers can safely use a 6 to 9 Watt panel
  • A battery pack – our V44 with Always On mode (doesn’t shut off in low power situations) is the most popular choice

 

Solar Power for Raspberry Pi

Protecting your Raspberry Pi – Autonomous Shutdown

One of the main hazards associated with running a Raspberry Pi from a battery is the potential to damage the Pi if it is abruptly turned off. The operating system must be safely shut down before power is removed from the Pi or the SD card (or the Pi board itself) may be permanently damaged. Therefore, our Voltaic USB batteries may not be the best solution for autonomous Raspberry Pi projects since they provide a constant power supply until the capacity is drained, then turn off without warning.

One way to protect the Pi from abruptly turning off is to monitor the raw voltage of a lithium-polymer battery and have the Pi autonomously turn itself off when the voltage drops to a specific threshold.

Monitoring Battery Voltage

You can monitor the voltage of a bare Li-Po battery with the SwitchDoc Labs SunAirPlus Charge Controller or the Adafruit INA219 volt / current meter combined with their Solar Charger and Power Boost with a USB port. The voltage for typical Li-Po batteries is 4.2V when full and 3.7V when nearly empty, so you’ll want to shut down your Pi board at around 3.7V so that it doesn’t completely drain the battery and damage the SD card.

There is a wealth of information for programming your Adafruit INA219 volt/current meter (no programming is necessary for the Adafruit Solar Charger) as well as information at SwitchDoc Labs for programming your SunAirPlus to detect voltage changes. Wiring diagrams are also included through each company.

Monitoring the battery voltage can be much easier with the right user interface to collect your data. Below is an example of the RaspiConnect interface that allows you to monitor your battery voltage in real time from anywhere in the world. Picture widgets can also be included to observe your time-lapse photography as it happens or record video.

Solar Power for Raspberry Pi

RaspiConnect interface for monitoring your battery voltage in real time

Autonomous Shutdown

To shutdown the Pi at 3.7V, see examples of these shutdown commands with a push button using a while loop or an interrupt command (this can easily be modified for detecting a voltage threshold) at raspberry-pi-geek.com. Anyone familiar with Raspberry Pi’s can insert a “sudo shutdown -h now” command when the voltage goes below 3.7V

Note: Your Raspberry Pi board cannot read the voltage directly since it exceeds the maximum voltage of the GPIO pins (3.3V). Therefore it is best to translate this information to the Pi through an Arduino board. The Arduino can control when the Pi gets power through a transistor or latch relay, thereby removing power after the Pi has shut down and providing power again when the voltage of the battery increases.

Simply monitor the voltage of the battery through an Arduino and have it send a unique signal to the Pi board(as simple as True/False, High/Low, 1/0) when the voltage dips below 3.7V so the Raspberry Pi can shut itself down. About one minute after the Pi board has shut down, the Arduino can stop providing power to the transistor or latch relay and remove power from the Pi altogether, that way when power is reapplied the Pi will automatically turn on. More information is available at John Shovic’s Project Curacao page.

 

Reducing Power Consumption

Raspberry Pi’s consume a lot of power by DIY microcontroller standards, and unfortunately they do not support a “sleep mode” like Arduino boards to reduce power consumption between important activities. You can still reduce the power though by cycling the Pi on and off for set periods of time.

24 / 7 Operation – Cycling the Pi on and off

If you want to keep your Pi board up and running around the clock, you may want to consider how often you actually need the Pi turned on. If you are collecting sensor data or taking time-lapsed photos, it would be advantageous to turn the Pi completely off between data collection and turn it on only when necessary (the less often the better!).

Keep in mind, running a Pi for 24 hours per day can consume a TON of power. Even the smallest, most power efficient Pi board out there (the A+ board) consumes at least 24 Watt-hours per day from constant use, so you’ll need at least a 9W panel to maintain this board in bright sunshine.

Earlier we talked about programming the Pi to autonomously shut itself off, but it is a little harder (translation: impossible) to have it turn itself back on. This cannot be done without another device that stays on indefinitely, and a small Arduino can be the perfect solution. By controlling the power supply to the Pi with a latch relay or a strong transistor, you can have the Arduino awaken your Raspberry Pi at set intervals. All Arduino’s have internal watchdog timers that can be customized to any length of time you want, from milliseconds to hours. Only a small board is necessary, as its only job is to turn on the Raspberry Pi after a fixed period of time (and possibly monitor the voltage of the battery since it can receive sensor data at 5V without scaling it down). They should be put to sleep when inactive to reduce power consumption further.

Note: Technically the internal watchdog timer only lasts 8 seconds before it wakes up the Arduino, but you can set a fixed number of sleep cycles that the Arduino must wake up from before it actually does anything. So if you wanted your Raspberry Pi to turn on every 10 minutes, you would simply set the appropriate number of times it should cycle through the 8 second sleep mode to wait the full 10 minutes before the Arduino allows power to return to the Pi. Code snippets of this are found on our Voltaic GitHub page and through Adafruit tutorials, and examples of this in action are seen in our Solar Air Quality Sensor to wake up an Arduino Uno every 5 minutes.

This can also work simultaneously with the Raspberry Pi’s automatic shutdown feature, so even if it should still stay powered on for a few more minutes but the voltage drops too low, the Pi will safely shut down.

Time-Specific Operation

Turning on the Raspberry Pi for only certain times of the day can also dramatically reduce the power consumption. Perhaps the data you want to collect or the pictures you want to take are most useful to you during a certain period of time, in which case you can program the Arduino to only turn on the Pi during that time of day using a Real Time Clock. Have the Arduino send a special signal of your choosing to the Raspberry Pi when your desired time interval has passed so that it can safely shut down and remain off through the night.

3rd Party Pi Management Boards

Since we first wrote this guide, several products have come on the market to help manage Raspberry Pi’s power consumption.

Witty Pi 2 by UUGear: This product adds a real-time clock and power management to the Pi. UUGear has even written a tutorial to create a Pi-based time-lapse camera using our 6 Watt solar panel and V15 Battery Pack with Always On mode.
Sleepy Pi 2 by Spell Foundry: We have at least one customer using this board for smart power management of the Pi, but no solar tutorials just yet.

Know more? Drop us a line.

 

Sizing your Solar Panels

It may be useful to briefly compare the power consumption of different Raspberry Pi boards so you can appropriately size your panels.

Solar Power for Raspberry Pi

Raspberry Pi Model A+ and Model B

Raspberry Pi Board Current Consumption Daily Power Consumption
(Amps x 5V x 24hrs)
Model A+ 200mA 24Wh
Model A 260mA 31.2Wh
Model B+ 300mA 36Wh
Model B 480mA 57.6Wh

 

Note: Every Pi script is different, therefore they all have different power requirements based on the additional accessories and sensors. The numbers presented here are approximations based on power consumption averages with no additional components. The best way to know how much power your Pi board actually uses is to monitor the voltage and current with a USB amp-meter from the battery or some other method.

Multiply the current by the voltage (USB power supplies are 5V) and by the number of hours you plan on running the Pi and you’ll have your daily power consumption in Watt-hours. This is the benchmark from which you’ll compare the output from the solar panels you are interested in. Multiply the rated wattage of the panel by the number of hours of sunshine you think you’ll receive each day and then discount for power loss along the chain by 40%. For example, if you think you’ll have bright sunshine for 6 hours per day, the 9W panel will produce 32 Watt-hours.

There are a lot of variables, but we generally recommend choosing a panel size that produces, on a good day, 2-3 times as much power as you think you’ll need on a daily basis.  If you so if you are using the Pi model B+ and your unique project requires 40Wh per day, we recommend using enough solar panels to generate at least 80Wh per day (equivalent to the 18W Charging Kit exposed to 4.5 hours of sun). This is why it’s critically important to reduce power consumption!

Remember! Don’t only count the number of hours the sun is in the sky, count the number of hours the sun is pointed directly at the solar panels. If there are trees or buildings that cast shade over your project for certain hours of the day, that shortens the amount of time the panels are pointed directly at the sun.

Solar Power for Raspberry Pi: Conclusion

With the appropriate software built into the Raspberry Pi to protect itself and some medium-large solar panels your Raspberry Pi project can live on indefinitely. Combining a Raspberry Pi with an Arduino can add many benefits to your project, such as safety and extended battery life during bad weather, though it is certainly not necessary.

If you can accomplish your project goals without using a Raspberry Pi at all (perhaps by using a BeagleBone or Arduino) it may be in your best interest to do so because of the technical obstacles presented here (high power consumption, risk of corrupting the SD card). Though if you are already very familiar with Raspberry Pi’s or want to use some of the powerful RaspiConnect interfaces to track your data in real time, then it is certainly possible to sustain your project with solar power.

For more on remote systems, check out our solar powered Arduino guide.

16 Responses

  1. Diogene

    Raspberry pi board power consumption are much higher that what you show here.
    And generally raspberry pi board are bad chooses for only solar powering.
    Furthermore the version A is not suitable choice for low power consumption because is equipped with very inefficient LDO.

    Reply
  2. stu

    I’m not a hardware guy so much as a software guy, but I think you may be overengineering things.
    You say “permanently damage” the pi or sd card. Well, again I’m not a hardware guy, but I thought power spikes break circuitry, not power loss. I can see low voltage being a problem but not immediate power loss.
    Anyway that’s not my point: it’s the sdcard I can speak to or rather the data on it. Depending on how you install whatever OS you run on your raspberry pi, you might have little to worry about.
    The ext3 and ext4 filesystems implement journaling which means after every write that is performed, the data may not be on disk in its final form, but it is on disk, at least in the journal an in the event of a random power loss, upon restart, the filesystem mount action will replay the journal to finish up what would have happened if the power wasn’t lost.
    Journaling filesystems are very resilient against these types of problems. If you want to go crazy, you can install zfs which has all sorts of data protection mechanisms in it if you need to protect your data against possible loss.

    Reply
  3. James

    Why not just power the pi with a 2.1 amp 5v usb adapter for a vehicle’s lighter socket, then connect that in parallel to a 9w solar panel and a cheap 12v 5ah lead acid battery? The power output of the panel would never be able to overcharge the battery and the pi would have full ups ability when the sun goes down.

    Reply
    • Voltaic Systems

      Hi James,

      In general, we prefer LiIon or LiIon Phosphate batteries over lead acid as they are a lot lighter and tend to last a lot more cycles. Unless managed properly, lead acid batteries seem to have short shelf lives in the field. You can certainly try that setup. We would probably go with an 18 Watt / 18 Volt panel and a charge controller to prevent over discharging the battery.

      Reply
    • Jared

      That’s exactly what I want to do, or are looking into, but using a 20watt panel /18ah battery, and a car lighter charger… They say rpi4s charger is 15watts (5V 3a), and that it would be fine if any added hats consumed under 500mA I think it was…

      So my theory was, 20watt panel, to charge a 12v 18ah battery, and then run a lighter charger to power rpi4… Still haven’t figured out what I’m going to do about running a display yet.. trying to stay away from a cheap and nasty low power inverter…

      Reply
      • Voltaic Systems

        The 20W panel could work if you’re shutting the Pi off between functions. If you are trying to run the Pi 24 x 7, it would not work.

        Cigarette lighters that drop power from 12 to 5V are often very inefficient. I would look for a buck converter or some other regulator.

  4. zorko

    is possible to run CHIP computer off grid?
    i need screen (10″), keyboard,wifi and router working all day (24h)
    CHIP are working 10-12h per day. How creating all together?
    router with information about power, meybe simple web serwer for information.
    router ssh acces and meybe SD storage.
    power bank in router big for screen (pixelq screen, mirasol?) and chip.

    Reply
  5. PJ Gray

    I am struggling to figure out how to properly power on/off my Pi with an Arduino using a transistor. Does anyone know of a tutorial that goes into more detail? I think I am not using the NPN transistor properly. I can trigger the power on and off to the Pi, but the current is never high enough and so my wifi doesn’t turn on. I am using a transistor from Adafruit, and the data sheet says the collector is rated at 1A (max) which should be good enough…so I think I am just not understanding the Base part? Most tutorials I have found online are about powering lamps or motors…haven’t found one that discusses power to something like a Pi (and how that changes the transistor setup)

    Thanks for helping a newb!

    Reply
  6. Ross McFarlane

    Hi Tony,

    I’m looking to do a project similar to yours but with water quality. What you have done looks great and it would be so useful if I could ask an expert for a few tips?

    Many thanks,
    Ross

    Reply
  7. Paul

    Does the smaller RPi A+ model work significantly better in this setup? Will Voltaic ever sell all-in-one cases with integrated battery and solar panels? Thanks!

    Reply
    • Tony

      the low power Pi’s do not work better or worse, the just work significantly longer. If you reduce your power requirement by 50%, you double the run time, possibly even more. There’s no need to use extra energy for systems or features that you don’t need, so if you can get away with the smallest ones then do so.

      Tony

      Reply
  8. David

    You may want to add the Pi2! Mine draws around 250 mA headless and 500mA with a monitor/keyboard/mouse attached.

    Also, is there a good way to monitor the capacity of the voltaic battery packs (V44)? My Pi seemed to just shut down when the battery died even though my amperometer says it is still putting out enough current at 5V.

    Reply
    • Voltaic Systems

      Hi David,

      No good way to monitor the voltage of the V44 as it is a regulated output. The voltage stays close to 5 until it is completely dead. The options are to use raw LiPo cells as they do in this post or, potentially, crack the case and attach leads directly to the cells. Obviously, the latter is at your own risk, but other customers have done this successfully.

      Jeff

      Reply

Leave a Reply

Your email address will not be published.

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