Table of Contents

Power #

What Are My Options to Power The Sleepy Pi 2? #

The Sleepy Pi is very flexible about power and can take power from many sources. However, to get the lowest power consumption you need to be aware of a couple of things:

  • 5V power should go to the USB connector on the Sleepy Pi 2. NOT the USB power on the Raspberry Pi OR the Power I/P Header on the Sleepy Pi
  • 5.5V – 30V should go into the Power I/P Header on the Sleepy Pi 2

If you put 5V into the Power I/P Header it will most likely work, BUT the regulator will work flat-out to ferry the 5V from the input straight to the output and not be able to go into a low power mode. Thus, you’ll find that the “Sleep” current is much higher than expected (10-20mA) whereas it should be 200uA or below.

Can I Use a 5V USB Rechargeable Battery? #

Yes, There seem to be a lot of these coming onto the market, typically used to recharge your mobile phone or tablet whilst on the go.

Plug these into the USB power socket on the Sleepy Pi 2 (NOT the Raspberry Pi) which will pipe the power straight through the regulator giving you the lowest possible power consumption. Don’t use the power jack as that is meant for voltages above 5V.

However be aware that some of these batteries have a minimum current draw; typically 50mA which they use to work out whether they are charging anything or not. If they think there’s no load, then they will switch off. When running the Sleepy Pi 2  with the Raspberry Pi asleep, the current draw will be well below this threshold and they will switch off, which means no power to the system and it will never wake.

Can I Measure the Battery Voltage? #

Yes, the main supply (not the 5V) is fed into an analogue input (ADC6) of the Arduino or A6 using the analogRead function. There is an Arduino Sleepy Pi 2 function that directly returns the scaled voltage reading:

float supplyVoltage = 0.0;

// Return the Supply Voltage in Volts
supplyVoltage = SleepyPi.supplyVoltage();

What Is The Power Consumption When The Raspberry Pi Is Switched Off? #

When the Raspberry Pi is switched off and the Arduino is in a low power sleep, it consumes around 180uA for a 12V input.

You will find that most bench multimeters are not able to measurement currents this low accurately. If you are into your low power, I recommend getting hold of one of Dave Jones’s uCurrent boxes which will turn your multimeter into a super accurate, low current measuring device.

How Long Will My Battery Last? #

This will depend on how often you power up the Raspberry Pi and for how long. For best battery life optimise the boot time and shutdown the Raspberry as soon as you can.

How Much Power Can I Draw From The Expansion Power? #

The Sleepy Pi 2 has 3 switched power outputs. These share power with the Raspberry Pi and Sleepy Pi 2 circuitry, but can supply to the outside world:

  • V+ (input from Power I/P Header) – 500mA
  • 5V – 500mA
  • 3V3 – 50mA

For the V+ and the 5V you can draw up to 500mA from either but not together i.e. the total draw shouldn’t exceed 500mA.

Note: The expansion power is separately switched from the Raspberry Pi power. Therefore, when you power up the Raspberry Pi you can choose if and when, to power up the expansion power. Similarly, you can leave the expansion powered when the Raspberry Pi is powered down.

How Do I Switch On The Expansion Power? #

The expansion power is normally off and needs to be switched on in software. The command:


will switch the power on and “false” will switch it off.

What Is The Power Jumper For? #

The optional power jumper is mainly used when developing Arduino code in the Raspberry Pi and uploading the code to the Sleepy Pi 2. Because the Arduino controls power to the Raspberry Pi, if you reset it, which occurs when you upload code, the Pi will be instantly powered off. Which is a bit of a chicken and egg situation! Adding in the power jumper forces the power to the Pi regardless of what the Arduino is doing and allows you to upload code.

Sleepy Pi 2 has both a hardware and software jumper – either can be used. The software jumper is described in more detail on the programming page.

Can I Power From A Solar Panel? #

There are a number of ways to do this, and all need 3 additional things:

  • Solar Panel (less than 30V)
  • Charge Controller
  • Battery

One way, is to use a setup commonly used for either camping or sailing. These can be found quite cheaply on eBay or similar and consist of e.g 10W solar panel intended for 12v use, 12V lead acid battery and 12V solar charge controller. Connect the output of the controller to the Vin input of the Sleepy Pi.

Operation #

Does The Raspberry Pi Have A Sleep Mode? #

No, the Raspberry Pi does not have any power management capabilities. It is in effect always on, even when you command the system to “halt”. This is one of the reasons why the Sleepy Pi was created, to allow a virtual low power mode to be realised on the Raspberry Pi.

How Does The Sleepy Pi Boot Up The Raspberry Pi? #

The Sleepy Pi 2 controls the power to the Raspberry Pi via a switch. When it “decides” that the Raspberry Pi is needed it will switch on the power to the Raspberry Pi and wait for it to boot.

There are various ways that you can set-up the Sleepy Pi 2 to switch on the Raspberry Pi. These could be:

  • At a timed interval
  • via a switch
  • An event on a digital I/O pin
  • A measured analogue value crossing a threshold

How Does The Sleepy Pi 2 Shutdown The Raspberry Pi? #

The Sleepy Pi 2 has two handshake lines available over the Raspberry Pi GPIO: 24 & 25. These can be used to co-ordinate a safe shutdown of the Operating System (OS) i.e. Raspbian. Once the Sleepy Pi 2 has detected that the OS is no longer running it will physically cut the power from the Raspberry Pi and go into a low power mode.

Sleepy Pi 2 also has an alternative / augmented way of detecting that it is safe to shutdown the Raspberry Pi. It has the ability to measure the current draw of the Raspberry Pi, which changes significantly after the Raspberry Pi has executed an OS shutdown using something like:

shutdown -h now

In certain applications, you can use this feature instead of using the handshake lines, thus freeing up additional GPIO pins. The example ButtonOnOff_CurrentRead shows how to do this.

Will The Sleepy Pi Corrupt My SD Card When Cutting The Power? #

No, if the handshake lines are used correctly, they ensure that the Operating System is in a safe state before cutting the power. This avoids power-loss SD card corruption.

How Fast Will The Raspberry Pi Boot-up Each Time? #

The speed of boot is dependent on many factors. These include:

  • Operating System, i.e. Raspbian, Bare metal etc
  • Boot media, i.e. SD card, USB stick etc
  • SD Card speed i.e. Class 10 or Class 4

As an example a plain vanilla Raspbian install running off a typical SD card will boot up in around 30 seconds.

There is an interesting series of articles in The MagPi magazine issues 15 and 20 entitled “Baking your own Raspberry Pi filling”. This describes a way of building your own linux image with only the parts you need. Boot times are slated to be region of 5 – 10 seconds.

This thread on the Raspberry Pi forums also contains some interesting information about how to optimise the boot process.

Can Sleepy Pi 2 Measure the Current Consumption of the Raspberry Pi? #

Yes, the Sleepy Pi 2 has a current measurement chip build into it that measures the Raspberry Pi current draw. The main design reason for this, was to provide an measurement of the Raspberry Pi state that was independent of any GPIO handshake lines. When a Raspberry Pi is “running” in draws far more current than it does when the OS has been commanded to shutdown with a

shutdown -h now

Depending on the model of Raspberry Pi, this OS shutdown current will vary from about 50 – 90mA. Therefore, you can set a current threshold of around 100mA and use that to trigger removing the power from the Raspberry Pi. To measure the current from the Arduino:

float supplyCurrent = 0.0;

// Return the Supply Current in mA
supplyCurrent = SleepyPi.rpiCurrent();

The example ButtonOnOff_CurrentRead shows an implementation of this.

Of course, you can also use this feature to log Raspberry Pi current in various states or boot up.

Software #

Can I Program The Arduino On The Sleepy Pi 2 With My Own Code? #

Absolutely, the Arduino processor (ATMEGA328P) is totally uncommitted and is available for use with your own code. There is a Sleepy Pi 2 Arduino library that allows your code easy access to standard Sleepy Pi 2 functions. This page gives an further notes on writing code on the Sleepy Pi 2 and also check the Sleepy Pi 2 Github page for the latest code and examples.

Can The Sleepy Pi 2 Run Standalone? #

Yes, the Sleepy Pi can run as a standalone, power optimised, Arduino style board. You can program the Arduino with either a direct link to a host computer, or you can temporarily connect it to a Raspberry pi.

Can You Talk to the Real-Time Clock (RTC) From The Raspberry Pi? #

Yes, you can talk to the Real-time clock from both the Raspberry Pi and the Arduino. The RTC on the Sleepy Pi uses the Linux driver for the PCF8523. See this page for more details.

Can I use an AVR-ISP to program the Sleepy Pi 2? #

The Sleepy Pi 2 is intended to be programmed via the bootloader and a serial link. However, if you want to burn another bootloader or want to flash code directly and dispense with the bootloader, then you can do this via an Atmel AVR programmer such as the AVR-ISP MkII.

There is a small programming header on the board that takes a special programming cable from Tag Connect – the TC2030-IDC-NL-10. This replaces the normal cable on the AVR-ISP. I’d also recommend getting the TC2030-CLIP to hold the cable in place.

Is the HAT Eeprom Programmed on Sleepy Pi 2? #

Yes, the HAT eeprom is programmed as standard in the Sleepy Pi 2 with the following information:
Product ID: 0x2785
Product Version: 0x014A
Vendor: “Spell Foundry”
Description: “Sleepy Pi 2 Power Management Board”

You can check that the board is present and view the product name from the command line with something like:

cd /proc/device-tree/hat
awk 1 product

which will print out “Sleepy Pi 2 Power Management Board” on the command line.

Is the Sleepy Pi 2 Compatible with the Arduino Watchdog? #

es, you can use the Arduino watchdog facilities and the bootloader that is used is compatible with the watchdog.

This watchdog can be demonstrated with the following code:

#include <avr/wdt.h>

void setup()
void loop()
 // the program is alive...for now. 
 while (1)
 ; // do nothing. the program will lockup here and the watchdog will reset it. 
 Serial.println("Can't get here");

Hardware #

What Things Do I Need to Consider for the Sleepy Pi 2 Arduino? #

The Arduino chip on the Sleepy Pi family is an ATMEGA328P and is similar to say, an Arduino Uno. However, it should be noted that the Sleepy Pi’s run at 8Mhz and have 3V3 GPIO’s whereas many Arduinos run at 16Mhz and has 5V GPIO (particularly the older ones). In most cases the clock speed is not an issue, but the GPIO voltages are important when porting an application from another Arduino setup.

What Are The Pinouts Of The Expansion Headers? #

The pinouts can be found hereNote that the Arduino on the Sleepy Pi is 3v3 the same as the GPIO on the Raspberry Pi. Do not connect 5V I/O to these pins.

What Voltage are the Sleepy Pi pins? #

The Arduino on the Sleepy Pi 2 is 3v3 the same as the GPIO on the Raspberry Pi. Do not connect 5V I/O to these pins.

Which RPi GPIO Pins Does The Sleepy Pi Use? #

The Sleepy Pi optionally uses the following Raspberry Pi GPIO lines:

  • GPIO 2: i2c-SDA – i2c bus available for communication with RTC and Arduino
  • GPIO 3: i2c-SCL – i2c bus available for communication with RTC and Arduino
  • GPIO 14: Serial RXD – used for programming the Arduino
  • GPIO 15: Serial TXD – used for programming the Arduino
  • GPIO 22: Arduino Reset line – used for programming
  • GPIO 23: RTC Alarm – Active low RTC alarm output
  • GPIO 24: General purpose / Handshake – Command Pi Shutdown
  • GPIO 25: General purpose / Handshake – Pi is Running

Most of these lines are not exclusively for use with the Sleepy Pi 2 and can be used for other things if required. Further information can be found on this page.

Can Sleepy Pi Be Used With Other Raspberry Pi Expansion Boards? #

Yes, but you need to check compatibility in terms of which GPIO pins are used. The Sleepy Pi 2 incorporates a stacking header on the Raspberry Pi GPIO which can be used with other expansion boards.

Which Battery Does the Real-Time Clock (RTC) Use? #

The RTC uses a CR1620  or CR1632  (best) coin cell. Due to legal restrictions with shipping Lithium batteries, this is not supplied with the Sleepy Pi 2.

Do I Need the Real-Time Clock Battery (RTC) Before I Run the Sleepy Pi? #

No. The RTC battery will keep the time if you disconnect the main power supply from the board, but if you keep your main power supply to connected after you have set the clock, then the main supply will keep the clock running even when the Sleepy Pi is asleep and the Raspberry Pi powered down. In these circumstances you don’t need the battery backup.

Applications #

Can I Use Sleepy Pi 2 in a Car? #

To power a Sleepy Pi 2 / Raspberry Pi setup in a car, connect a power feed from the car battery to the Power I/P Header of the Sleepy Pi (this is good up to 30V). This feed should not go off when the ignition is off – it needs to remain so that you can safely shutdown the Raspberry Pi after you stop and then the Sleepy Pi will go into a low power mode to prevent battery drain.

In most cases to effectively shut the system down, you need to detect that the ignition is off. For this you need a battery / ignition feed that goes low / off when the ignition is off that you can feed into a Sleepy Pi GPIO. The key here is that, this will most likely be at 12V when the ignition is on and needs to be dropped down to 3v3 for the Sleepy Pi GPIO. The easiest way to do this, is via a voltage divider:

Car 12V Divider
Car 12V Divider

It’s worth noting that car batteries are seldom only 12V all the time and will often go a lot higher, so it’s worth calculating the divider to cope with voltages such as 14.4V. The resultant voltages into the Arduino GPIO needs to be above about 2V to register as a “high”, so there’s quite a range. In the example divider I’ve used 36k and 10k, but any values that give a rough 4:1 could be used. It’s also worth popping in a 3V3 zener (eg. BZX79-C3V3,113, just to clip the voltage to 3V3 in case it does go too high. You can make up this circuit on a piece of veroboard or on a prototyping blanket with appropriate headers (e.g.standard).

Troubleshooting #

I Can’t Seem to Access the Real-Time Clock From the Raspberry Pi #

If you are trying to access the Real-Time Clock from the Raspberry Pi and you get an error such as:

Error: Could not open file `/dev/i2c-1′ or `/dev/i2c/1′: No such file or directory

then it might be that you haven’t enabled the i2c bus from the Raspi-config utility.

From a Terminal type:

sudo raspi-config

From the menu select “Advanced Options” and then “A7 i2c” and click “Yes”to enabling the interface.

The Raspberry Pi Boots up Once and Doesn’t Boot Again #

You can often see this when running one of the examples such as WakeUpPiOnAlarm. The culprit is generally the Raspberry Pi and not the Sleepy Pi 2. As the Raspberry Pi has access to the RTC, it can sometimes talk to the RTC at boot and reset the RTC, hence you don’t get the subsequent boots.

You can check this by running the Sleepy Pi 2 standalone off the Raspberry Pi and setting the wake time to something like 10 seconds. You should see the LED’s flash every 10 seconds.

Another way to check is to install a fresh copy of Raspbian with no configuration and it shouldn’t mess with the clock.

The solution is to root out any code that might be taking to the clock.

1 thought on “FAQ”

  1. Hi!
    First, your product was a huge asset to the project I’m working on where I’m trying save as much power as possible.
    I ran into an issue where the sleepy pi will not fully cut power to the pi. Pi remains in the 0.11 amp idle mode instead of the lower power mode. The software jumpers seem like they’re working with the ability to upload code to the arduino without restart but then when the arduino code begins to run(jumper still not switched off) it was force pi into a shutdown anyway as scheduled.
    I have an audio output from pi 3.5mm to an amp powered from the 5v and ground gpio pins, a USB mic, and 2 tb USB hdd. A python script for playback and record of signals also runs automatically on start up. I have tried cycling the software jumper a few times normally and with sudo but no luck there. The alarm works fine turns on and off as requested but lower power state is not. It had worked at one point when I was first installing everything, but something changed between then and now to cause the problem.
    Any help or ideas would be greatly appreciated.

    Thank you!


Leave a Reply

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top