Alarm event without RTC ok, with RTC no alarm. Not rocket science I'm sure.

I had created a daily alarm example before my DS1307 RTC module arrived that operated perfectly. Then tested my RTC alone with success.

Now I'm trying to add the RTC to my working daily alarm sketch. My problem is, the daily alarm event does not fire (with RTC time). After searching for examples, and reading other users RTC questions, I think my Arduino clock is not synchronized with my RTC, and my code is alarming reference the Auduino time.

So, the most accurate time keeping (alarm) method isn't an initial sync with the Arduino, it would be the alarm time being checked against the RTC time. What would be the lowest-overhead way of checking RTC time for the alarm? Nothing I have tried works. Latest code below.

// Daily alarm test using a DS1307 RTC
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal_I2C.h>
#include <Time.h>
#include <TimeAlarms.h>
LiquidCrystal_I2C lcd(0x27,20,4); 
RTC_DS1307 RTC;
 
void setup () {
 //setTime(12,19,0,06,04,13); // Old set time, pre RTC
 RTC.begin();
 Alarm.alarmRepeat(11,50,0, Alarm1);  // every day 11:50 Hours
 lcd.init(); 
 lcd.backlight();
 lcd.setCursor(0, 0);
 pinMode(13, OUTPUT); 
  //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__));
  }
 
void loop () {
 digitalClockDisplay();
 Alarm.delay(1000); 
}

void digitalClockDisplay()
{
  DateTime now = RTC.now();
  char buf[20];
  //sprintf(buf, "%02d:%02d:%02d %02d/%02d/%4d", now.hour(), now.minute(), now.second(), now.month(), now.day(), now.year());
  sprintf(buf, "%02d:%02d  %02d/%02d/%4d", now.hour(), now.minute(), now.month(), now.day(), now.year());
  lcd.print(buf);
 lcd.setCursor(0,0);
}  

void Alarm1(){
  digitalWrite(13, HIGH);  //alarm test output
  delay(5000);
  digitalWrite(13, LOW); }

Someone may have an answer to your question the way you asked it, but why not just periodically sync the Arduino clock to the RTC? (Granted there is argument about the accuracy of the RTC in question...)

I don't know if any of the peeps at Evil Mad Scientist read this forum, but their bulbdial clock uses an RTC optionally (meaning it functions with and without it). The project is opensource, so you may be able to learn things if you read through their code. See Bulbdial - Evil Mad Scientist Wiki for all their development files. (I plan on sitting down with their code at some point to help me grok charlieplexing...)

I like the periodic sync suggestion. I could just sync daily when my alarm triggers.

The problem is every sync command I've tried fails to compile, because of my incorrect syntax .

Like:

void setup () {
 RTC.begin();
 DateTime now = RTC.now(); 
 setTime(now.hour(), now.minute(), now.month(), now.day(), now.year()); // Old set time, pre RTC

I'm really having trouble finding a syntax example of the setTime command for Time.h.

Does this page help ?

Does this page help ?
Understanding the Code | DS1307 Real Time Clock Breakout Board Kit | Adafruit Learning System

I began my RTC tests using the above code, but it does not Sync the Arduino time to the RTC.

I began my RTC tests using the above code, but it does not Sync the Arduino time to the RTC.

Neither does the code in Reply #2.