So I'm using the NTP on the arduino. I'm going to only ping the NTP once a day to truth up the clock. however the rest of the time I want just to use incrementing the minute and hour via ints.

I'm using a TFT display..so here is my issue.

The getLocaltime of the NTP seems to return a struct of characters. Which I'm able to push out to the screen every miniute. What I'd like to do is be able to get the NTP once a day and then just use the ESP32 clock to increment the minutes every 60000ms and then the hour when the min goes from 59 to 00....

I'm new to C and am not sure how to take the char to int and then increment it and then back to char to send to the display.

any help appreciated.

I think I determined an answer which seems to beworking OK. timeHour and timeMin are set from the NTP library in a previous Setup area.

if (currentMillis - timeMillisincrement > 60000){
timeMillisincrement = currentMillis;
int hh,mm; 
sscanf(timeHour, "%02d", &hh);
sscanf(timeMin, "%02d", &mm);

if(mm == 59){
  mm = 0;
  if(hh == 23){
    hh = 0;
    hh = hh + 1;
  mm = mm + 1;


gslc_ElemSetTxtStr(&m_gui, m_pElemOutTxt1_3, timeHour);
gslc_ElemSetTxtStr(&m_gui, m_pElemOutTxt5, timeMin);
  • Can you please share your code also. You can use typeCast to change it from char to int and vice versa – Maaz Sk Dec 24 '20 at 4:27
  • What do you mean by “seems to return a struct of characters”? Please, share the definition of the struct, or at least a link to the NTP library you are using. Also, you may want to take a look at the RTC_Millis class from RTClib. – Edgar Bonet Dec 24 '20 at 10:13
  • did you se the ESP32 SimpleTime example? – Juraj Dec 24 '20 at 10:46
  • 1
    Why would you want to do that? A char is an 8-bit integer. Though, I admit, the name is a bit confusing. – Gerben Dec 24 '20 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.