Wifi Configuration - NiklasVoigt/Afterburner GitHub Wiki

WiFi Configuration

Introduction

The ESP32 processor as used in the diesel heater controller can function in the following WiFi operation modes:

  • AP - Access Point - clients can directly connect
  • STA - Station mode - connecting to an existing WiFi network
  • STA+AP - Simultaneous Station and Access Point

However to connect as a WiFi station requires credentials to be sent to the host Access Point to gain access to that network.
These credentials being the SSID and password for the Access Point.

Obviously as each network will require unique credentials, a way to define these credentials needs to exist that is relatively easy for the user to define.
The laziest way is to hard code this into the firmware, which has obvious disadvantages.

A better way is to make use of the WiFiManager library, whereby a special web page is enabled allowing a user to firstly connect directly to the ESP32 over WiFi via its own Access Point, and then define the credentials for the network to connect to.

Once defined, the ESP32 then runs in STA+AP mode, allowing direct client connections, or clients from the host WiFi network to connect.

WiFi mode indication

The current operational mode of the WiFi system can be ascertained by observing the icon in the OLED display's header:

AP only STA+AP Config Portal
wifiIconAPx2 wifiIconx2 wifiIconCFGx2

When enabled, the Config Portal is always available via the ESP32's Access Point.
If station credentials are stored, it will also be available via the the STA IP address.

If AP is shown against the Wifi icon, the heater control web page is only available via the hosted Access Point.
If a clean WiFi icon is shown, the heater control web page is available via the hosted Access Point, or STA IP address.

Initial configuration

The very first time firmware is loaded into the ESP32, obviously no credentials have ever been defined.
Therefore the ESP32 boots up only hosting its own Access Point.

The credentials for this Access Point are as follows:

  • SSID: BTCESP32
  • Password: thereisnospoon

Once a client gains access to the heater controller over WiFi, they can then open a web browser to IP address 192.168.4.1.
By default this will be the usual heater control web page.

Starting WiFi Manager

There are several ways to initiate the WiFi manager Configuration Portal:

  • BOOT button
  • OLED menu
  • Web page

BOOT button

The BOOT button is usually only used to initiate a firmware upload, holding this button down whilst resetting the ESP32 processor.
However, this button can also be used for any use by a user program.
Here we use it to start or stop the WiFi Manager:

  • Short press (< 1 second) - Enable configuration portal.
  • > 1 seconds press (< 5 seconds) - Disable the configuration portal.
  • > 5 seconds - Erase existing credentials and enable the configuration portal.
    All of the above actions result in the processor being restarted via reset, bringing up a notification on the OLED display.

To assist in determining how long your press of the BOOT button has been, the WiFi icon on the OLED will be adorned with a subtext showing the mode the ESP32 will reboot into:

Initial press 1 second hold 5 second hold
Config Portal Heater control Erase credentials, Config Portal
wifiIconCFGx2 wifiIconHTRx2 wifiIconERSx2

Wifi details OLED menu

An OLED menu is available to present the IP address(es) of the heater controller, and can also be used to enable/disable the Configuration Portal.
Using the left/right navigation keys, a menu that looks something like this can be found:
IP address

Upon initial entry, the navigation arrows are selected at the bottom of the screen.
The current Wifi Mode will be presented in inverse text, along with the appropriate IP addresses for the active mode.

Pressing left or right will navigate to the previous or next menu.
Pressing the down switch will toggle from showing the IP address(es) to showing the MAC address(es) of the Wifi connection(s), this may be useful for router configurations when applying a fixed IP for the STA connection.
MAC address

Toggling between Configuration Portal, or Heater web pages

Pressing the up switch will move the selection box to where the inverted text existed.
WiFi Mode toggle

You can now toggle WiFi mode between the Configuration Portal or Web Server.
You can also erase any existing credentials and open the Configuration Portal:

  • Press centre button - Toggle between the Configuration Portal, or the heater control web pages
  • Hold centre button > 4 seconds - Erase WiFi credentials and enter the Configuration Portal

If STA credentials are existing, the long hold duration expiring is made evident by the STA details disappearing from the OLED, and the WiFi icon becoming AP only.

Once released, a reboot sequence is initiated, and the new mode that will become active is presented upon the OLED display.
Reboot OLED indication

Heater web page - invoking WiFi Manager

If the heater web page is currently being served, the Configuration Portal can be started by adding /wmconfig to the end of the browser URL: eg: http://192.168.4.1/wmconfig

The heater controller accept the command, setup to start the Config portal and finally reboot. Once again presenting a reboot notification upon the OLED display.

Configuration Portal

Using a web browser, navigate to the heater controller's IP address. eg http://192.168.4.1/
This will present the configuration portal.
The following images show the initial entry to the portal; defining the credentials; and finally the completed Config portal, after a reboot. Initial Config PortalDefining credentialsConfigured STA

Finally the OLED WiFi menu will also show the controller is now configured for STA+AP mode:
Final STA+AP mode

⚠️ **GitHub.com Fallback** ⚠️