Hi,
I am using Arduino to control light conditions for a project. The precision of time is very critical and I use the RTC in the code. The clock did not switch to daylight saving time this weekend, but the computer clock did. I re-started the computer just in case but it didn't fix the issue. And I do not understand why. Shouldn't it synchronize with the computer? I read different posts about time adjustements but I don't know why the pc and arduino are not synchronized. And I don't have time to make some tests after code modifications as I need it to work correctly for the project. I am in the Pacific Time zone and here is the code I use
#include <Wire.h>
#include <Chronodot.h>
#include <Time.h>
#include <TimeAlarms.h>
Chronodot RTC;
time_t syncProvider()
{
return RTC.now().unixtime();
}
void setup()
{
Serial.begin(9600);
Serial.println("Initializing Chronodot.");
Wire.begin();
RTC.begin();
setSyncProvider(syncProvider);
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(2014,3,10,5,59,0));
}
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
Alarm.alarmRepeat(6,0,0, MorningAlarm);
Alarm.alarmRepeat(18,0,0, EveningAlarm);
}
void loop(){
digitalClockDisplay();
Alarm.delay(1000);
int irLed = 9;
int redLed = 10;
analogWrite(irLed, 100);
analogWrite(redLed, 8);
}
void MorningAlarm(){
int whiteLed = 11;
analogWrite(whiteLed, 150);
delay(1000);
Serial.println("LIGHT ON");
}
void EveningAlarm(){
int whiteLed = 11;
analogWrite(whiteLed, 0);
delay(1000);
Serial.println("LIGHT OFF");
}
void digitalClockDisplay()
{
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
if(now.month() < 10) Serial.print("0");
Serial.print(now.month(), DEC);
Serial.print('/');
if(now.day() < 10) Serial.print("0");
Serial.print(now.day(), DEC);
Serial.print(' ');
if(now.hour() < 10) Serial.print("0");
Serial.print(now.hour(), DEC);
Serial.print(':');
if(now.minute() < 10) Serial.print("0");
Serial.print(now.minute(), DEC);
Serial.print(':');
if(now.second() < 10) Serial.print("0");
Serial.print(now.second(), DEC);
Serial.println();
delay(5000);
} // END
I am not very familiar with Arduino yet, I just started to use it a few weeks ago. Any explaination/suggestion? Thanks for your help,
Audrey