Is There anyway to clear the previous alarm?

is there anyway to clear the previous alarms that was already set?
max alarms i can input is 6 without changing the " #define dtNBR_ALARMS 6 " in TimeAlarms.h.

the code shows that in the afterNoonAlarm2(), the time is being reset to the initial time i set during setup.
after repeating the alarms, some of them won’t work anymore. is there a way to clear the alarms?

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


void setup()
{
  Serial.begin(9600);
  setTime(17,30,31,1,1,11);
  pinMode(13, OUTPUT);
  Alarm.alarmRepeat(17,30,33, afterNoonAlarm);  
  Alarm.alarmRepeat(17,30,36, afterNoonAlarm);   
  Alarm.alarmRepeat(17,30,39, afterNoonAlarm2);  
}

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

// functions to be called when an alarm triggers:
void afterNoonAlarm(){
  Serial.println("Alarm: - turn lights on");  
  digitalWrite(13, HIGH);  
  Alarm.timerOnce(2, offIt); 
}

// functions to be called when an alarm triggers:
void afterNoonAlarm2(){
  setTime(17,30,31,1,1,11);
  Alarm.alarmRepeat(17,30,33, afterNoonAlarm);  
  Alarm.alarmRepeat(17,30,36, afterNoonAlarm);   
  Alarm.alarmRepeat(17,30,39, afterNoonAlarm2); 
}

void offIt(){
  Serial.println("Alarm: - turn lights off");  
  digitalWrite(13, LOW);  
}

void digitalClockDisplay()
{
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.println(); 
}

void printDigits(int digits)
{
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

the log shows that after repeating the time and resetting the alarm, one of the function wasn’t called.(attached picture)

help please. Thank You so much

// functions to be called when an alarm triggers:
void afterNoonAlarm2(){
  setTime(17,30,31,1,1,11);
  Alarm.alarmRepeat(17,30,33, afterNoonAlarm);  
  Alarm.alarmRepeat(17,30,36, afterNoonAlarm);   
  Alarm.alarmRepeat(17,30,39, afterNoonAlarm2); 
}

Have you written the function like this to test something or do you intend to use it like this for real ? When the function is called you already have repeat alarms set for those times that call exactly the same functions so you will have an ever increasing number of repeat alarms set to call the same functions at the same time. Is that what you want ?

I have written the that kind of function to test something. That when i set the clock again via android via curl.. Alarms are not ticking of anymore, because the alarms has its maximum of 6 without changing the TimeAlarms.h... ahhmm is there anyway to delete previous alarms? or override it?

thanks sir for the reply.

Hi, I am having the same problem. I set an alarm and want to remove it before it triggers. Is there a way to remove or delete a previously alarm set?

Thanks for your help. Thomas

Look in the documentation for the lib, if there is it should be listed. Or try the .h file

Mark

taich:
Hi,
I am having the same problem. I set an alarm and want to remove it before it triggers.
Is there a way to remove or delete a previously alarm set?

Thanks for your help.
Thomas

From the TimeAlarms readme

disable( ID); - prevent the alarm associated with the given ID from triggering

When set Timer get their AlarmID_t like this:

AlarmID_t aTimer = Alarm.timerRepeat(10, RepeatTest);

and then when you want to unschedule just disable/free (I am not test what is happening if you not disable before free it but for safe just disable and free) like this:

Alarm.disable(aTimer); Alarm.free(aTimer);

1 Like