I'm have a Sleepy Pi and am having extreme difficulties trying to program a wake/sleep cycle. Sleepy Pi is an Arduino board with a RTC. My ultimate goal is for a time-lapse project.

I have the Raspberry Pi programmed and operational to take a picture on boot, my trouble is coming from trying to program the Arduino board to actually do it's job.

I would like the Sleepy Pi to wake at 8am, 9am, 10am, ..., 3pm, 4pm, and 5pm, each for 5 minutes, then go back to sleep. I've been working with the SleepyPi, Time, TimeAlarms, LowPower, and DS1374RTC libraries in the Arduino IDE. However, I cannot find any examples on how to put everything to sleep until a specific time comes around. Also, in several of my tests, it seems that the clock actually stops when the Sleepy Pi is asleep!

Here is what I've been working with (and this is non-working). It's probably completely wrong.

#include "SleepyPi.h"
#include <Time.h>
#include <TimeAlarms.h>
#include <LowPower.h>
#include <DS1374RTC.h>
#include <Wire.h>

// Set the status LED pin constant
const int LED_PIN = 13;

void setup()
  // Configure "Standard" LED pin
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN,LOW); // Switch off LED

  // Start with the Pi off

  // Set our communication rate

  // Set up our boot times
  Alarm.alarmRepeat(8,0,0, startPiUp);
  Alarm.alarmRepeat(9,0,0, startPiUp);
  Alarm.alarmRepeat(10,0,0, startPiUp);
  Alarm.alarmRepeat(11,0,0, startPiUp);
  Alarm.alarmRepeat(12,0,0, startPiUp);
  Alarm.alarmRepeat(13,0,0, startPiUp);
  Alarm.alarmRepeat(14,0,0, startPiUp);
  Alarm.alarmRepeat(15,0,0, startPiUp);
  Alarm.alarmRepeat(16,0,0, startPiUp);
  Alarm.alarmRepeat(17,0,0, startPiUp);

void loop()
  // Tick the alarm clock every second

  // Cut Power if we detect Pi not running
  bool pi_running;
  pi_running = SleepyPi.checkPiStatus(true);
  if(pi_running == false){
    SleepyPi.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);

  // Flash the LED

// Function to tell the Pi to boot up
void startPiUp()
  // Turn the Pi on

  // Turn on the LED to signal we're here

  // Keep the Pi on for 5 minutes

  // Start a shutdown

I also cannot find a good way to "debug" things. I've been trying to use the LED flashes as a "I'm here" echo, but have been unsuccessful with this as well.

NOTE: I do not have enough reputation on this site yet to create new tags. Someone with over 150, please tag this with and . Thank you.

  • I would have thought you would use this device to wake the Pi, then have that do it's job & shutdown -h now, & use the checkPiStatus command to watch for that - it should save more battery than a set 5 minutes. You will then have the Pi status LEDs to se that power up/down, and can use the SleepyPi to monitor itself - Does it have a serial comms capability? Feb 2 '15 at 17:10
  • You're probably right, but I'm not even that far. I'm trying to get the device to just wake the Pi up on a set schedule using the RTC, and I cannot even get that part working. There seems to be no actual documentation about how to use the TimeAlarms library, and it seems like when I program the Arduino and the try to start the cycle, the RTC doesn't continue ticking. Feb 2 '15 at 18:10
  • I have just received my Sleepy Pi and am having trouble programming it to use for a timelapse controller for my Rpi. I just wondered if you have got any further with yours? I'm with you on the desire to set specific times in the day to fire up my Pi - all the code samples I've come across elsewhere just put the Pi to sleep for a nominated period. There doesn't seem to be any decent documentation to support the Sleepy Pi code examples so I'm struggling to find my way forward with this
    – user8338
    Apr 8 '15 at 15:52

I have the same problem and I just saw that they fixed a bug in a library used by SleepyPi

More specific, the RTC library file DS1374RTC.cpp reads since March: '2015
(which is after the question was asked)

V1_0 - 10 Aug 2013 - Initial release
V1_1 - 11 Mar 2015 - Mod: Added "ackAlarm" and "ackRTCOSF" functions to aid Alarm use
- Bugfix: Changed the way the "SetAlarm(tmElements_t &tm)" was updating the Alarm time. It wasn't mapping correctly

They also added a new example to wake up the Pi: WakePeriodicallySimple.ino


Same probem. Kludgy solution ... but it works

Get the startstopsimple skectch from GitHub.

Set the period to 60 minutes Set the timeout to whatever makes sense for you

Modify the setup function to loop until the clock says the minute is 59. something like

   delay (100);
} while !(minute() == 59);

Then it will go into the loop function. It will be asleep. So it will then do a whole "empty" loop and sync after that, dunno how one gets rid of first the empty loop. But it works .... :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.