So I made one change. In the end of setup I put WiFi.disconnect(); and in drawCurrentTime() class I make little update, in the beginning i connect to WiFi and in the end I disconnect from WiFi and it is work.
void drawCurrentTime() {
WiFi.begin(ssid, password);
Serial.print("Pripajam sa na WiFi...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
return;
}
char timeString[9];
strftime(timeString, sizeof(timeString), "%H:%M:%S", &timeinfo);
char dateString[11];
strftime(dateString, sizeof(dateString), "%d.%m.%Y", &timeinfo);
int textWidthTime = strlen(timeString) * 18;
int textWidthDate = strlen(dateString) * 18;
int xPosTime = (tft.width() - textWidthTime) / 2;
int xPosDate = (tft.width() - textWidthDate) / 2;
int yPosTime = 160;
int yPosDate = 190;
tft.fillRect(xPosTime, yPosTime, textWidthTime, 24, ILI9341_WHITE);
tft.setCursor(xPosTime, yPosTime);
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(3);
tft.print(timeString);
Serial.println(timeString);
tft.fillRect(xPosDate, yPosDate, textWidthDate, 24, ILI9341_WHITE);
tft.setCursor(xPosDate, yPosDate);
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(3);
tft.print(dateString);
Serial.println(dateString);
WiFi.disconnect();
}
Now I am able to sending data true ESPNOW and update Day and time from NTP server. I still need to make som updates because it is not smoot but it's work. Here is output from serial monitor:
Pripajam sa na WiFi....18:03:25
04.09.2025
Pripajam sa na WiFi....18:03:26
04.09.2025
Pripajam sa na WiFi....18:03:27
04.09.2025
Sprava prisla od: 14:08:08:a4:fb:ec
Pripajam sa na WiFi....18:03:28
04.09.2025
Pripajam sa na WiFi....18:03:29
04.09.2025