[Added]: EEPROM writing summer/winter alarm time saved [Added]: WiFi support [Added]: Time setting over NTP every hour
33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|