#include <WiFi.h> // esp32
#include <GyverNTP.h> //
GyverNTP ntp(3); //3-й часовой пояс, опрос NTP 1 раз в сутки
char cstr[60] = "";
char cstr_time[20] = "";
void setup() {
Serial.begin(115200);
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) delay(100);
Serial.println("Connected");
ntp.begin();
while(!ntp.synced()) {
ntp.tick();
delay(500);
}
//String myString = ntp.toString();
ntp.toString().toCharArray(cstr_time, 20);
strcat(cstr, cstr_time);
strcat(cstr, "\n");
Serial.println(cstr);
}
void loop() {
if (ntp.tick()) {
char cint[3];
uint16_t s1 = random(500);
itoa(s1, cint, DEC);
strcat(cstr, cint);
strcat(cstr, ";");
uint16_t s2 = random(500);
itoa(s2, cint, DEC);
strcat(cstr, cint);
strcat(cstr, "\n");
Serial.println(cstr);
}
}