Timer Alarm Issue

Hi all,

New to the forum. I have played around with Arduino, not really from a development point of view, but more in an integration point of view. I tend to copy projects, modify code etc. I think that this needs to end, as I have numerous ideas but not learning code is holding me back…

So I started putting together a multi-zone timer with a relay to power my home Aquaponics system.
I initially tried to time the system using delays. I very quickly learnt that delays are not sufficient and limiting… I started looking for alternatives, leading to the Time and TimeAlarms libraries…

I wrote Code and tested it, it worked… for the first few alarms. Then the alarms just stop.

I have toyed around with the delay timer, the interval of the alarms etc. but i can not get the code to run past the one alarm… I am wondering if it is linked to an issue with the libraries?

Have a look at my code:


  • This code is used as a multi zone timer to switch the pump of my Aquaponics system on and off
  • this happens every two hours for 15 minutes during the day. At night time the system is dormant.


#include <Time.h>
#include <TimeAlarms.h>

void setup()
setTime(16,22,00,19,9,15); // set time 16:22 19/09/2015

// create the alarms or trigger points

// The times dont match the comments, as i wanted to check that it runs throught all the alarms
// before I set it to 24 hours… Could not wait 12 hours to see whether all the alarms work…

Alarm.alarmRepeat(16,22,05,Run); // 6:00am every day
Alarm.alarmRepeat(16,22,10,Stop); // 6:15am every day
Alarm.alarmRepeat(16,23,00,Run); // 8:00am every day
Alarm.alarmRepeat(16,23,05,Stop); // 8:15am every day
Alarm.alarmRepeat(16,24,00,Run); // 10:00am every day
Alarm.alarmRepeat(16,24,05,Stop); // 10:15am every day
Alarm.alarmRepeat(16,25,00,Run); // << from here the code gets stuck I have tried commenting out the delay, adjusting the intervals of the alarms etc. Nothing works…
// the timer runs past this point in the serial monitor, but none of the alarms trigger…

Alarm.alarmRepeat(16,25,05,Stop); // 12:15pm every day
Alarm.alarmRepeat(16,26,00,Run); // 2:00pm every day
Alarm.alarmRepeat(16,26,05,Stop); // 2:15pm every day
Alarm.alarmRepeat(16,27,00,Run); // 4:00pm every day
Alarm.alarmRepeat(16,27,05,Stop); // 4:15pm every day
Alarm.alarmRepeat(16,28,00,Run); // 6:00pm every day
Alarm.alarmRepeat(16,28,05,Stop); // 6:15pm every day

pinMode(12,OUTPUT); // set pin 12 as an output
pinMode(13,OUTPUT); // set pin 13 as an output


void loop(){
Alarm.delay(1000); // wait one second between clock display

// functions to be called when an alarm triggers:
void Run(){
// Serial.println(“POW: - turn pump on”);
digitalWrite(12, HIGH); // turn the Relay on
digitalWrite(13, HIGH); // LED indication

void Stop(){
// Serial.println(“POW: - turn pump off”);
digitalWrite(12, LOW); // turn the Relay off
digitalWrite(13, LOW); // LED indication

void digitalClockDisplay()
// digital clock display of the time

void printDigits(int digits)
if(digits < 10)

You have tried to set too many alarms with the default library settings. From TimeAlarms readme.txt

Q: How many alarms can be created?
A: Up to six alarms can be scheduled.
The number of alarms can be changed in the TimeAlarms header file (set by the constant dtNBR_ALARMS,
note that the RAM used equals dtNBR_ALARMS * 11)

onceOnly Alarms and Timers are freed when they are triggered so another onceOnly alarm can be set to trigger again.
There is no limit to the number of times a onceOnly alarm can be reset.

The following fragment gives one example of how a timerOnce task can be rescheduled:
Alarm.timerOnce(random(10), randomTimer); // trigger after random number of seconds

void randomTimer(){
int period = random(2,10); // get a new random period
Alarm.timerOnce(period, randomTimer); // trigger for another random period


It worked... the old story about reading manuals applies I guess... :o

I didi learn something out of the exercise however. I have a better understanding of how to edit a library.

Thanks for the lesson. :slight_smile: