[GH-ISSUE #1754] Changing wifi without having to turn on the config portal #1483

Open
opened 2026-02-28 01:30:15 +03:00 by kerem · 7 comments
Owner

Originally created by @VladimirVecera on GitHub (Jul 29, 2024).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1754

First of all ... wifimanager is an absolutely amazing tool and I thank you for it. Thank you very much.
I have a question. I configure the ESP32 through the config portal, the ESP32 successfully connects to wifi. In a month I want to change wifi accesses. At the same time, I have my own web administration on ESP32. Is it possible to change wifi accesses without having to activate the config portal, which works on 192.168.4.1 and is it necessary to have a wifi device at hand to set up wifi? I would like to be able to configure the wifi via the web interface on the already connected wifi. I hope you understand me.

Originally created by @VladimirVecera on GitHub (Jul 29, 2024). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1754 First of all ... wifimanager is an absolutely amazing tool and I thank you for it. Thank you very much. I have a question. I configure the ESP32 through the config portal, the ESP32 successfully connects to wifi. In a month I want to change wifi accesses. At the same time, I have my own web administration on ESP32. Is it possible to change wifi accesses without having to activate the config portal, which works on 192.168.4.1 and is it necessary to have a wifi device at hand to set up wifi? I would like to be able to configure the wifi via the web interface on the already connected wifi. I hope you understand me.
Author
Owner

@F1p commented on GitHub (Jul 29, 2024):

wifiManager.startWebPortal();

At the end of setup to run the web server when on WiFi
And in loop to handle requests and modification:

wifiManager.process();

You may also need this if saving fields to a file:
if (shouldSaveConfig) { saveConfig(); } // Handles WiFiManager Settings Changes

<!-- gh-comment-id:2257080137 --> @F1p commented on GitHub (Jul 29, 2024): wifiManager.startWebPortal(); At the end of setup to run the web server when on WiFi And in loop to handle requests and modification: wifiManager.process(); You may also need this if saving fields to a file: if (shouldSaveConfig) { saveConfig(); } // Handles WiFiManager Settings Changes
Author
Owner

@tablatronix commented on GitHub (Jul 29, 2024):

You can do it in regular esp code via begin()

<!-- gh-comment-id:2257080937 --> @tablatronix commented on GitHub (Jul 29, 2024): You can do it in regular esp code via begin()
Author
Owner

@VladimirVecera commented on GitHub (Jul 30, 2024):

I'm a bit confused. Can you send the best code? Thank you very much in advance for your help.

<!-- gh-comment-id:2259145169 --> @VladimirVecera commented on GitHub (Jul 30, 2024): I'm a bit confused. Can you send the best code? Thank you very much in advance for your help.
Author
Owner

@F1p commented on GitHub (Jul 31, 2024):

I'm a bit confused. Can you send the best code? Thank you very much in advance for your help.

Edit of basic example:

#include <WiFiManager.h>
WiFiManager wm;

void setup() {
  bool res;
  res = wm.autoConnect("AutoConnectAP", "password");
  if (!res) {
    Serial.println("Failed to connect");
  } else {
    Serial.println("connected...yeey :)");
  }

  wm.startWebPortal();  // Post connection WiFi Manager Portal Start
}

void loop() {
  wm.process();  // Handle requests
}
<!-- gh-comment-id:2261345444 --> @F1p commented on GitHub (Jul 31, 2024): > I'm a bit confused. Can you send the best code? Thank you very much in advance for your help. Edit of basic example: ``` #include <WiFiManager.h> WiFiManager wm; void setup() { bool res; res = wm.autoConnect("AutoConnectAP", "password"); if (!res) { Serial.println("Failed to connect"); } else { Serial.println("connected...yeey :)"); } wm.startWebPortal(); // Post connection WiFi Manager Portal Start } void loop() { wm.process(); // Handle requests } ```
Author
Owner

@VladimirVecera commented on GitHub (Aug 12, 2024):

The problem is that the web administration of the project is already running on the web interface #include <WebServer.h>
And if I want to change the wifi configuration to the already successfully connected wifi, it doesn't work. Does it even work?

server.on("/wifiportal", []() { wm.startWebPortal(); });

<!-- gh-comment-id:2283897598 --> @VladimirVecera commented on GitHub (Aug 12, 2024): The problem is that the web administration of the project is already running on the web interface #include <WebServer.h> And if I want to change the wifi configuration to the already successfully connected wifi, it doesn't work. Does it even work? `server.on("/wifiportal", []() { wm.startWebPortal(); }); `
Author
Owner

@tablatronix commented on GitHub (Aug 12, 2024):

I thought you meant in code.. you want to start the webportal you cant of you are already running another webserver

<!-- gh-comment-id:2284968116 --> @tablatronix commented on GitHub (Aug 12, 2024): I thought you meant in code.. you want to start the webportal you cant of you are already running another webserver
Author
Owner

@VladimirVecera commented on GitHub (Aug 13, 2024):

Thank you for the information. If I understand it correctly. Are you using the Webserver library so I can use wm.server->on() ? See code below along with mdns.

#include <WiFi.h>
#include <WiFiManager.h>  // Knihovna WiFiManager
#include <ESPmDNS.h>       // Knihovna pro mDNS

WiFiManager wm;

void setup() {
  Serial.begin(115200);

  // Spustí WiFiManager a připojí se k WiFi síti
  if (!wm.autoConnect("AutoConnectAP")) {
    Serial.println("Failed to connect and hit timeout");
    // Možná chcete restartovat zařízení nebo jinak reagovat
    ESP.restart();
    delay(1000);
  }

  Serial.println("Connected to WiFi!");

  // Nastavení mDNS
  if (!MDNS.begin("esp32")) {  // "esp32" je jméno mDNS, zařízení bude dostupné na "http://esp32.local"
    Serial.println("Error setting up MDNS responder!");
  } else {
    Serial.println("mDNS responder started");
  }

  // Přidání vlastního handleru pro "/mycustomurl"
  wm.server->on("/mycustomurl", HTTP_GET, []() {
    wm.server->send(200, "text/plain", "Hello, this is a custom URL!");
  });

  // Spuštění serveru
  wm.server->begin();

  Serial.println("HTTP server started");
}

void loop() {
  // Je nutné pravidelně volat loop WiFiManageru
  wm.process();
  
  // Musíte pravidelně volat MDNS.update()
  MDNS.update();
}
<!-- gh-comment-id:2285377195 --> @VladimirVecera commented on GitHub (Aug 13, 2024): Thank you for the information. If I understand it correctly. Are you using the Webserver library so I can use **wm.server->on()** ? See code below along with mdns. ``` #include <WiFi.h> #include <WiFiManager.h> // Knihovna WiFiManager #include <ESPmDNS.h> // Knihovna pro mDNS WiFiManager wm; void setup() { Serial.begin(115200); // Spustí WiFiManager a připojí se k WiFi síti if (!wm.autoConnect("AutoConnectAP")) { Serial.println("Failed to connect and hit timeout"); // Možná chcete restartovat zařízení nebo jinak reagovat ESP.restart(); delay(1000); } Serial.println("Connected to WiFi!"); // Nastavení mDNS if (!MDNS.begin("esp32")) { // "esp32" je jméno mDNS, zařízení bude dostupné na "http://esp32.local" Serial.println("Error setting up MDNS responder!"); } else { Serial.println("mDNS responder started"); } // Přidání vlastního handleru pro "/mycustomurl" wm.server->on("/mycustomurl", HTTP_GET, []() { wm.server->send(200, "text/plain", "Hello, this is a custom URL!"); }); // Spuštění serveru wm.server->begin(); Serial.println("HTTP server started"); } void loop() { // Je nutné pravidelně volat loop WiFiManageru wm.process(); // Musíte pravidelně volat MDNS.update() MDNS.update(); } ```
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#1483
No description provided.