Files
Licht_Wecker/LichtWecker/ntp.ino
Christian Mittring 482d96d4fa [Added]: text
2018-03-31 17:41:30 +02:00

34 lines
1.2 KiB
C++

//Code to update time from the web
void update_time_from_web(){
//Serial.println(wifi_connected);
if (wifi_connected == true)
{
strDateTime dateTime;
// first parameter: Time zone in floating point (for India); second parameter: 1 for European summer time; 2 for US daylight saving time; 0 for no DST adjustment; (contributed by viewwer, not tested by me)
dateTime = NTPch.getNTPtime(1.0, 1);
// check dateTime.valid before using the returned time
// Use "setSendInterval" or "setRecvTimeout" if required
if(dateTime.valid){
NTPch.printDateTime(dateTime);
byte actualHour = dateTime.hour;
byte actualMinute = dateTime.minute;
byte actualsecond = dateTime.second;
int actualyear = dateTime.year;
byte actualMonth = dateTime.month;
byte actualday =dateTime.day;
byte actualdayofWeek = dateTime.dayofWeek;
if (actualMinute != m){
h = actualHour;
m = actualMinute;
s = actualsecond;
y = actualyear;
M = actualMonth;
d = actualday;
set_clock();
Serial.println("Time Updated!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
}
}
}