You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this code just changing the line WiFi.config(ip, gateway, subnet); stops working.
#include<NTPClient.h>// change next line to use with another board/shield//#include <ESP8266WiFi.h>
#include<WiFi.h>// for WiFi shield//#include <WiFi101.h> // for WiFi 101 shield or MKR1000
#include<WiFiUdp.h>
IPAddress ip(192,168,0,30);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
constchar *ssid = "<SSID>";
constchar *password = "<PASSWORD>";
WiFiUDP ntpUDP;
// You can specify the time server pool and the offset (in seconds, can be// changed later with setTimeOffset() ). Additionaly you can specify the// update interval (in milliseconds, can be changed using setUpdateInterval() ).
NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000);
voidsetup(){
Serial.begin(115200);
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}
timeClient.begin();
}
voidloop() {
timeClient.update();
Serial.println(timeClient.getFormattedTime());
delay(1000);
}
The text was updated successfully, but these errors were encountered:
After I replace WiFi.config(ip, gateway, subnet); with WiFi.config(ip, gateway, subnet, dns);, it works.
If it still not working, try to change your ntp server.
this code just changing the line
WiFi.config(ip, gateway, subnet);
stops working.The text was updated successfully, but these errors were encountered: