feat: test ntp

This commit is contained in:
2023-08-18 21:34:05 +02:00
parent 6e2da886fc
commit 2c138a3225
4 changed files with 31 additions and 3 deletions

View File

@ -21,12 +21,33 @@ Program::Program() {
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
//init obj
this->discord = new DiscordAPI(DISCORD_HOOK);
delay(1000);
Serial.println(this->discord->sendHeure("10h", "18h"));
this->ntpUDP = new WiFiUDP();
this->timeClient = new NTPClient(*this->ntpUDP, "pool.ntp.org", 3600*2);//*2 = gnt+2
//Serial.println(this->discord->sendHeure("10h", "18h"));
}
void Program::loop() {
// Loop
delay(1000);
this->timeClient->update();
int currentHour = this->timeClient->getHours();
Serial.print("Hour: ");
Serial.println(currentHour);
int currentMinute = this->timeClient->getMinutes();
Serial.print("Minutes: ");
Serial.println(currentMinute);
int currentSecond = this->timeClient->getSeconds();
Serial.print("Seconds: ");
Serial.println(currentSecond);
int currentDayOfWeek = this->timeClient->getDay();
Serial.print("Day of week: ");
Serial.println(currentDayOfWeek);
}

View File

@ -9,3 +9,5 @@ void setup() {
void loop() {
program->loop();
}