I want to be able to set the time for triggering certain events in my ESP8266.
Currently I am using millis to set an interval as a number of minutes and then I am checking in loop() for millis()-lasttime > interval to execute some event function.
But I want the events to happen on even minutes in time, millis depend on when the ESP was reset...
So I have added the NTP library and I have successfully been able to read back the time from the ESP:
case '3': //Return current NTP time
#ifdef USE_NTP_TIME
TimeMsg = NTP.getTimeDateString ();
strcpy(msg, "Current time= ");
strcat(msg, TimeMsg.c_str());
#else
strcpy(msg, "NTP time undefined");
#endif
ReplyCmd(msg, strlen(msg));
break;
The output on my console is:
Current time = 2018-12-08 13:44:08
How can I use this in loop to activate my event?
For example if I could get the current time in seconds from midnight I could use that...
But how?