I have this code and it works fine. When I set the alarms I can see them go off when the time is reached:
#include <Wire.h>
#include "RTClib.h"
#include <Time.h>
#include <TimeAlarms.h>
RTC_DS1307 rtc;
void setup(){
Serial.begin(9600);
Wire.begin();
rtc.begin();
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
//rtc.adjust(DateTime(__DATE__, __TIME__));
Serial.print("time set auto");
}
//setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011
DateTime now = rtc.now();
setTime(now.hour(), now.minute(), now.second(), now.month(), now.day(), now.year());
// create the alarms
Alarm.alarmRepeat(9,15,0, MorningAlarm); // 8:00am every day
Alarm.alarmRepeat(9,16,0, EveningAlarm); // 4:00pm every day
Alarm.alarmRepeat(9,17,0, EveningAlarm); // 1:00am every day
//Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm); // 8:30:30 every Saturday
//Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds
//Alarm.timerOnce(10, OnceOnly); // called once after 10 seconds
Serial.print("Alarms set!");
}
void loop(){
digitalClockDisplay();
Alarm.delay(1000); // wait one second between clock display
}
// functions to be called when an alarm triggers:
void MorningAlarm(){
Serial.println("Alarm: - read CO/V1 & post to web");
}
void EveningAlarm(){
Serial.println("Alarm: - read CO/V2 & post to web");
}
void DawnAlarm(){
Serial.println("Alarm: - read CO/V & post to web");
}
void WeeklyAlarm(){
Serial.println("Alarm: - its Monday Morning");
}
void ExplicitAlarm(){
Serial.println("Alarm: - this triggers only at the given date and time");
}
void Repeats(){
Serial.println("15 second timer");
}
void OnceOnly(){
Serial.println("This timer only triggers once");
}
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);
}
But I dont want to see the time on the monitor, I actually just want to see the alarms. So I comment out the 2 lines in the loop method that call:
digitalClockDisplay();
Alarm.delay(1000);
But when I do this, the alarm methods do not get logged.
Why?