Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on esp32 with fixed ip, it doesn't work #166

Open
Albalate opened this issue Feb 16, 2022 · 1 comment
Open

on esp32 with fixed ip, it doesn't work #166

Albalate opened this issue Feb 16, 2022 · 1 comment
Labels
type: imperfection Perceived defect in any part of project

Comments

@Albalate
Copy link

Albalate commented Feb 16, 2022

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);

const char *ssid     = "<SSID>";
const char *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);

void setup(){
  Serial.begin(115200);
  WiFi.config(ip, gateway, subnet);
  WiFi.begin(ssid, password);

  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }

  timeClient.begin();
}

void loop() {
  timeClient.update();

  Serial.println(timeClient.getFormattedTime());

  delay(1000);
}
@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Feb 17, 2022
@JyunWei-Su
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants