Hi all,
I can't seem to be able to get the time from inside an interrupt.
timeClient.update(); //update the time
unsigned long epochTime = timeClient.getEpochTime(); //get the epoch time
int currentHour = timeClient.getHours(); //put the current hours into a variable
int currentMinute = timeClient.getMinutes(); //put the current minutes into a variable
int currentSecond = timeClient.getSeconds(); //put the current seconds into a variable
struct tm *ptm = gmtime ((time_t *)&epochTime); //Get a time structure
int currentDay = ptm->tm_mday; //put the current day into a variable
int currentMonth = ptm->tm_mon + 1; //put the current month into a variable and add 1 month to it
int currentYear = ptm->tm_year + 1900; //put the current year into a variable and add "1900" to it
/* PUT THE CURRENT YEAR, MONTH, DAY, HOURS, MINUTES, SECONDS INTO ONE STRING */
String currentTimeDate = (String(currentYear) + "-" + toStringAddZero(currentMonth) + "-" + toStringAddZero(currentDay)) + ("T") + (toStringAddZero(currentHour) + ":" + toStringAddZero(currentMinute) + ":" + toStringAddZero(currentSecond)) + ("Z");
currentTimeDate.toCharArray(receivedTimeDate, 25); //convert the String "receivedTime" to a character array
strcpy(newPost, receivedTimeDate); //make the newPost variable equal the current time and date
Serial.println(newPost);
Is it not possible because it takes to long or something?
Thanks,
Zeb