Hi all!
I’m using two DS3232 RTC with two Arduino boards. But i want to synchronize both of RTC.
So what i think is sync the PC time everytime when i burn the sketch.
Here’s the code of I’m using now. Always need to set by myself, so it won’t be accurate.
void setup() {
Serial.begin( 9600 );
while( !Serial ){;}
xbeeSerial.begin( 9600 );
xbee.setSerial( xbeeSerial );
/*setTime(14, 56, 59, 13, 2, 2017); //set the time at first time and then annotation it
RTC.set(now());*/
setSyncProvider(RTC.get);
Serial << "RTC Sync";
if (timeStatus() != timeSet){
Serial << " FAIL!";
}
Serial << endl;
printDateTime( RTC.get() );
Serial << " --> Current RTC time." << endl;
//Disable the default square wave of the SQW pin.
RTC.squareWave(SQWAVE_NONE);
//Attach an interrupt on the falling of the SQW pin.
//digitalWrite(SQW_PIN, HIGH); //redundant with the following line
pinMode(SQW_PIN, INPUT_PULLUP);
attachInterrupt(INT0, alarmIsr, CHANGE);
//Set an alarm at every 20th second of every minute.
RTC.setAlarm(ALM1_MATCH_SECONDS, 30, 0, 0, 1); //daydate parameter should be between 1 and 7
RTC.alarm(ALARM_1); //ensure RTC interrupt flag is cleared
RTC.alarmInterrupt(ALARM_1, true);
//Set an alarm every minute.
RTC.setAlarm(ALM2_EVERY_MINUTE, 0, 0, 0, 1); //daydate parameter should be between 1 and 7
RTC.alarm(ALARM_2); //ensure RTC interrupt flag is cleared
RTC.alarmInterrupt(ALARM_2, true);
}