Go Down

Topic: New library for Scheduling Time Based Tasks (Read 61343 times) previous topic - next topic


I haven't used chronodot but if its DS1307 compatible then it should work with the DS1307 library included in the Time library download.

See if the TimeRTC example sketch in the download works with Chronodot.

After you have the TimeRTC sketch working with Chronodot  then perhaps something like this would get that going with TimeAlarms

Code: [Select]
#include "Wire.h"
#include <Time.h>
#include <TimeAlarms.h>
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t

int ledPin =  02;    // LED connected to digital pin 2

void setup()
 byte second, minute, hour;
 pinMode(ledPin, OUTPUT);

 setSyncProvider(RTC.get);   // the function to get the time from the RTC
 if(timeStatus()!= timeSet)
    Serial.println("Unable to sync with the RTC");
    Serial.println("RTC has set the system time");  

 Alarm.alarmRepeat(0,05,20, IlluminationOn);  // 8:30am every day
 Alarm.alarmRepeat(0,15,20,IlluminationOff);  // 5:45pm every day


void  loop()
 Alarm.delay(1000); // service the alarm timers once per second

void IlluminationOn()
 digitalWrite(ledPin, HIGH);   // set the LED on

void IlluminationOff()
 digitalWrite(ledPin, LOW);    // set the LED off  



That worked quite well! I just had to switch things from secs, minutes, hours(in my code)  to hours,minutes, and seconds as this is how the DS1307 code reads the RTC.

Yes, the '1307 code appears to be compatible with the DS3231.

Thanks again, I'm off to do some more coding!


Go Up