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

Credentials

Read, replace, erase and reset the WiFi credentials that NetWizard stores on the device.

NetWizard stores the SSID and password of the configured network in persistent storage (Preferences, in the nw_creds namespace) and loads them in autoConnect(). The methods on this page read and modify these credentials.

Methods

isConfigured()

bool isConfigured();

Returns true if the device has saved credentials, otherwise false.

if (NW.isConfigured()) {
  // ...
}

getSSID()

const char* getSSID();

Returns the SSID of the configured network.

String ssid = NW.getSSID();

getPassword()

const char* getPassword();

Returns the password of the configured network.

String password = NW.getPassword();

setCredentials()

void setCredentials(const char* ssid, const char* password);

Replaces the configured credentials and saves them to persistent storage. It does not start a connection or the captive portal. To save and connect in one step, use connect(ssid, password).

NW.setCredentials("ssid", "password");

erase()

void erase();

Erases the saved credentials from persistent storage, so the device starts unconfigured after the next reboot. It does not disconnect the device, stop the captive portal or change the credentials currently in use; isConfigured() keeps returning its current value until the next reboot.

NW.erase();

reset()

void reset();

Returns NetWizard to its initial state: clears the credentials in memory and in persistent storage, disconnects from the network and, if the captive portal is active, stops it after a delay of about 5 seconds.

NW.reset();
MethodClears stored credentialsClears credentials in useDisconnectsStops the portal
erase()YesNoNoNo
reset()YesYesYesYes

On this page