For disclosure, this is my first week with Arduino (and C).
My project is an E-Ink screen printer, done from GxEPD2WiFiExample. I'm generating an image using Java, which has current time and some other stuff (mostly temperature sensors, for which I am yet to write mqtt infrastructure and relevant service ecosystem).
The image upload takes 15 seconds, so the best time to make the request to the server (server is adjusted to return an image with +1 minute) is somewhere on the 40th second.
So I'm looking for a working (and simple!) solution to have the actual time.
...
#include "NTPClient.h" (I know that \" should be used for local libraries/files, but this is how the example provided it)
#include "WiFiUdp.h"
...
uint8_t utcOffsetInSeconds = 3*60*60;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);
...
void setup() {
...
timeClient.begin();
Serial.println("Setup finished");
}
...
void loop() {
Serial.println("Updating time");
timeClient.update();
// Serial.print(daysOfTheWeek[timeClient.getDay()]);
// Serial.print(", ");
Serial.print(timeClient.getHours());
Serial.print(":");
Serial.print(timeClient.getMinutes());
Serial.print(":");
Serial.println(timeClient.getSeconds());
...
}
Thank you. I believe I stumbled upon your stripped version somewhere here on the forum. It was quite useful (I thought that maybe I missed something when I was trying the Editor`s cut. But one thing is missing in all of the examples I have stumbled upon (except the one from above) - printing that the ntp is not yet resolved(although I have quite a few years of professional Java development, C and Arduino with their lack of documentation was a challenge to get through).