How to make the Arduino and RTC work with the Daylight saving time?
hi,
i using arduino control light conditions project. precision of time critical , use rtc in code. clock did not switch daylight saving time weekend, computer clock did. re-started computer in case didn't fix issue. , not understand why. shouldn't synchronize computer? read different posts time adjustements don't know why pc , arduino not synchronized. , don't have time make tests after code modifications need work correctly project. in pacific time zone , here code 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 not running!"); // following line sets rtc date & time sketch compiled
rtc.adjust(datetime(2014,3,10,5,59,0));
}
if(timestatus()!= timeset)
serial.println("unable sync rtc");
else
serial.println("rtc has set 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, ;
}
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 = 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 not familiar arduino yet, started use few weeks ago. explaination/suggestion? help,
audrey
don't forget code tags.
what rtc using? possible doesn't account daylight savings time. or, since decided annoying it, accounts next weekend.
what rtc using? possible doesn't account daylight savings time. or, since decided annoying it, accounts next weekend.
Arduino Forum > Using Arduino > Project Guidance > How to make the Arduino and RTC work with the Daylight saving time?
arduino
Comments
Post a Comment