Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

"Library to configure MultiWiFi/Credentials at runtime for Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52, RP2040-based (Nano RP2040 Connect, RASPBERRY_PI_PICO), AmebaD RTL8720DN, etc. boards, using Generic WiFi (WiFiNINA, WiFi101, ESP8266-AT, ESP32-AT, etc.) modules/shields. You can also specify DHCP HostName, static AP and STA IP.…

License

Notifications You must be signed in to change notification settings

khoih-prog/WiFiManager_Generic_Lite

Repository files navigation

WiFiManager_Generic_Lite (Light Weight Credentials / WiFi Manager for Generic WiFi (WiFiNINA, WiFi101, WiFiEsp, etc.) modules/shields)

arduino-library-badge GitHub release GitHub contributions welcome GitHub issues

Donate to my libraries using BuyMeACoffee



Table of Contents



Important Notes about RTL8720DN

WiFi.status() bug

The current AmebaD core v3.1.2 has bug that once WiFi is connected, WiFi.status() always reports WL_CONNECTED even if WiFi is lost.

There is no workaround yet for this WiFi.status() bug because WiFi.RSSI() is still keeping the good value

Therefore, the auto-reconnect feature for WiFiMulti won't work, until this bug is fixed by Realtek.


Important Notes about Nano_RP2040_Connect

The LittleFS of the new Nano_RP2040_Connect board ( see New board ), using ISSI Flash chip, is currently not working with Arduino mbed_rp2040 core 2.4.1+. Please downgrade to Arduino mbed_rp2040 core 2.3.1

Check RP2040 Connect board has faulty components in newest purchase #318 for more information of when and how the issue will be fixed.

The old board ( see Old board ), using Adesto Flash chip, is currently working with Arduino mbed_rp2040 core 2.4.1+.



Features

If you have used the full-fledge WiFiManager such as :

  1. Tzapu WiFiManager
  2. Ken Taylor WiFiManager
  3. Khoi Hoang ESP_WiFiManager

and have to write complicated callback functions to save custom parameters in SPIFFS/LittleFS/EEPROM, you'd appreciate the simplicity of this Light-Weight Credentials / WiFiManager.

This library is a Light Weight Credentials / WiFi Manager for Generic WiFi (WiFiNINA, WINC1500/WiFi101, WiFiEsp, etc.) modules/shields, specially designed to support Teensy, SAM DUE, SAMD21 (Nano-33 IoT, Itsy-Bitsy M0, etc), SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.), STM32F (F1, F2, F3, F4, F7, Nucleo-144, etc.), nRF52 (Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, NINA_B302_ublox, NINA_B112_ublox, etc.), RP2040-based (Nano RP2040 Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040), etc. boards running WiFiNINA modules/shields. with smaller memory (64+K bytes)

The AVR-family boards (UNO, Nano, Mega, etc.) are not supported as they don't have enough memory to run Config Portal WebServer.

This is a Credentials / WiFi Connection Manager, permitting the addition of custom parameters to be configured in Config Portal. The parameters then will be saved automatically, without the complicated callback functions to handle data saving / retrieving.

You can also specify DHCP HostName, static AP and STA IP. Use much less memory compared to full-fledge WiFiManager. Config Portal will be auto-adjusted to match the number of dynamic custom parameters. Credentials are saved in EEPROM, (emulated-)EEPROM, FlashStorage_SAMD, FlashStorage_STM32 or DueFlashStorage.

The web configuration portal, served from the Generic WiFi modules/shields is operating as an access point (AP) with configurable static IP address or use default IP Address of 192.168.4.1

New recent features:

  • MultiWiFi feature for configuring/auto(re)connecting Generic WiFi (WiFiNINA, WINC1500/WiFi101, WiFiEsp, etc.) shields to the available MultiWiFi APs at runtime.
  • DoubleDetectDetector feature to force Config Portal when double reset is detected within predetermined time, default 10s.
  • Powerful-yet-simple-to-use feature to enable adding dynamic custom parameters from sketch and input using the same Config Portal. Config Portal will be auto-adjusted to match the number of dynamic parameters.
  • Optional default Credentials as well as Dynamic parameters to be optionally autoloaded into Config Portal to use or change instead of manually input.
  • Dynamic custom parameters to be saved automatically in non-volatile memory, such as Teensy EEPROM, SAMD EEPROM-emulated FlashStorage_SAMD, STM32F/L/H/G/WB/MP1 EEPROM-emulated FlashStorage_STM32 or SAM DUE DueFlashStorage.
  • Configurable Config Portal Title to be either BoardName or default undistinguishable names.
  • Examples are designed to separate Credentials / Defines / Dynamic Params / Code so that you can change Credentials / Dynamic Params quickly for each device.
  • Control Config Portal from software or Virtual Switches
  • To permit autoreset after configurable timeout if DRD/MRD or non-persistent forced-CP
  • Use new nRF52, RP2040 LittleFS, SAMD FlashStorage_SAMD and STM32F/L/H/G/WB/MP1 FlashStorage_STM32 features
  • Scan WiFi networks for selection in Configuration Portal

WiFiMulti_Generic library usage

The usage the new WiFiMulti_Generic library to help connect to the best of multi-WiFi APs, with auto-checking / auto-reconnecting features when WiFi connection is lost.


Currently supported Boards

This WiFiManager_Generic_Lite library currently supports these following boards:

  1. nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.

  2. SAMD21

  • Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc.
  • Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc.
  • Seeeduino: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc.
  1. SAMD51
  • Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc.
  • Seeeduino: Wio Terminal, Grove UI Wireless
  1. SAM DUE
  2. Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0)
  3. STM32F/L/H/G/WB/MP1 boards (with 32+K Flash)
  • Nucleo-144
  • Nucleo-64
  • Discovery
  • Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7 (with 64+K Flash): x8 and up
  • STM32L0, STM32L1, STM32L4, STM32L5
  • STM32G0, STM32G4
  • STM32H7
  • STM32WB
  • STM32MP1
  • LoRa boards
  • 3-D printer boards
  • Generic Flight Controllers
  • Midatronics boards
  1. RP2040-based boards, such as Nano RP2040 Connect, using Arduino mbed OS for Nano boards or Earle Philhower's arduino-pico core.

  2. RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core or Earle Philhower's arduino-pico core.

  3. RTL8720DN, RTL8722DM, RTM8722CSM, etc. boards


Currently supported WiFi shields/modules

  1. WiFiNINA using WiFiNINA_Generic library v1.8.14-3+
  2. WiFi101 using WiFi101 library v0.16.1+
  3. u-blox W101, W102 using WiFiNINA_Generic library
  4. ESP826-AT command using WiFiEspAT library v1.3.2+
  5. ESP8266/ESP32-AT command using ESP_AT_Lib library v1.4.1+ and ESP8266_AT_WebServer


Prerequisites

  1. Arduino IDE 1.8.19+ for Arduino. GitHub release
  2. Arduino Core for STM32 v2.3.0+ for STM32 boards. GitHub release
  3. Teensy core 1.57+ for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0, LC) boards
  4. Arduino SAM DUE core 1.6.12+ for SAM DUE ARM Cortex-M3 boards
  5. Arduino SAMD core 1.8.13+ for SAMD ARM Cortex-M0+ boards. GitHub release
  6. Adafruit SAMD core 1.7.11+ for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). GitHub release
  7. Seeeduino SAMD core 1.8.3+ for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). Latest release
  8. Adafruit nRF52 v1.3.0+ for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, NINA_B302_ublox, etc. GitHub release
  9. Arduino mbed_rp2040 core 3.4.1+ for Arduino (Use Arduino Board Manager) RP2040-based boards, such as Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.. GitHub release
  10. Earle Philhower's arduino-pico core v2.6.3+ for RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, etc. GitHub release
  11. Arduino AmebaD core 3.1.4+ for Realtek RTL8720DN, RTL8722DM and RTM8722CSM. GitHub release
  12. Functional-Vlpp library v1.0.2+ to use server's lambda function. To install. check arduino-library-badge
  13. WiFiNINA_Generic library v1.8.15-0+. To install. check arduino-library-badge
  14. WiFiWebServer library v1.10.0+. To install. check arduino-library-badge
  15. ESP8266_AT_WebServer library v1.6.0+ to be able to support ESP32-AT shields. To install, check arduino-library-badge
  16. ESP_AT_Lib library v1.4.1+ if using ESP8288/ESP32-AT shields. To install, check arduino-library-badge.
  17. Modified WiFi101 Library v0.16.1+ to use SAMD MKR1000, etc. boards with WiFi101.
  18. WiFiEspAT library v1.4.1+ if using ESP8288/ESP32-AT shields. GitHub release
  19. FlashStorage_SAMD library v1.3.2+ for SAMD21 and SAMD51 boards (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit Itsy-Bitsy M4, etc.). GitHub release
  20. FlashStorage_STM32F1 library v1.1.0+ for STM32F1/F3 boards. To install. check arduino-library-badge
  21. FlashStorage_STM32 library v1.2.0+ for STM32F/L/H/G/WB/MP1 boards. To install. check arduino-library-badge
  22. DueFlashStorage library v1.0.0+ for SAM DUE. To install, check arduino-library-badge
  23. Adafruit's LittleFS/InternalFS for nRF52
  24. DoubleResetDetector_Generic v1.8.1+. To install, check arduino-library-badge
  25. MultiResetDetector_Generic v1.8.1+. To install, check arduino-library-badge
  26. WiFiMulti_Generic library v1.2.2+ to use WiFiMulti function. To install, check arduino-library-badge. New
  27. FlashStorage_RTL8720 library v1.1.0+. GitHub release
  28. Modified Adafruit_MQTT_Library v2.4.2+ to use MQTT examples for many boards.

Installation

Use Arduino Library Manager

The best and easiest way is to use Arduino Library Manager. Search for WiFiManager_Generic_Lite, then select / install the latest version. You can also use this link arduino-library-badge for more detailed instructions.

Manual Install

  1. Navigate to WiFiManager_Generic_Lite page.
  2. Download the latest release WiFiManager_Generic_Lite-main.zip.
  3. Extract the zip file to WiFiManager_Generic_Lite-main directory
  4. Copy the whole
  • WiFiManager_Generic_Lite-main folder to Arduino libraries' directory such as ~/Arduino/libraries/.

VS Code & PlatformIO:

  1. Install VS Code
  2. Install PlatformIO
  3. Install WiFiManager_Generic_Lite library by using Library Manager. Search for WiFiManager_Generic_Lite in Platform.io Author's Libraries
  4. Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File


Packages' Patches

1. For Adafruit nRF52840 and nRF52832 boards

To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards, you have to copy the whole nRF52 Packages_Patches directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0).

Supposing the Adafruit nRF52 version is 1.3.0. These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/boards.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h

Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/boards.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h

2. For Teensy boards

To be able to compile and run on Teensy boards, you have to copy the files in Packages_Patches for Teensy directory into Teensy hardware directory (./arduino-1.8.19/hardware/teensy/avr/boards.txt).

Supposing the Arduino version is 1.8.19. These files must be copied into the directory:

  • ./arduino-1.8.19/hardware/teensy/avr/boards.txt
  • ./arduino-1.8.19/hardware/teensy/avr/cores/teensy/Stream.h
  • ./arduino-1.8.19/hardware/teensy/avr/cores/teensy3/Stream.h
  • ./arduino-1.8.19/hardware/teensy/avr/cores/teensy4/Stream.h

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:

  • ./arduino-x.yy.zz/hardware/teensy/avr/boards.txt
  • ./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy/Stream.h
  • ./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy3/Stream.h
  • ./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy4/Stream.h

3. For Arduino SAM DUE boards

To be able to compile and run on SAM DUE boards, you have to copy the whole SAM DUE directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12).

Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/sam/1.6.12/platform.txt

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt

4. For Arduino SAMD boards

To be able to compile, run and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards, you have to copy the whole Arduino SAMD Packages_Patches directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.13).

For core version v1.8.10+

Supposing the Arduino SAMD version is 1.8.13. Now only one file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/1.8.13/platform.txt

Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz

This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.zz/platform.txt

For core version v1.8.9-

Supposing the Arduino SAMD version is 1.8.9. These files must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/1.8.9/platform.txt
  • ~/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h

Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z

These files must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.z/platform.txt
  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.z/cores/arduino/Arduino.h

This is mandatory to fix the notorious Arduino SAMD compiler error. See Improve Arduino compatibility with the STL (min and max macro)

 ...\arm-none-eabi\include\c++\7.2.1\bits\stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)

Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don't need to copy the Arduino.h file anymore.

5. For Adafruit SAMD boards

To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards, you have to copy the whole Adafruit SAMD Packages_Patches directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.11).

Supposing the Adafruit SAMD core version is 1.7.11. These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/samd/1.7.11/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.h
  • ~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.cpp

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.h
  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.cpp

6. For Seeeduino SAMD boards

To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards, you have to copy the whole Seeeduino SAMD Packages_Patches directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3).

Supposing the Seeeduino SAMD core version is 1.8.3. These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Arduino.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.cpp

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Arduino.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.cpp

7. For STM32 boards

7.1 For STM32 boards to use LAN8720

To use LAN8720 on some STM32 boards

  • Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG)
  • Discovery (DISCO_F746NG)
  • STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)

you have to copy the files stm32f4xx_hal_conf_default.h and stm32f7xx_hal_conf_default.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.3.0/system) to overwrite the old files.

Supposing the STM32 stm32 core version is 2.3.0. These files must be copied into the directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/2.3.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h for STM32F4.
  • ~/.arduino15/packages/STM32/hardware/stm32/2.3.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h for Nucleo-144 STM32F7.

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, these files must be copied into the corresponding directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F4xx/stm32f4xx_hal_conf_default.h
  • `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F7xx/stm32f7xx_hal_conf_default.h

7.2 For STM32 boards to use Serial1

To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards, you have to copy the files STM32 variant.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.3.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.

Supposing the STM32 stm32 core version is 2.3.0. These files must be copied into the directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h for Nucleo-144 NUCLEO_F767ZI.
  • ~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h for Nucleo-64 NUCLEO_L053R8.

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, these files must be copied into the corresponding directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h
  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h

8. For RP2040-based boards using Earle Philhower arduino-pico core

8.1 To use BOARD_NAME

To be able to automatically detect and display BOARD_NAME on RP2040-based boards (RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc) boards, you have to copy the file RP2040 platform.txt into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).

Supposing the rp2040 core version is 1.4.0. This file must be copied into the directory:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/platform.txt

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/platform.txt

With core after v1.5.0, this step is not necessary anymore thanks to the PR Add -DBOARD_NAME="{build.board}" #136.

8.2 To avoid compile error relating to microsecondsToClockCycles

Some libraries, such as Adafruit DHT-sensor-library, require the definition of microsecondsToClockCycles(). To be able to compile and run on RP2040-based boards, you have to copy the files in RP2040 Arduino.h into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).

Supposing the rp2040 core version is 1.4.0. This file must be copied to replace:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.h

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied to replace:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/cores/rp2040/Arduino.h

With core after v1.5.0, this step is not necessary anymore thanks to the PR Add defs for compatibility #142.

9. For Portenta_H7 boards using Arduino IDE in Linux

To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.), you have to copy the file portenta_post_install.sh into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh).

Then run the following command using sudo

$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1
$ chmod 755 portenta_post_install.sh
$ sudo ./portenta_post_install.sh

This will create the file /etc/udev/rules.d/49-portenta_h7.rules as follows:

# Portenta H7 bootloader mode UDEV rules

SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"

Supposing the ArduinoCore-mbed core version is 3.4.1. Now only one file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh

Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz

This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/x.yy.zz/portenta_post_install.sh

10. For RTL8720DN boards using AmebaD core

To avoid compile error relating to PROGMEM, you have to copy the file Realtek AmebaD core pgmspace.h into Realtek AmebaD directory (~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/ambd/avr/pgmspace.h).

Supposing the Realtek AmebaD core version is 3.1.4. This file must be copied into the directory:

  • ~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/ambd/avr/pgmspace.h

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/realtek/hardware/AmebaD/x.yy.zz/cores/ambd/avr/pgmspace.h

11. For SAMD21 and SAMD51 boards using ArduinoCore-fab-sam core

To avoid compile error relating to SAMD21/SAMD51, you have to copy the file ArduinoCore-fab-sam core pgmspace.h into ArduinoCore-fab-sam samd directory (~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.9.0/boards.txt).

Supposing the ArduinoCore-fab-sam samd core version is 1.9.0. This file must be copied into the directory:

  • ~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.9.0/boards.txt

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/x.yy.zz/boards.txt

12. For Seeeduino RP2040 boards

To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino RP2040 (XIAO RP2040, Wio RP2040 Mini) boards, you have to copy the whole Seeeduino RP2040 Packages_Patches directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2).

Supposing the Seeeduino RP2040 core version is 2.7.2. These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/boards.txt
  • ~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/variants/Seeed_XIAO_RP2040/pins_arduino.h

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/boards.txt
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/variants/Seeed_XIAO_RP2040/pins_arduino.h

13. For Seeeduino nRF52840 boards

To be able to compile and run on Xiao nRF52840 boards, you have to copy the whole nRF52 1.0.0 directory into Seeeduino nRF52 directory (~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0).

Supposing the Seeeduino nRF52 version is 1.0.0. These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Udp.h

Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h


How It Works

  • The SAMD_WiFi example shows how it works and should be used as the basis for a sketch that uses this library.
  • The concept of SAMD_WiFi is that a new Generic WiFi module/shield will start a WiFi configuration portal when powered up, but has no valid stored Credentials or can't connect to WiFi APs after a pre-determined time.
  • There are 6 more custom parameters added in the sketch which you can use in your program later. In the example, they are: 2 sets of Blynk Servers and Tokens, Blynk Port and MQTT Server.
  • Using any WiFi enabled device with a browser (computer, phone, tablet) connect to the newly created AP and type in the configurable AP IP address (default 192.168.4.1). The Config Portal AP channel (default 10) is also configurable to avoid conflict with other APs.
  • The Config Portal is auto-adjusted to fix the 4 static parameters (WiFi SSIDs/PWDs) as well as 6 more dynamic custom parameters.
  • After the custom data entered, and Save button pressed, the configuration data will be saved in host's non-volatile memory, then the board reboots.
  • If there is valid stored Credentials, it'll go directly to connect to one of the MultiWiFi APs without starting / using the Config Portal.
  • Generic WiFi module/shield will try to connect. If successful, the dynamic DHCP and/or configured static IP address will be displayed in the configuration portal.
  • The Generic WiFi module/shield WiFi Config Portal network and Web Server will shutdown to return control to the sketch code.
  • In the operation, if the current WiFi connection is lost because of any reason, the system will auto(Re)connect to the remaining WiFi AP.
  • If system can't connect to any of the 2 WiFi APs, the Config Portal will start, after some pre-determined time, to permit user to update the Credentials.

How to use

1. Basic usage

  • Include in your sketch
// Must be before #include <WiFiManager_Generic_Lite.h>
// Start location in EEPROM to store config data. Default 0
// Config data Size, not including your custom data, currently is 84 bytes)
#define EEPROM_START      0

#include <WiFiManager_Generic_Lite.h>

WiFiManager_Generic_Lite* WiFiManager_Generic;

2. Add custom parameters

  • To add custom parameters, just add
#include "defines.h"

// USE_DYNAMIC_PARAMETERS defined in defined.h

/////////////// Start dynamic Credentials ///////////////

//Defined in <WiFiManager_Generic_Lite.h>
/**************************************
  #define MAX_ID_LEN                5
  #define MAX_DISPLAY_NAME_LEN      16

  typedef struct
  {
  char id             [MAX_ID_LEN + 1];
  char displayName    [MAX_DISPLAY_NAME_LEN + 1];
  char *pdata;
  uint8_t maxlen;
  } MenuItem;
**************************************/

#if USE_DYNAMIC_PARAMETERS

#define MAX_BLYNK_SERVER_LEN      34
#define MAX_BLYNK_TOKEN_LEN       34

char Blynk_Server1 [MAX_BLYNK_SERVER_LEN + 1]  = "account.duckdns.org";
char Blynk_Token1  [MAX_BLYNK_TOKEN_LEN + 1]   = "token1";

char Blynk_Server2 [MAX_BLYNK_SERVER_LEN + 1]  = "account.ddns.net";
char Blynk_Token2  [MAX_BLYNK_TOKEN_LEN + 1]   = "token2";

#define MAX_BLYNK_PORT_LEN        6
char Blynk_Port   [MAX_BLYNK_PORT_LEN + 1]  = "8080";

#define MAX_MQTT_SERVER_LEN      34
char MQTT_Server  [MAX_MQTT_SERVER_LEN + 1]   = "mqtt.duckdns.org";

MenuItem myMenuItems [] =
{
  { "sv1", "Blynk Server1", Blynk_Server1,  MAX_BLYNK_SERVER_LEN },
  { "tk1", "Token1",        Blynk_Token1,   MAX_BLYNK_TOKEN_LEN },
  { "sv2", "Blynk Server2", Blynk_Server2,  MAX_BLYNK_SERVER_LEN },
  { "tk2", "Token2",        Blynk_Token2,   MAX_BLYNK_TOKEN_LEN },
  { "prt", "Port",          Blynk_Port,     MAX_BLYNK_PORT_LEN },
  { "mqt", "MQTT Server",   MQTT_Server,    MAX_MQTT_SERVER_LEN },
};

uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem);  //MenuItemSize;

#else

MenuItem myMenuItems [] = {};

uint16_t NUM_MENU_ITEMS = 0;

#endif    //USE_DYNAMIC_PARAMETERS

3. Not using custom parameters

  • If you don't need to add dynamic parameters, use the following in sketch
#define USE_DYNAMIC_PARAMETERS      false

4. To open Config Portal

  • When you want to open a config portal, just add
WiFiManager_Generic = new WiFiManager_Generic_Lite();
WiFiManager_Generic->begin();

5. To use different AP WiFi Channel

  • To not use default AP WiFi Channel 10 to avoid conflict with other WiFi APs :
WiFiManager_Generic->setConfigPortalChannel(newChannel);
  • To use random AP WiFi Channel to avoid conflict with other WiFi APs :
WiFiManager_Generic->setConfigPortalChannel(0);

6. To use different static AP IP from default

  • To use different static AP IP (not use default 192.168.4.1), call
WiFiManager_Generic->setConfigPortalIP(IPAddress(xxx,xxx,xxx,xxx));

7. To use custom DHCP HostName

  • To set custom DHCP HostName :
  // Set customized DHCP HostName
  WiFiManager_Generic->begin("SAMD_ABCDEF");

or just use the default Hostname, for example "SAMD_XXXXXX" for SAMD

  //Or use default Hostname "WIFI_GENERIC_XXXXXX"
  //WiFiManager_Generic->begin();

8. To use custom HTML Style

const char NewCustomsStyle[] /*PROGMEM*/ = "<style>div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}\
button{background-color:blue;color:white;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}</style>";

...

WiFiManager_Generic->setCustomsStyle(NewCustomsStyle);

9. To use custom Head Elements

WiFiManager_Generic->setCustomsHeadElement("<style>html{filter: invert(10%);}</style>");

10. To use CORS Header

WiFiManager_Generic->setCORSHeader("Your Access-Control-Allow-Origin");

While in AP mode, connect to it using its SSID (WIFI_GENERIC_XXXXXX) / Password ("MyWIFI_GENERIC_XXXXXX"), then open a browser to the Portal AP IP, default 192.168.4.1, configure wifi then click Save. The Credentials / WiFi connection information will be saved in non-volatile memory. It will then autoconnect.

Once Credentials / WiFi network information is saved in the host non-volatile memory, it will try to autoconnect to WiFi every time it is started, without requiring any function calls in the sketch.

11. To use and input only one set of WiFi SSID and PWD

11.1 If you need to use and input only one set of WiFi SSID/PWD

// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW       true

But it's always advisable to use and input both sets for reliability.

11.2 If you need to use both sets of WiFi SSID/PWD

// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW       false

12. To enable auto-scan of WiFi networks for selection in Configuration Portal

12.1 Enable auto-scan of WiFi networks for selection in Configuration Portal

#define SCAN_WIFI_NETWORKS                  true

The manual input of SSIDs is default enabled, so that users can input arbitrary SSID, not only from the scanned list. This is for the sample use-cases in which users can input the known SSIDs of another place, then send the boards to that place. The boards can connect to WiFi without users entering Config Portal to re-configure.

12.2 Disable manually input SSIDs

// To disable manually input SSID, only from a scanned SSID lists
#define MANUAL_SSID_INPUT_ALLOWED           false

This is for normal use-cases in which users can only select an SSID from a scanned list of SSIDs to avoid typo mistakes and/or security.

12.3 Select maximum number of SSIDs in the list

The maximum number of SSIDs in the list is selectable from 2 to 15 (for ESP8266/ESP32-AT shields, from 2-6). If invalid number of SSIDs is selected, the default number of 10 will be used.

// From 2-15
#define MAX_SSID_IN_LIST                    8

13. To avoid blocking in loop when WiFi is lost

13.1 Max times to try WiFi per loop

To define max times to try WiFi per loop() iteration. To avoid blocking issue in loop()

Default is 1 if not defined, and minimum is forced to be 1.

To use, uncomment in defines.h.

Check retries block the main loop #18

#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP     2

13.2 Interval between reconnection WiFi if lost

Default is no interval between reconnection WiFi times if lost WiFi. Max permitted interval will be 10mins.

Uncomment to use. Be careful, WiFi reconnection will be delayed if using this method.

Only use whenever urgent tasks in loop() can't be delayed. But if so, it's better you have to rewrite your code, e.g. using higher priority tasks.

Check retries block the main loop #18

#define WIFI_RECON_INTERVAL                   30000     // 30s

14. Not using Board_Name on Config_Portal

Default is true. Just change to false to Not using Board_Name on Config_Portal

/////////////////////////////////////////////

// Optional, to use Board Name in Menu
#define USING_BOARD_NAME                    false

/////////////////////////////////////////////

15. How to use CONFIG_MODE_LED

Check the examples

if (WiFi.status() == WL_CONNECTED)
Serial.print("H"); // H means connected to WiFi
else
{
if (WiFiManager_Generic->isConfigMode())
Serial.print("C"); // C means in Config Mode
else
Serial.print("F"); // F means not connected to WiFi
}

/////////////////////////////////////////////
// Optional, to use Board Name in Menu
#define USING_CONFIG_MODE_LED true
#if USING_CONFIG_MODE_LED
#if defined(LED_BUILTIN)
#define CONFIG_MODE_LED LED_BUILTIN
#else
// Using default pin 13 for CONFIG_MODE_LED. To be changed as necessary
#define CONFIG_MODE_LED 13
#endif
#define LED_ON HIGH
#define LED_OFF LOW
#endif
/////////////////////////////////////////////



Examples

  1. MKR1000_WiFi101
  2. MKR1000_WiFi101_MQTT
  3. nRF52_WiFi
  4. nRF52_WiFi_MQTT
  5. SAM_DUE_WiFi
  6. SAM_DUE_WiFi_MQTT
  7. SAMD_WiFi
  8. SAMD_WiFi_MQTT
  9. STM32_WiFi
  10. STM32_WiFi_MQTT
  11. Teensy_WiFi
  12. Teensy_WiFi_MQTT
  13. RP2040_WiFi
  14. RP2040_WiFi_MQTT
  15. RTL8720_WiFi New
  16. RTL8720_WiFi_MQTT New


So, how it works?

In Configuration Portal Mode, it starts an AP called WIFI_GENERIC_XXXXXX. Connect to it using the configurable password you can define in the code. For example, MyWIFI_GENERIC_XXXXXX (see examples):

After you connected, please, go to http://192.168.4.1 or newly configured AP IP, you'll see this Main page:

Enter your credentials,

1. Without SCAN_WIFI_NETWORKS

2. With SCAN_WIFI_NETWORKS

3. With SCAN_WIFI_NETWORKS for ESP8266-AT and ESP32-AT shield

The number of SSIDs in scanned list is limited at max 6.

then click Save.

The WiFi Credentials will be saved and the board connect to the selected WiFi AP.

If you're already connected to a listed WiFi AP and don't want to change anything, just select Exit from the Main page to reboot the board and connect to the previously-stored AP. The WiFi Credentials are still intact.


Important Notes

  1. Now you can use special chars such as ~, !, @, #, $, %, ^, &, _, -, space,etc. thanks to brondolin to provide the amazing fix in Blynk_WM to permit input special chars such as % and # into data fields. See Issue 3.
  2. The SSIDs, Passwords must be input (or to make them different from blank). Otherwise, the Config Portal will re-open until those fields have been changed. If you don't need any field, just input anything or use duplicated data from similar field.
  3. WiFi password max length now is 63 chars according to WPA2 standard.

How to use default Credentials and have them pre-loaded onto Config Portal

See this example and modify as necessary

1. To always load Default Credentials and override Config Portal data

// Used mostly for development and debugging. FORCES default values to be loaded each run.
// Config Portal data input will be ignored and overridden by DEFAULT_CONFIG_DATA
bool LOAD_DEFAULT_CONFIG_DATA = true;

2. To load Default Credentials when there is no valid Credentials.

Config Portal data input will be override DEFAULT_CONFIG_DATA

// Used mostly once debugged. Assumes good data already saved in device.
// Config Portal data input will be override DEFAULT_CONFIG_DATA
bool LOAD_DEFAULT_CONFIG_DATA = false;

3. Example of Default Credentials

/// Start Default Config Data //////////////////

/*
#define SSID_MAX_LEN      32
//From v1.0.3, WPA2 passwords can be up to 63 characters long.
#define PASS_MAX_LEN      64

typedef struct
{
  char wifi_ssid[SSID_MAX_LEN];
  char wifi_pw  [PASS_MAX_LEN];
}  WiFi_Credentials;

#define NUM_WIFI_CREDENTIALS      2

// Configurable items besides fixed Header, just add board_name 
#define NUM_CONFIGURABLE_ITEMS    ( ( 2 * NUM_WIFI_CREDENTIALS ) + 1 )
////////////////

typedef struct Configuration
{
  char header         [16];
  WiFi_Credentials  WiFi_Creds  [NUM_WIFI_CREDENTIALS];
  char board_name     [24];
  int  checkSum;
} WIFI_GENERIC_Configuration;
*/

#define TO_LOAD_DEFAULT_CONFIG_DATA      false

#if TO_LOAD_DEFAULT_CONFIG_DATA

// This feature is primarily used in development to force a known set of values as Config Data
// It will NOT force the Config Portal to activate. Use DRD or erase Config Data with Blynk.clearConfigData()

// Used mostly for development and debugging. FORCES default values to be loaded each run.
// Config Portal data input will be ignored and overridden by DEFAULT_CONFIG_DATA
//bool LOAD_DEFAULT_CONFIG_DATA = true;

// Used mostly once debugged. Assumes good data already saved in device.
// Config Portal data input will be override DEFAULT_CONFIG_DATA
bool LOAD_DEFAULT_CONFIG_DATA = false;


WIFI_GENERIC_Configuration defaultConfig =
{
  //char header[16], dummy, not used
  "WIFI_GENERIC",
  // WiFi_Credentials  WiFi_Creds  [NUM_WIFI_CREDENTIALS];
  // WiFi_Credentials.wifi_ssid and WiFi_Credentials.wifi_pw
  "SSID1",  "password1",
  "SSID2",  "password2",
  //char board_name     [24];
  "SAMD-Control",
  // terminate the list
  //int  checkSum, dummy, not used
  0
  /////////// End Default Config Data /////////////
};

#else

bool LOAD_DEFAULT_CONFIG_DATA = false;

WIFI_GENERIC_Configuration defaultConfig;

#endif    // TO_LOAD_DEFAULT_CONFIG_DATA

/////////// End Default Config Data /////////////

How to add dynamic parameters from sketch

Example of Default dynamicParams

  • To add custom parameters, just modify the example below
#include "defines.h"

// USE_DYNAMIC_PARAMETERS defined in defined.h

/////////////// Start dynamic Credentials ///////////////

//Defined in <WiFiManager_Generic_Lite.h>
/**************************************
  #define MAX_ID_LEN                5
  #define MAX_DISPLAY_NAME_LEN      16

  typedef struct
  {
  char id             [MAX_ID_LEN + 1];
  char displayName    [MAX_DISPLAY_NAME_LEN + 1];
  char *pdata;
  uint8_t maxlen;
  } MenuItem;
**************************************/

#if USE_DYNAMIC_PARAMETERS

#define MAX_BLYNK_SERVER_LEN      34
#define MAX_BLYNK_TOKEN_LEN       34

char Blynk_Server1 [MAX_BLYNK_SERVER_LEN + 1]  = "account.duckdns.org";
char Blynk_Token1  [MAX_BLYNK_TOKEN_LEN + 1]   = "token1";

char Blynk_Server2 [MAX_BLYNK_SERVER_LEN + 1]  = "account.ddns.net";
char Blynk_Token2  [MAX_BLYNK_TOKEN_LEN + 1]   = "token2";

#define MAX_BLYNK_PORT_LEN        6
char Blynk_Port   [MAX_BLYNK_PORT_LEN + 1]  = "8080";

#define MAX_MQTT_SERVER_LEN      34
char MQTT_Server  [MAX_MQTT_SERVER_LEN + 1]   = "mqtt.duckdns.org";

MenuItem myMenuItems [] =
{
  { "sv1", "Blynk Server1", Blynk_Server1,  MAX_BLYNK_SERVER_LEN },
  { "tk1", "Token1",        Blynk_Token1,   MAX_BLYNK_TOKEN_LEN },
  { "sv2", "Blynk Server2", Blynk_Server2,  MAX_BLYNK_SERVER_LEN },
  { "tk2", "Token2",        Blynk_Token2,   MAX_BLYNK_TOKEN_LEN },
  { "prt", "Port",          Blynk_Port,     MAX_BLYNK_PORT_LEN },
  { "mqt", "MQTT Server",   MQTT_Server,    MAX_MQTT_SERVER_LEN },
};

uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem);  //MenuItemSize;

#else

MenuItem myMenuItems [] = {};

uint16_t NUM_MENU_ITEMS = 0;

#endif    //USE_DYNAMIC_PARAMETERS
  • If you don't need to add dynamic parameters, use the following in sketch
#define USE_DYNAMIC_PARAMETERS     false

or

/////////////// Start dynamic Credentials ///////////////

MenuItem myMenuItems [] = {};

uint16_t NUM_MENU_ITEMS = 0;
/////// // End dynamic Credentials ///////////

Important Notes for using Dynamic Parameters' ids

  1. These ids (such as "mqtt" in example) must be unique.

Please be noted that the following reserved names are already used in library:

"id"    for WiFi SSID
"pw"    for WiFi PW
"id1"   for WiFi1 SSID
"pw1"   for WiFi1 PW
"nm"    for Board Name


Example SAMD_WiFi

Please take a look at other examples, as well.

#include "defines.h"
#include "Credentials.h"
#include "dynamicParams.h"
WiFiManager_Generic_Lite* WiFiManager_Generic;
void heartBeatPrint(void)
{
static int num = 1;
if (WiFi.status() == WL_CONNECTED)
Serial.print("H"); // H means connected to WiFi
else
{
if (WiFiManager_Generic->isConfigMode())
Serial.print("C"); // C means in Config Mode
else
Serial.print("F"); // F means not connected to WiFi
}
if (num == 80)
{
Serial.println();
num = 1;
}
else if (num++ % 10 == 0)
{
Serial.print(F(" "));
}
}
void check_status()
{
static unsigned long checkstatus_timeout = 0;
//KH
#define HEARTBEAT_INTERVAL 20000L
// Print hearbeat every HEARTBEAT_INTERVAL (20) seconds.
if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
{
heartBeatPrint();
checkstatus_timeout = millis() + HEARTBEAT_INTERVAL;
}
}
#if USING_CUSTOMS_STYLE
const char NewCustomsStyle[] /*PROGMEM*/ = "<style>div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}\
button{background-color:blue;color:white;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}</style>";
#endif
void setup()
{
// Debug console
Serial.begin(115200);
while (!Serial && millis() < 5000);
delay(200);
Serial.print(F("\nStart SAMD_WiFi on ")); Serial.print(BOARD_NAME);
Serial.print(F(" with ")); Serial.println(SHIELD_TYPE);
#if (USE_WIFI_NINA || USE_WIFI101)
Serial.println(WIFIMULTI_GENERIC_VERSION);
#endif
Serial.println(WIFI_MANAGER_GENERIC_LITE_VERSION);
#if ( USE_WIFI_CUSTOM && USE_ESP_AT_SHIELD )
// initialize serial for ESP module
EspSerial.begin(115200);
// initialize ESP module
WiFi.init(&EspSerial);
Serial.println(F("WiFi shield init done"));
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD)
{
Serial.println(F("WiFi shield not present"));
// don't continue
while (true);
}
#endif
WiFiManager_Generic = new WiFiManager_Generic_Lite();
// Optional to change default AP IP(192.168.4.1) and channel(10)
//WiFiManager_Generic->setConfigPortalIP(IPAddress(192, 168, 120, 1));
WiFiManager_Generic->setConfigPortalChannel(0);
#if USING_CUSTOMS_STYLE
WiFiManager_Generic->setCustomsStyle(NewCustomsStyle);
#endif
#if USING_CUSTOMS_HEAD_ELEMENT
WiFiManager_Generic->setCustomsHeadElement("<style>html{filter: invert(10%);}</style>");
#endif
#if USING_CORS_FEATURE
WiFiManager_Generic->setCORSHeader("Your Access-Control-Allow-Origin");
#endif
// Set customized DHCP HostName
WiFiManager_Generic->begin(HOST_NAME);
//Or use default Hostname "SAMD-WIFI-XXXXXX"
//WiFiManager_Generic->begin();
}
#if USE_DYNAMIC_PARAMETERS
void displayCredentials()
{
Serial.println(F("\nYour stored Credentials :"));
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
{
Serial.print(myMenuItems[i].displayName);
Serial.print(F(" = "));
Serial.println(myMenuItems[i].pdata);
}
}
void displayCredentialsInLoop()
{
static bool displayedCredentials = false;
if (!displayedCredentials)
{
for (int i = 0; i < NUM_MENU_ITEMS; i++)
{
if (!strlen(myMenuItems[i].pdata))
{
break;
}
if ( i == (NUM_MENU_ITEMS - 1) )
{
displayedCredentials = true;
displayCredentials();
}
}
}
}
#endif
void loop()
{
WiFiManager_Generic->run();
check_status();
#if USE_DYNAMIC_PARAMETERS
displayCredentialsInLoop();
#endif
}


2. File defines.h

#ifndef defines_h
#define defines_h
/* Comment this out to disable prints and save space */
#define DEBUG_WIFI_WEBSERVER_PORT Serial
#define WIFI_GENERIC_DEBUG_OUTPUT Serial
#define _WIFI_GENERIC_LOGLEVEL_ 1
#define _WIFIMULTI_LOGLEVEL_ 1
#define DRD_GENERIC_DEBUG true
#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
|| defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \
|| defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) \
|| defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD51__) || defined(__SAMD51J20A__) \
|| defined(__SAMD51J19A__) || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) \
|| defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \
|| defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \
|| defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) )
#if defined(WIFI_GENERIC_USE_SAMD)
#undef WIFI_GENERIC_USE_SAMD
#undef WIFI_USE_SAMD
#endif
#define WIFI_GENERIC_USE_SAMD true
#define WIFI_USE_SAMD true
#else
#error This code is intended to run only on the SAMD boards ! Please check your Tools->Board setting.
#endif
#if defined(WIFI_GENERIC_USE_SAMD)
#if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) )
#define BOARD_TYPE "SAMD Zero"
#elif defined(ARDUINO_SAMD_MKR1000)
#define BOARD_TYPE "SAMD MKR1000"
#elif defined(ARDUINO_SAMD_MKRWIFI1010)
#define BOARD_TYPE "SAMD MKRWIFI1010"
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
#define BOARD_TYPE "SAMD NANO_33_IOT"
#elif defined(ARDUINO_SAMD_MKRFox1200)
#define BOARD_TYPE "SAMD MKRFox1200"
#elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) )
#define BOARD_TYPE "SAMD MKRWAN13X0"
#elif defined(ARDUINO_SAMD_MKRGSM1400)
#define BOARD_TYPE "SAMD MKRGSM1400"
#elif defined(ARDUINO_SAMD_MKRNB1500)
#define BOARD_TYPE "SAMD MKRNB1500"
#elif defined(ARDUINO_SAMD_MKRVIDOR4000)
#define BOARD_TYPE "SAMD MKRVIDOR4000"
#elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)
#define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS"
#elif defined(ADAFRUIT_FEATHER_M0_EXPRESS)
#define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS"
#elif defined(ADAFRUIT_METRO_M0_EXPRESS)
#define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS"
#elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0"
#elif defined(ADAFRUIT_GEMMA_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0"
#elif defined(ADAFRUIT_TRINKET_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0"
#elif defined(ADAFRUIT_ITSYBITSY_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0"
#elif defined(ARDUINO_SAMD_HALLOWING_M0)
#define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0"
#elif defined(ADAFRUIT_METRO_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS"
#elif defined(ADAFRUIT_GRAND_CENTRAL_M4)
#define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4"
#elif defined(ADAFRUIT_FEATHER_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS"
#elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS"
#elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS"
#elif defined(ADAFRUIT_PYPORTAL)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL"
#elif defined(ADAFRUIT_PYPORTAL_M4_TITANO)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO"
#elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS"
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)
#define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE"
#elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS"
#elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS"
#elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4"
#elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS"
#elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS"
#elif defined(SEEED_WIO_TERMINAL)
#define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL"
#elif defined(SEEED_FEMTO_M0)
#define BOARD_TYPE "SAMD SEEED_FEMTO_M0"
#elif defined(SEEED_XIAO_M0)
#define BOARD_TYPE "SAMD SEEED_XIAO_M0"
#elif defined(Wio_Lite_MG126)
#define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126"
#elif defined(WIO_GPS_BOARD)
#define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD"
#elif defined(SEEEDUINO_ZERO)
#define BOARD_TYPE "SAMD SEEEDUINO_ZERO"
#elif defined(SEEEDUINO_LORAWAN)
#define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN"
#elif defined(SEEED_GROVE_UI_WIRELESS)
#define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS"
#elif defined(__SAMD21E18A__)
#define BOARD_TYPE "SAMD21E18A"
#elif defined(__SAMD21G18A__)
#define BOARD_TYPE "SAMD21G18A"
#elif defined(__SAMD51G19A__)
#define BOARD_TYPE "SAMD51G19A"
#elif defined(__SAMD51J19A__)
#define BOARD_TYPE "SAMD51J19A"
#elif defined(__SAMD51J20A__)
#define BOARD_TYPE "SAMD51J20A"
#elif defined(__SAM3X8E__)
#define BOARD_TYPE "SAM3X8E"
#elif defined(__CPU_ARC__)
#define BOARD_TYPE "CPU_ARC"
#elif defined(__SAMD51__)
#define BOARD_TYPE "SAMD51"
#else
#define BOARD_TYPE "SAMD Unknown"
#endif
#endif
// Start location in EEPROM to store config data. Default 0
// Config data Size currently is 128 bytes)
#define EEPROM_START 0
#define EEPROM_SIZE (2 * 1024)
/////////////////////////////////////////////
// Add customs headers from v1.1.0
#define USING_CUSTOMS_STYLE true
#define USING_CUSTOMS_HEAD_ELEMENT true
#define USING_CORS_FEATURE true
/////////////////////////////////////////////
#define USE_WIFI_NINA true
#define USE_WIFI101 false
#define USE_WIFI_CUSTOM false
#if USE_WIFI_NINA
#warning Using WIFININA_Generic Library
#define SHIELD_TYPE "WiFiNINA using WiFiNINA_Generic Library"
#include "WiFiNINA_Pinout_Generic.h"
#elif USE_WIFI101
#if defined(USE_WIFI_NINA)
#undef USE_WIFI_NINA
#endif
#define USE_WIFI_NINA false
#define SHIELD_TYPE "WINC1500 using WiFi101 Library"
#warning Using WiFi101 Library
#elif USE_WIFI_CUSTOM
#if defined(USE_WIFI_NINA)
#undef USE_WIFI_NINA
#endif
#define USE_WIFI_NINA false
#if defined(USE_WIFI101)
#undef USE_WIFI101
#endif
#define USE_WIFI101 false
#define SHIELD_TYPE "Custom using Custom WiFi Library"
#warning Using Custom WiFi Library. You must include here or compile error
// For SAMD
#define EspSerial Serial1
#include "ESP8266_AT_WebServer.h"
#define USE_ESP_AT_SHIELD true
#define WiFiWebServer ESP8266_AT_WebServer
#else
#define SHIELD_TYPE "Default WiFi using WiFi Library"
#warning Using fallback WiFi.h Library defined in WiFiWebServer Library.
#endif
/////////////////////////////////////////////
// Permit running CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET times before reset hardware
// to permit user another chance to config. Only if Config Data is valid.
// If Config Data is invalid, this has no effect as Config Portal will persist
#define RESET_IF_CONFIG_TIMEOUT true
// Permitted range of user-defined RETRY_TIMES_RECONNECT_WIFI between 2-5 times
#define RETRY_TIMES_RECONNECT_WIFI 3
// Permitted range of user-defined CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET between 2-100
#define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5
// Config Timeout 120s (default 60s). Applicable only if Config Data is Valid
#define CONFIG_TIMEOUT 120000L
/////////////////////////////////////////////
// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW true //false
// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
// Default 1 if not defined, and minimum 1.
//#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2
// Default no interval between recon WiFi if lost
// Max permitted interval will be 10mins
// Uncomment to use. Be careful, WiFi reconnect will be delayed if using this method
// Only use whenever urgent tasks in loop() can't be delayed. But if so, it's better you have to rewrite your code, e.g. using higher priority tasks.
//#define WIFI_RECON_INTERVAL 30000
/////////////////////////////////////////////
#define USE_DYNAMIC_PARAMETERS true
/////////////////////////////////////////////
#define SCAN_WIFI_NETWORKS true
// To be able to manually input SSID, not from a scanned SSID lists
#define MANUAL_SSID_INPUT_ALLOWED true
/////////////////////////////////////////////
#if (USE_WIFI_CUSTOM && USE_ESP_AT_SHIELD)
// ESP-AT can't use longer than 2K HTML and DYNAMIC_PARAMETERS
#undef USE_DYNAMIC_PARAMETERS
#define USE_DYNAMIC_PARAMETERS false
#warning Disable USE_DYNAMIC_PARAMETERS for ESP_AT_SHIELD
// From 2-6 to keep HTML short for ESP8266-AT. Limited 6 in WiFiEspAT library anyway
#define MAX_SSID_IN_LIST 4
#else
// From 2-15
#define MAX_SSID_IN_LIST 8
#endif
/////////////////////////////////////////////
// Optional, to use Board Name in Menu
#define USING_BOARD_NAME true
/////////////////////////////////////////////
// Optional, to use Board Name in Menu
#define USING_CONFIG_MODE_LED true
#if USING_CONFIG_MODE_LED
#if defined(LED_BUILTIN)
#define CONFIG_MODE_LED LED_BUILTIN
#else
// Using default pin 13 for CONFIG_MODE_LED. To be changed as necessary
#define CONFIG_MODE_LED 13
#endif
#define LED_ON HIGH
#define LED_OFF LOW
#endif
/////////////////////////////////////////////
#include <WiFiManager_Generic_Lite.h>
#define HOST_NAME "SAMD-Master-Controller"
#ifdef LED_BUILTIN
#define LED_PIN LED_BUILTIN
#else
#define LED_PIN 13
#endif
#endif //defines_h


#ifndef Credentials_h
#define Credentials_h
#include "defines.h"
/// Start Default Config Data //////////////////
/*
#define SSID_MAX_LEN 32
//From v1.0.3, WPA2 passwords can be up to 63 characters long.
#define PASS_MAX_LEN 64
typedef struct
{
char wifi_ssid[SSID_MAX_LEN];
char wifi_pw [PASS_MAX_LEN];
} WiFi_Credentials;
#define NUM_WIFI_CREDENTIALS 2
// Configurable items besides fixed Header, just add board_name
#define NUM_CONFIGURABLE_ITEMS ( ( 2 * NUM_WIFI_CREDENTIALS ) + 1 )
////////////////
typedef struct Configuration
{
char header [16];
WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS];
char board_name [24];
int checkSum;
} WIFI_GENERIC_Configuration;
*/
#define TO_LOAD_DEFAULT_CONFIG_DATA false
#if TO_LOAD_DEFAULT_CONFIG_DATA
// This feature is primarily used in development to force a known set of values as Config Data
// It will NOT force the Config Portal to activate. Use DRD or erase Config Data with Blynk.clearConfigData()
// Used mostly for development and debugging. FORCES default values to be loaded each run.
// Config Portal data input will be ignored and overridden by DEFAULT_CONFIG_DATA
//bool LOAD_DEFAULT_CONFIG_DATA = true;
// Used mostly once debugged. Assumes good data already saved in device.
// Config Portal data input will be override DEFAULT_CONFIG_DATA
bool LOAD_DEFAULT_CONFIG_DATA = false;
WIFI_GENERIC_Configuration defaultConfig =
{
//char header[16], dummy, not used
"WIFI_GENERIC",
// WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS];
// WiFi_Credentials.wifi_ssid and WiFi_Credentials.wifi_pw
"SSID1", "password1",
"SSID2", "password2",
//char board_name [24];
"SAMD-Control",
// terminate the list
//int checkSum, dummy, not used
0
/////////// End Default Config Data /////////////
};
#else
bool LOAD_DEFAULT_CONFIG_DATA = false;
WIFI_GENERIC_Configuration defaultConfig;
#endif // TO_LOAD_DEFAULT_CONFIG_DATA
/////////// End Default Config Data /////////////
#endif //Credentials_h


#ifndef dynamicParams_h
#define dynamicParams_h
#include "defines.h"
// USE_DYNAMIC_PARAMETERS defined in defined.h
/////////////// Start dynamic Credentials ///////////////
//Defined in <WiFiManager_Generic_Lite_SAMD.h>
/**************************************
#define MAX_ID_LEN 5
#define MAX_DISPLAY_NAME_LEN 16
typedef struct
{
char id [MAX_ID_LEN + 1];
char displayName [MAX_DISPLAY_NAME_LEN + 1];
char *pdata;
uint8_t maxlen;
} MenuItem;
**************************************/
#if USE_DYNAMIC_PARAMETERS
#define MAX_BLYNK_SERVER_LEN 34
#define MAX_BLYNK_TOKEN_LEN 34
char Blynk_Server1 [MAX_BLYNK_SERVER_LEN + 1] = "account.duckdns.org";
char Blynk_Token1 [MAX_BLYNK_TOKEN_LEN + 1] = "token1";
char Blynk_Server2 [MAX_BLYNK_SERVER_LEN + 1] = "account.ddns.net";
char Blynk_Token2 [MAX_BLYNK_TOKEN_LEN + 1] = "token2";
#define MAX_BLYNK_PORT_LEN 6
char Blynk_Port [MAX_BLYNK_PORT_LEN + 1] = "8080";
#define MAX_MQTT_SERVER_LEN 34
char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.duckdns.org";
MenuItem myMenuItems [] =
{
{ "sv1", "Blynk Server1", Blynk_Server1, MAX_BLYNK_SERVER_LEN },
{ "tk1", "Token1", Blynk_Token1, MAX_BLYNK_TOKEN_LEN },
{ "sv2", "Blynk Server2", Blynk_Server2, MAX_BLYNK_SERVER_LEN },
{ "tk2", "Token2", Blynk_Token2, MAX_BLYNK_TOKEN_LEN },
{ "prt", "Port", Blynk_Port, MAX_BLYNK_PORT_LEN },
{ "mqt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN },
};
uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize;
#else
MenuItem myMenuItems [] = {};
uint16_t NUM_MENU_ITEMS = 0;
#endif //USE_DYNAMIC_PARAMETERS
#endif //dynamicParams_h



Debug Terminal output Samples

1. SAMD_WiFi example on Nano-33 IoT

This is the terminal output when running SAMD_WiFi example on Nano-33 IoT:

1.1 Open Config Portal

Start SAMD_WiFi on SAMD_NANO_33_IOT with WiFiNINA using WiFiNINA_Generic Library
WiFiManager_Generic_Lite v1.8.0
[WG] Hostname=SAMD-Master-Controller
Flag read = 0xffffffff
No doubleResetDetected
SetFlag write = 0xd0d01234
[WG] ======= Start Default Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=SSID1,PW=password1
[WG] SSID1=SSID2,PW1=password2
[WG] BName=SAMD-Control
[WG] i=0,id=sv1,data=account.duckdns.org
[WG] i=1,id=tk1,data=token1
[WG] i=2,id=sv2,data=account.ddns.net
[WG] i=3,id=tk2,data=token2
[WG] i=4,id=pt,data=8080
[WG] i=5,id=mq,data=mqtt.duckdns.org
[WG] ChkCrR:CrCCsum=0xaf50,CrRCsum=0xffffffff
[WG] CCSum=0x1360,RCSum=0x0
[WG] Invalid Stored Dynamic Data. Load default from Sketch
[WG] SaveEEPROM,sz=1024,Datasz=0,CSum=0x109a
[WG] CrCCSum=0x1981
[WG] ======= Start Loaded Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=SSID1,PW=password1
[WG] SSID1=SSID2,PW1=password2
[WG] BName=SAMD-Control
[WG] i=0,id=sv1,data=account.duckdns.org
[WG] i=1,id=tk1,data=token1
[WG] i=2,id=sv2,data=account.ddns.net
[WG] i=3,id=tk2,data=token2
[WG] i=4,id=pt,data=8080
[WG] i=5,id=mq,data=mqtt.duckdns.org
[WG] b:StayInCfgPortal:NoCfgDat
[WG] SSID=WIFI_GENERIC_51F485,PW=MyWIFI_GENERIC_51F485
[WG] IP=192.168.4.1,CH=10
WiFi-beginAP3: return1 = 7
WiFi-beginAP3: return2 = 7
C
Your stored Credentials :
Blynk Server1 = account.duckdns.org
Token1 = token1
Blynk Server2 = account.ddns.net
Token2 = token2
Port = 8080
MQTT Server = mqtt.duckdns.org
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
CCCCCCCCC

1.2 Received data from Config Portal

[WG] h: Init menuItemUpdated :6
[WG] h:repl id
[WG] h:items updated =1
[WG] h:key =id, value =HueNet1
[WG] h:repl pw
[WG] h:items updated =2
[WG] h:key =pw, value =12345678
[WG] h:repl id1
[WG] h:items updated =3
[WG] h:key =id1, value =HueNet2
[WG] h:repl pw1
[WG] h:items updated =4
[WG] h:key =pw1, value =12345678
[WG] h:repl nm
[WG] h:items updated =5
[WG] h:key =nm, value =Nano_33_IoT
[WG] h:sv1=account.duckdns.org
[WG] h:items updated =6
[WG] h:key =sv1, value =account.duckdns.org
[WG] h:tk1=token1
[WG] h:items updated =7
[WG] h:key =tk1, value =token1
[WG] h:sv2=192.168.2.32
[WG] h:items updated =8
[WG] h:key =sv2, value =192.168.2.32
[WG] h:tk2=token2
[WG] h:items updated =9
[WG] h:key =tk2, value =token2
[WG] h:prt=8080
[WG] h:items updated =10
[WG] h:key =prt, value =8080
[WG] h:mqt=mqtt_server
[WG] h:items updated =11
[WG] h:key =mqt, value =mqtt_server
[WG] h:UpdEEPROM
[WG] SaveEEPROM,Sz=1024,DataSz=0,WCSum=0x130e
[WG] pdata=account.duckdns.org,len=34
[WG] pdata=token1,len=34
[WG] pdata=192.168.2.32,len=34
[WG] pdata=token2,len=34
[WG] pdata=8080,len=6
[WG] pdata=mqtt_server,len=34
[WG] CrCCSum=0x1330
[WG] h:Rst

1.3 Got valid Credential from Config Portal, then connected to WiFi

Start SAMD_WiFi on SAMD_NANO_33_IOT with WiFiNINA using WiFiNINA_Generic Library
WiFiManager_Generic_Lite v1.8.0
[WG] Hostname=SAMD-Master-Controller
Flag read = 0xd0d04321
No doubleResetDetected
SetFlag write = 0xd0d01234
[WG] CCSum=0x130e,RCSum=0x130e
[WG] ChkCrR:CrCCsum=0x1330,CrRCsum=0x1330
[WG] CrCCSum=1330,CrRCSum=1330
[WG] Valid Stored Dynamic Data
[WG] ======= Start Stored Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=HueNet1,PW=12345678
[WG] SSID1=HueNet2,PW1=12345678
[WG] BName=Nano_33_IoT
[WG] i=0,id=sv1,data=account.duckdns.org
[WG] i=1,id=tk1,data=token1
[WG] i=2,id=sv2,data=192.168.2.32
[WG] i=3,id=tk2,data=token2
[WG] i=4,id=prt,data=8080
[WG] i=5,id=mqt,data=mqtt_server
[WG] WiFi connected after time: 1
[WG] SSID:HueNet1,RSSI=-20
[WG] IP address:192.168.2.148
[WG] b:WOK
H
Your stored Credentials :
Blynk Server1 = account.duckdns.org
Token1 = token1
Blynk Server2 = 192.168.2.32
Token2 = token2
Port = 8080
MQTT Server = mqtt_server
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH
HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH HHHHHHHHHH

1.4 Lost a WiFi and autoconnect to another WiFi AP

[WG] r:Check&WLost                      <=== Lost primary WiFi
[WG] r:WLost.ReconW
[WG] WiFi connected after time: 1
[WG] SSID:HueNet2,RSSI=-50              <=== Connect secondary WiFi
[WG] IP address:192.168.2.113
[WG] r:WOK                              <=== Success
HHHHHHHHHH HHHHHHHHHH

1.5 Reopen Config Portal if can't connect to any of the 2 WiFi APs

Start SAMD_WiFi on SAMD_NANO_33_IOT with WiFiNINA using WiFiNINA_Generic Library
WiFiManager_Generic_Lite v1.8.0
[WG] Hostname=SAMD-Master-Controller
Flag read = 0xd0d04321
No doubleResetDetected
SetFlag write = 0xd0d01234
[WG] ======= Start Default Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=SSID1,PW=password1
[WG] SSID1=SSID2,PW1=password2
[WG] BName=SAMD-Control
[WG] i=0,id=sv1,data=account.duckdns.org
[WG] i=1,id=tk1,data=token1
[WG] i=2,id=sv2,data=account.ddns.net
[WG] i=3,id=tk2,data=token2
[WG] i=4,id=pt,data=8080
[WG] i=5,id=mq,data=mqtt.duckdns.org
[WG] ChkCrR:CrCCsum=0x21ce,CrRCsum=0x21ce
[WG] CCSum=0x1246,RCSum=0x1246
[WG] CrCCsum=0x21ce,CrRCsum=0x21ce
[WG] Valid Stored Dynamic Data
[WG] ======= Start Stored Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=HueNet1,PW=****
[WG] SSID1=HueNet2,PW1=****
[WG] BName=Air-Control
[WG] i=0,id=sv1,data=new_account.duckdns.org
[WG] i=1,id=tk1,data=new_token1
[WG] i=2,id=sv2,data=new_account.ddns.net
[WG] i=3,id=tk2,data=new_token2
[WG] i=4,id=pt,data=8080
[WG] i=5,id=mq,data=new_mqtt.duckdns.org
[WG] ConMultiWifi
[WG] con2WF:SSID=SSID,PW=password
[WG] Remaining retry_time=3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
[WG] Remaining retry_time=2
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
[WG] Remaining retry_time=1
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
[WG] Failed using index=0, retry_time=0
[WG] con2WF:failed
[WG] b:NoW
[WG] SSID=WIFI_GENERIC_51F485,PW=MyWIFI_GENERIC_51F485
[WG] IP=192.168.4.1,CH=10
WiFi-beginAP3: return1 = 7
WiFi-beginAP3: return2 = 7
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
C
Your stored Credentials :
Blynk Server1 = new_account.duckdns.org
Token1 = new_token1
Blynk Server2 = new_account.ddns.net
Token2 = new_token2
Port = 8080
MQTT Server = new_mqtt.duckdns.org
CCCC

1.6 DRD Not Detected:

Start SAMD_WiFi on SAMD_NANO_33_IOT with WiFiNINA using WiFiNINA_Generic Library
WiFiManager_Generic_Lite v1.8.0
[WG] Hostname=SAMD-Master-Controller
Flag read = 0xd0d04321
No doubleResetDetected
SetFlag write = 0xd0d01234
[WG] ======= Start Default Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=SSID1,PW=password1
[WG] SSID1=SSID2,PW1=password2
[WG] BName=SAMD-Control
[WG] i=0,id=sv1,data=account.duckdns.org
[WG] i=1,id=tk1,data=token1
[WG] i=2,id=sv2,data=account.ddns.net
[WG] i=3,id=tk2,data=token2
[WG] i=4,id=pt,data=8080
[WG] i=5,id=mq,data=mqtt.duckdns.org
[WG] ChkCrR:CrCCsum=0x21ce,CrRCsum=0x21ce
[WG] CCSum=0x1246,RCSum=0x1246
[WG] CrCCsum=0x21ce,CrRCsum=0x21ce
[WG] Valid Stored Dynamic Data
[WG] ======= Start Stored Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=HueNet1,PW=****
[WG] SSID1=HueNet2,PW1=****
[WG] BName=Air-Control
[WG] i=0,id=sv1,data=new_account.duckdns.org
[WG] i=1,id=tk1,data=new_token1
[WG] i=2,id=sv2,data=new_account.ddns.net
[WG] i=3,id=tk2,data=new_token2
[WG] i=4,id=pt,data=8080
[WG] i=5,id=mq,data=new_mqtt.duckdns.org
[WG] WiFi connected after time: 1
[WG] SSID:HueNet1,RSSI=-20
[WG] IP address:192.168.2.105
[WG] b:WOK
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
H
Your stored Credentials :
Blynk Server1 = new_account.duckdns.org
Token1 = new_token1
Blynk Server2 = new_account.ddns.net
Token2 = new_token2
Port = 8080
MQTT Server = new_mqtt.duckdns.org
HHHHHHHHH HHHHHHHHHH

1.7 DRD detected and Config Portal is forcefully opened

Start SAMD_WiFi on SAMD_NANO_33_IOT with WiFiNINA using WiFiNINA_Generic Library
WiFiManager_Generic_Lite v1.8.0
[WG] Hostname=SAMD-Master-Controller
Flag read = 0xd0d01234
doubleResetDetected
ClearFlag write = 0xd0d04321
[WG] Double Reset Detected
[WG] ======= Start Default Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=SSID1,PW=password1
[WG] SSID1=SSID2,PW1=password2
[WG] BName=SAMD-Control
[WG] i=0,id=sv1,data=account.duckdns.org
[WG] i=1,id=tk1,data=token1
[WG] i=2,id=sv2,data=account.ddns.net
[WG] i=3,id=tk2,data=token2
[WG] i=4,id=pt,data=8080
[WG] i=5,id=mq,data=mqtt.duckdns.org
[WG] ChkCrR:CrCCsum=0x21ce,CrRCsum=0x21ce
[WG] CCSum=0x1246,RCSum=0x1246
[WG] CrCCsum=0x21ce,CrRCsum=0x21ce
[WG] Valid Stored Dynamic Data
[WG] ======= Start Stored Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=HueNet1,PW=****
[WG] SSID1=HueNet2,PW1=****
[WG] BName=Air-Control
[WG] i=0,id=sv1,data=new_account.duckdns.org
[WG] i=1,id=tk1,data=new_token1
[WG] i=2,id=sv2,data=new_account.ddns.net
[WG] i=3,id=tk2,data=new_token2
[WG] i=4,id=pt,data=8080
[WG] i=5,id=mq,data=new_mqtt.duckdns.org
[WG] b:StayInCfgPortal:DRD
[WG] SSID=WIFI_GENERIC_51F485,PW=MyWIFI_GENERIC_51F485
[WG] IP=192.168.4.1,CH=10
WiFi-beginAP3: return1 = 7
WiFi-beginAP3: return2 = 7
C
Your stored Credentials :
Blynk Server1 = new_account.duckdns.org
Token1 = new_token1
Blynk Server2 = new_account.ddns.net
Token2 = new_token2
Port = 8080
MQTT Server = new_mqtt.duckdns.org
CCCCC

2. SAMD_WiFi on ITSYBITSY_M4 using Custom WiFi Library

This is the terminal output when running SAMD_WiFi example on Adafruit SAMD51 ITSYBITSY_M4:

2.1 Open Config Portal

Start SAMD_WiFi on ITSYBITSY_M4 with Custom using Custom WiFi Library
WiFiManager_Generic_Lite v1.8.0
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
[WG] Hostname=SAMD-Master-Controller
Flag read = 0xffffffff
No doubleResetDetected
SetFlag write = 0xd0d01234
[WG] CCSum=0xe11e,RCSum=0xffffffff
[WG] InitCfgFile,sz=236
[WG] SaveEEPROM,Sz=1024,DataSz=0,WCSum=0xdb3
[WG] bg: isForcedConfigPortal = false
[WG] bg:Stay forever in CP:No ConfigDat
[WG] Scanning Network
[WG] scanWifiNetworks: Done, Scanned Networks n = 9
[WG] Sorting
[WG] Removing Dup
[WG] DUP AP:Waterhome
[WG] DUP AP:
[WG] WiFi networks found:
[WG] 1: HueNet1, -44dB
[WG] 2: HueNetTek, -32dB
[WG] 3: HueNet2, -58dB
[WG] 4: bacau, -82dB
[WG] 5: dlink-4F96, -86dB
[WG] 6: Waterhome, -88dB
[WG] 7: , -84dB
[WG] 9: BELL627, -63dB
[WG] SSID=WIFI_GENERIC_51F485,PW=MyWIFI_GENERIC_51F485
[WG] IP=192.168.4.1,CH=1
[WG] s:configTimeout = 0
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
C

2.2 Got valid Credential from Config Portal, then connected to WiFi

Start SAMD_WiFi on ITSYBITSY_M4 with Custom using Custom WiFi Library
WiFiManager_Generic_Lite v1.8.0
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
[WG] Hostname=SAMD-Master-Controller
Flag read = 0xd0d04321
No doubleResetDetected
SetFlag write = 0xd0d01234
[WG] CCSum=0x14eb,RCSum=0x14eb
[WG] ======= Start Stored Config Data =======
[WG] Hdr=WIFI_GENERIC,SSID=HueNet1,PW=12345678
[WG] SSID1=HueNet2,PW1=12345678
[WG] BName=Itsy-Bitsy-SAMD51
[WG] WiFi connected after time: 1
[WG] SSID:HueNet1,RSSI=-20
[WG] IP address:192.168.2.154
[WG] b:WOK
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
HHH


Debug

Debug is enabled by default on Serial. To disable, add at the beginning of sketch

/* Comment this out to disable prints and save space */
#define DEBUG_WIFI_WEBSERVER_PORT     Serial
#define WIFI_GENERIC_DEBUG_OUTPUT     Serial

#define _WIFI_GENERIC_LOGLEVEL_       4

#define DRD_GENERIC_DEBUG             true

Troubleshooting

If you get compilation errors, more often than not, you may need to install a newer version of the board's core, Generic WiFi (WiFiNINA, WINC1500/WiFi101, ESP8266/ESP32-AT, etc.) module/shield libraries or this library version.

Sometimes, the library will only work if you update the Generic WiFi module/shield core to the newer or older version because some function compatibility.



Issues

Submit issues to: WiFiManager_Generic_Lite issues



TO DO

  1. Support more boards, shields and libraries
  2. Bug Searching and Killing

DONE

  1. Permit EEPROM size and location configurable to avoid conflict with others.
  2. More flexible to configure reconnection timeout.
  3. For fresh config data, don't need to wait for connecting timeout before entering config portal.
  4. If the config data not entered completely (SSIDs, Passwords, etc.), entering config portal
  5. Add configurable Config Portal IP, SSID and Password
  6. Change Synch XMLHttpRequest to Async
  7. Add configurable Static IP, GW, Subnet Mask and 2 DNS Servers' IP Addresses.
  8. Add checksums
  9. Add support to nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, SAM-DUE
  10. Add support to WiFiNINA, WINC1500/WiFi101, ESP8266/ESP32-AT, etc. shields.
  11. Add MultiWiFi features with auto(re)connect
  12. Easy-to-use Dynamic Parameters without the necessity to write complicated ArduinoJSon functions
  13. Permit to input special chars such as % and # into data fields.
  14. Default Credentials and dynamic parameters
  15. DoubleDetectDetector to force Config Portal when double reset is detected within predetermined time, default 10s.
  16. Configurable Config Portal Title
  17. Re-structure all examples to separate Credentials / Defines / Dynamic Params / Code so that you can change Credentials / Dynamic Params quickly for each device.
  18. Add support to Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)
  19. Add Table of Contents and Version String
  20. Use more efficient FlashStorage_STM32](https://github.com/khoih-prog/FlashStorage_STM32) and FlashStorage_SAMD library versions.
  21. Configurable Customs HTML Headers, including Customs Style, Customs Head Elements, CORS Header
  22. Add functions to control Config Portal from software or Virtual Switches.
  23. Permit optionally inputting one set of WiFi SSID/PWD by using REQUIRE_ONE_SET_SSID_PW == true
  24. Enforce WiFi Password minimum length of 8 chars
  25. Enable scan of WiFi networks for selection in Configuration Portal
  26. Add support to Arduino Nano RP2040 Connect using Arduino mbed OS for Nano boards.
  27. Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core.
  28. Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core
  29. Add LibraryPatches for Adafruit_MQTT_Library to fix compiler error for RP2040-based and many other boards.
  30. Add support to Arduino Nano RP2040 Connect using Earle Philhower's arduino-pico core.
  31. Fix the blocking issue in loop() with configurable WIFI_RECON_INTERVAL
  32. Update to be compatible with new FlashStorage_SAMD
  33. Use better FlashStorage_STM32 or FlashStorage_STM32F1 library for STM32
  34. Add support to generic SAMD21 boards : __SAMD21E1xA__, __SAMD21G1xA__ and __SAMD21J1xA__
  35. Optimize code by passing by reference instead of value
  36. Optional Board_Name in Config Portal
  37. Add optional CONFIG_MODE_LED to be ON when in Config Portal mode.
  38. Add function isConfigMode() to signal system is in Config Portal mode
  39. Use WiFiMulti_Generic library to connect to the best of multi-WiFi APs, with auto-checking / auto-reconnecting features when WiFi connection is lost.
  40. Add support to Realtek RTL8720DN, RTL8722DM and RTL8722CSM using AmebaD core and FlashStorage_RTL8720 library. RTL8720DN WiFi can use either 2.4GHz or 5GHz band.


Contributions and Thanks

Please help contribute to this project and add your name here.

  1. Thanks to Max Gerhardt in GitHub and in PIO for the useful fix attachInterrupt() on wifi101 unidentified to enable STM32F/L/H/G/WB/MP1 using ATWINC1500/WiFi101, leading to new v1.0.2
  2. Thanks to Michael H. "bizprof" to report bugs in
  1. Again thanks to Michael H. "bizprof" to be collaborator, co-author/maintainer of this library. With the impressive new feature :
  1. Thanks to tomtobback to report issue retries block the main loop #18 leading to version v1.5.0 to fix the blocking issue in loop() with WIFI_RECON_INTERVAL.
  2. Thanks to nicogou to post enhancement request Knowing when configuration mode is on or off #26 leading to version v1.6.0 to add optional CONFIG_MODE_LED and function isConfigMode()
maxgerhardt
Maximilian Gerhardt

bizprof
⭐️⭐️ Michael H. "bizprof"

tomtobback
tomtobback

nicogou
nicogou


Contributing

If you want to contribute to this project:

  • Report bugs and errors
  • Ask for enhancements
  • Create issues and pull requests
  • Tell other people about this library

License

  • The library is licensed under MIT

Copyright

Copyright 2021- Khoi Hoang - Michale H.

About

"Library to configure MultiWiFi/Credentials at runtime for Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52, RP2040-based (Nano RP2040 Connect, RASPBERRY_PI_PICO), AmebaD RTL8720DN, etc. boards, using Generic WiFi (WiFiNINA, WiFi101, ESP8266-AT, ESP32-AT, etc.) modules/shields. You can also specify DHCP HostName, static AP and STA IP.…

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published