Anniversary Sale · up to 80% off all librariesEnds Nov 9Shop now
SOFTTDocs

Integration Guide

Add NetWizard to an existing sketch that already uses a web server.

This guide adds NetWizard to an existing sketch with the minimum number of changes. It assumes you have installed NetWizard and its dependencies as described in Installation.

Prepare the sketch

Remove every call to WiFi.begin() and WiFi.softAP() from your sketch. NetWizard manages the WiFi mode, the station connection and the access point; direct calls interfere with its state.

After integration, prefer the NetWizard methods over the WiFi object for connection details, for example NW.getSSID(), NW.getPassword() and NW.localIP().

Integrate NetWizard

Include the library

Add the header at the top of the sketch:

#include <NetWizard.h>  // NetWizard Pro: #include <NetWizardPro.h>

Create the NetWizard instance

Create a global NetWizard object and pass a pointer to your web server:

NetWizard NW(&server);

The server type must match the mode NetWizard is compiled in: WebServer by default, or AsyncWebServer in async mode.

Call autoConnect()

Call autoConnect() in setup(). NetWizard connects to the saved network; if none exists or the connection fails, it starts the captive portal and waits for user input until the portal times out.

void setup() {
  // ...
  NW.autoConnect("NetWizard Demo", "");
  // ...
}

The two arguments are the SSID and password of the access point the device opens for the portal. An empty password creates an open access point.

Call loop()

Call NW.loop() on every iteration of loop(). It processes portal requests, updates the connection status and invokes callbacks.

void loop() {
  // ...
  NW.loop();
  // ...
}

This is the minimal setup. Add callbacks, parameters and configuration as required.

Routes used by NetWizard

While the portal is active, NetWizard registers the following routes on your server. They respond only to clients connected to the device's access point, so clients on your local network continue to reach your own routes.

RoutePurpose
/Portal page
/netwizard/*Portal API (status, schema, scan, save, clear, exit) and, in NetWizard Pro, the logo

NetWizard also replaces the server's not-found handler so that captive-portal detection requests are redirected to the portal. When the portal stops, NetWizard removes its routes and clears the not-found handler. If your sketch relies on a custom not-found handler, register it again after the portal has closed.

Next steps

On this page