[GH-ISSUE #1449] DHCP renew #1239

Closed
opened 2026-02-28 01:29:11 +03:00 by kerem · 2 comments
Owner

Originally created by @Laxilef on GitHub (Jul 7, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1449

Hardware

WiFimanager: 2.0.11 beta
Esp8266:
Hardware: wemos d1 mini pro
Core Version: 3.0.2

Description

After changing the IP address for esp8266 on the router, esp does not do dhcp renew. No reboots help.
It seems to me that esp writes down the received ip and doesn't do renew anymore.
Only one thing helps: changing the ssid on the access point and reconnecting the esp.
What am I doing wrong?

Sketch

  void setup() {
    // code
    // ....
    // ....

    wm.addParameter(wmMqttPrefix);

    //wm.setCleanConnect(true);
    wm.setRestorePersistent(false);

    wm.setHostname(settings.hostname);
    wm.setWiFiAutoReconnect(true);
    wm.setConfigPortalBlocking(false);
    wm.setSaveParamsCallback(saveParamsCallback);
    wm.setConfigPortalTimeout(300);
    wm.setDisableConfigPortal(false);

    if (wm.autoConnect(AP_SSID)) {
      INFO_F("Wifi connected. IP: %s, RSSI: %d\n", WiFi.localIP().toString().c_str(), WiFi.RSSI());
      wm.startWebPortal();

    } else {
      INFO(F("Failed to connect to WIFI, start the configuration portal..."));
    }
  }

  void loop() {
    wm.process();
  }
Originally created by @Laxilef on GitHub (Jul 7, 2022). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1449 #### Hardware WiFimanager: 2.0.11 beta Esp8266: Hardware: wemos d1 mini pro Core Version: 3.0.2 ### Description After changing the IP address for esp8266 on the router, esp does not do dhcp renew. No reboots help. It seems to me that esp writes down the received ip and doesn't do renew anymore. Only one thing helps: changing the ssid on the access point and reconnecting the esp. What am I doing wrong? ### Sketch ```cpp void setup() { // code // .... // .... wm.addParameter(wmMqttPrefix); //wm.setCleanConnect(true); wm.setRestorePersistent(false); wm.setHostname(settings.hostname); wm.setWiFiAutoReconnect(true); wm.setConfigPortalBlocking(false); wm.setSaveParamsCallback(saveParamsCallback); wm.setConfigPortalTimeout(300); wm.setDisableConfigPortal(false); if (wm.autoConnect(AP_SSID)) { INFO_F("Wifi connected. IP: %s, RSSI: %d\n", WiFi.localIP().toString().c_str(), WiFi.RSSI()); wm.startWebPortal(); } else { INFO(F("Failed to connect to WIFI, start the configuration portal...")); } } void loop() { wm.process(); } ```
kerem closed this issue 2026-02-28 01:29:11 +03:00
Author
Owner

@tablatronix commented on GitHub (Jul 8, 2022):

hmm, thats indeed odd, esp only saved the address if you give it a static via sta config.. So I am not sure.
Ideally I would bring this down to a basic esp example and try to reproduce, removing wm from the picture..

If I have time to test I will

<!-- gh-comment-id:1179039658 --> @tablatronix commented on GitHub (Jul 8, 2022): hmm, thats indeed odd, esp only saved the address if you give it a static via sta config.. So I am not sure. Ideally I would bring this down to a basic esp example and try to reproduce, removing wm from the picture.. If I have time to test I will
Author
Owner

@Laxilef commented on GitHub (Jul 10, 2022):

Tested. I tried changing the IP settings for esp and forcibly disconnecting the client (esp). In this case, everything is fine, renew happens. Code:

#include <ESP8266WiFi.h>
const char* ssid = "AP";
const char* password = "password";

void setup()  {
  Serial.begin(115200);
  Serial.println("");
  Serial.println("Boot");
  WiFi.hostname("ESP-device");
  WiFi.begin(ssid, password);
}
 
void loop() {
  static unsigned long last = 0;
  static bool connected = false;

  if (connected && WiFi.status() != WL_CONNECTED) {
    connected = false;
    Serial.println("Disconnected");

  } else if (!connected && WiFi.status() != WL_CONNECTED && millis() - last >= 500) {
    Serial.print(".");
    last = millis();

  } else if (!connected && WiFi.status() == WL_CONNECTED) {
    connected = true;

    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
  }
}

Log:

Boot
..........
Connected to AP
IP address: 10.224.0.186
Disconnected
.....
Connected to AP
IP address: 10.224.0.185
Disconnected
.....
Connected to AP
IP address: 10.224.0.184
<!-- gh-comment-id:1179805899 --> @Laxilef commented on GitHub (Jul 10, 2022): Tested. I tried changing the IP settings for esp and forcibly disconnecting the client (esp). In this case, everything is fine, renew happens. Code: ``` #include <ESP8266WiFi.h> const char* ssid = "AP"; const char* password = "password"; void setup() { Serial.begin(115200); Serial.println(""); Serial.println("Boot"); WiFi.hostname("ESP-device"); WiFi.begin(ssid, password); } void loop() { static unsigned long last = 0; static bool connected = false; if (connected && WiFi.status() != WL_CONNECTED) { connected = false; Serial.println("Disconnected"); } else if (!connected && WiFi.status() != WL_CONNECTED && millis() - last >= 500) { Serial.print("."); last = millis(); } else if (!connected && WiFi.status() == WL_CONNECTED) { connected = true; Serial.println(""); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); } } ``` Log: ``` Boot .......... Connected to AP IP address: 10.224.0.186 Disconnected ..... Connected to AP IP address: 10.224.0.185 Disconnected ..... Connected to AP IP address: 10.224.0.184 ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1239
No description provided.