“Sleep Co-Processor” Enables Solar-Powered Raspberry Pi with ATTiny85

Published By

We previously discussed whether or not you can run a Pi Zero W single board computer on solar power. The answer is yes, of course, but you’ll need a backup power source for when the sun isn’t out—probably one that’s much larger than what you expect.

This need for power assumes that your Pi actually stays on all the time, constantly sucking in around 132mA of current. In many IoT scenarios, however, you only need access in short bursts, perhaps to take measurements every few hours or snap a picture at a designated time. While the Pi can’t go to sleep on its own, this project shows you how to power it up only when needed, then safely shut down until the next time it's needed.

Here we’ll be using the ATtiny85 microcontroller as a sort of “sleep co-processor,” since it can sip under a single mA when awake. The ‘85 cycles power on and off to the Pi board with a relay, giving it enough time to boot up, accomplish its task, and shut down for the next cycle, keeping its battery or solar power bank ready to go!

Program ATTiny85 with Raspberry Pi

power pack 2

Current draw measured via Fluke Multimeter via black and red clips

To test this idea, I set up male and female USB connectors on a breadboard, along with a relay and ATtiny85 to engage power, and a 2200µF capacitor to even out any voltage drops. The Pi runs a script on bootup that turns an LED on, then shuts itself off after 90 seconds, simulating some trivial task that its human masters would like it to accomplish. The on time could be made shorter, but I wanted to be able to log on and stop the shutdown, if needed.

Code for this procedure is found on GitHub, for both the ATtiny85 and the Raspberry Pi. Note that you’ll need to use sudo apt-get install rpi.gpio to add the needed functionality to turn the test LED on and off. You’ll also need to add a line to crontab with crontab -e that states: @reboot python3/home/blinkshut.py to start its ticking shutdown clock when it boots up.

Raspberry Pi Zero Power Usage

In raw numbers, here are a few things I found when running this experiment:

·      Pi bootup (time to LED on) ~30 seconds

·      Pi shutdown ~10 seconds

·      Current draw with ATtiny85 running, relay connected and disengaged: 5mA

·      Current draw with Pi/relay on: 200mA

Since the Pi consumes around 130mA by itself, the relay, ATtiny85, and losses are taking a relatively big chunk of power to operate when engaged. The big takeaway is that the less often you cycle your Pi, the better—preferably every few hours or less. The other lesson here is that whatever your process is, when working with the Pi Zero W, add sufficient time for startup and shutdown.

power pack 3

PuTTY never saw the auto-shutdown coming!

Go Further: Raspberry Pi RTC Module & More

Everything in this low-power Pi device is based on timing, so if for some reason the Pi takes too long to do a certain task, you risk powering it off prematurely. This could mean uncollected data and/or a corrupted SD card. A better solution is to run an output from the Pi to the ATiny85, telling it exactly when it’s powering off. Additionally, you could use an input to the ATtiny85 to tell it when to turn on based on a sensor input, or even use an RTC module to make sure the system activates right on time.

Latest News

Sorry, your filter selection returned no results.

We've updated our privacy policy. Please take a moment to review these changes. By clicking I Agree to Arrow Electronics Terms Of Use  and have read and understand the Privacy Policy and Cookie Policy.

Our website places cookies on your device to improve your experience and to improve our site. Read more about the cookies we use and how to disable them here. Cookies and tracking technologies may be used for marketing purposes.
By clicking “Accept”, you are consenting to placement of cookies on your device and to our use of tracking technologies. Click “Read More” below for more information and instructions on how to disable cookies and tracking technologies. While acceptance of cookies and tracking technologies is voluntary, disabling them may result in the website not working properly, and certain advertisements may be less relevant to you.
We respect your privacy. Read our privacy policy here