Blynk & WiFiManager for Mega/nRF52/SAM DUE/SAMD21/SAMD51/STM32/RP2040 boards using ESP8266 AT shields

  • This is the new library, adding to the current Blynk_WiFiManager. It’s designed to help you eliminate hardcoding your Blynk credentials for Mega/Teensy boards running ESP8266 AT shields, and updating/reflashing every time when you need to change them.
  • You can update WiFi and Blynk Credentials any time you need to change via Configure Portal. Data are saved in configurable locations in EEPROM.

If it cannot connect to the Blynk server in 30 seconds, it will switch to Configuration Mode. You will see your built-in LED turned ON. In Configuration Mode, it starts a configurable access portal, default called Teensy4_XXXXXX or Mega_XXXXXX. Connect to it using password Teensy4_XXXXXX or MyMega_XXXXXX.

Selection_1

After you connected, please, go to http://192.168.4.1 or the AP IP you specified.

Config_Portal

Enter your credentials, then click Save. After you restarted, it’ll try to connect to your WiFi and Blynk server.

The following is the sample terminal output when running example Teensy40_ESP8266Shield

  1. No Config Data => Config Portal
Start Blynk WiFiManager using ESP8266_AT_Shield on TEENSY 4.0
Start Blynk_WM
[7866] AT version:0.40.0.0(Aug  8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04
OK
[8392] Init new EEPROM, size = 1080
[8393] bg: No configdat. Stay forever in config portal
[12836] startConfig: SSID = Teensy4_CCE61, PW = MyTeensy4_CCE61, IP = 192.168.100.1

  1. Config Data Ready => Run
Start Blynk WiFiManager using ESP8266_AT_Shield on TEENSY 4.0
Start Blynk_WM
[7866] AT version:0.40.0.0(Aug  8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04
OK
[8390] Header = SHD_ESP8266, SSID = ****, PW = ****
[8390] Server = ****.duckdns.org, Port = 8080, Token = ****
[8390] Board Name = Teensy4-WM
[8390] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Teensy 4.0

[8390] con2WF: start
[8390] connectToWifi: Try connectWiFi
[8390] Connecting to ****
[14956] AT version:0.40.0.0(Aug  8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04
OK
[15493] Get macAddress = 5c:cf:7f:66:05:d2
[22526] IP = 192.168.2.107

[22543] Connected to WiFi
[22543] con2WF: con OK
[22543] IP = 192.168.2.107

[22560] bg: WiFi connected. Try Blynk
[32717] Ready (ping: 18ms).
[32932] bg: WiFi+Blynk connected
BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB 
F[634808] run: Blynk lost. Connect Blynk
F[649868] run: Blynk lost. Connect Blynk
F[664928] run: Blynk lost. Connect Blynk
[675040] Ready (ping: 13ms).
[675265] run: Blynk reconnected
BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB 

This Blynk.begin() is not a blocking call, so you can use it for critical functions requiring in loop().
Anyway, this is better for projects using Blynk just for GUI (graphical user interface).

In operation, if WiFi or Blynk connection is lost, Blynk.run() will try reconnecting automatically. Therefore, Blynk.run() must be called in the loop() function. Don’t use:

void loop()
{
  if (Blynk.connected())
     Blynk.run();
     
  ...
}

just

void loop()
{
  Blynk.run();
  ...
}

Releases v1.0.0

Features

  1. This release of very-easy-to-use will help you to eliminate hardcoding your Wifi and Blynk credentials for Mega/Teensy boards running ESP8266 AT shields, and updating/reflashing every time when you need to change them.
  2. Configuration data are stored in configurable location in EEPROM.
  3. When WiFi and/or Blynk connection is lost, the WM will try auto-reconnect.
  4. Config Portal Static IP address, Name and Password.
  5. Static IP address, Gateway, Subnet Mask.

Update Feb 17th 2020

Blynk_Esp8266AT_WM libraries v1.0.0 just got included into Arduino Library Manager.
Now you can install this library directly from Arduino Library Manager.

Update Feb 17th 2020

Releases v1.0.1

  1. Add ESP8266_AT_WebServer dependency for autoinstall via Library Manager
  2. Add prerequisite to README.md
  3. Add config data checksum, fix bugs

Update Feb 22th 2020

New Version v1.0.2

  1. Add support to SAMD (DUE, ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit CIRCUITPLAYGROUND_EXPRESS, etc.) boards
3 Likes

@khoih great job!

How about adding a routine (Blynk.ResetSettings()) in case resetting is needed via programming or a push button.

1 Like

Hi @Emilio,
Thanks for using the lib. Your idea sounds very good, I’ll implement it in next version of all (Blynk)WiFiManagers.

  1. There will be a public function called clearConfigData() to reset the current settings then reset the board.
  2. You can call it whenever necessary (such as button pushed, flags detected from Blynk button, certain conditions, etc.)
  3. It’ll be very helpful if you can share your experience in using it: issues, problems, tricks, solution. etc.

Regards,

Update Mar 04th 2020

New Version v1.0.3

  1. Add support to STM32 (STM32F1, F2, F3, F4, F7, etc) boards
  2. Add clearConfigData() function.

Update Mar 13th 2020

New Version v1.0.4

  1. Add support to SAM DUE
  2. Reduce html and code size for faster Config Portal response.
  3. Enhance GUI.

So, how it works?

If it cannot connect to the Blynk server in 30 seconds, it will switch to Configuration Mode. You will see your built-in LED turned ON. In Configuration Mode, it starts a configurable access point, default called Teensy4_XXXXXX, SAMD_XXXXXX, DUE_XXXXXX,Mega_XXXXXX or STM32_XXXXXX. Connect to it using password MyTeensy4_XXXXXX, MySAMD_XXXXXX, MyDUE_XXXXXX, MyMega_XXXXXX or MySTM32_XXXXXX.

After you connected, please, go to http://192.168.4.1 or the AP IP you specified.

Enter your credentials : WiFi SSID/Password, Blynk Server, Port and Token, Board Name.

Then click Save. After you restarted, you will see your built-in LED turned OFF. That means, it connected to your Blynk server successfully.

1 Like

Update June 25th 2020

New recent features:

  • MultiWiFi feature for configuring/auto(re)connecting ESP8266-AT shields to the available MultiWiFi APs at runtime.
  • DoubleDetectDetector feature to force Config Portal when double reset is detected within predetermined time, default 10s.
  • Configurable Config Portal Title to be either BoardName or default undistinguishable names.
  • Examples are redesigned to separate Credentials / Defines / Dynamic Params / Code so that you can change Credentials / Dynamic Params quickly for each device

Major Releases v1.0.5

  1. Add support to nRF52 (AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, NINA_B112_ublox, etc.). Dynamic custom parameters to be saved automatically in LittleFS.
  2. Add support to Adafruit SAMD21/SAM51 (Itsy-Bitsy M0/M4, Metro M0/M4, Grand Central M4, Feather M0/M4 Express, etc.). Dynamic custom parameters to be saved automatically in FlashStorage.
  3. Add MultiWiFi features for WiFi
  4. Add DoubleResetDetector (DRD) feature.
  5. Increase WPA2 SSID and PW to 63 chars. Permit special chars such as !,@,#,$,%,^,&,* into data fields.
  6. Restructure examples separate Credentials / Defines / Dynamic Params / Code.
  7. Drop support to Teensy boards.

Update July 1st 2020

New Releases v1.0.6

  1. Add support to ESP32-AT shields
  2. Use new ESP_AT_Lib to support ESP8266/ESP32-AT
  3. Enhance MultiWiFi connection logic.
  4. New logic for USE_DEFAULT_CONFIG_DATA to autoload Config / Dynamic Data in developing stage. See Can’t load defaults for more information on how to use.

Now, the correct board type of many new boards can be displayed correctly along with Blynk logo as follows:

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on NRF52840_ITSYBITSY_EXPRESS

not just unknown Arduino board type:

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino

Update July 27th 2020

New Releases v1.0.7

  1. Add support to all STM32F/L/H/G/WB/MP1 (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.)
  2. 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.)
  3. Sync with latest ESP8266_AT_WebServer Library v1.0.12

The following is the sample terminal output when running example STM32_ESP8266Shield using STM32 Nucleo-144 NUCLEO_F767ZI with ESP8266-AT shield.

Start STM32_ESP8266Shield on NUCLEO_F767ZI
Start Blynk_ESP8266AT_WM
[6566] AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
OK

EEPROM size = 16384, start = 0
Flag read = 0xffffffff
No doubleResetDetected
SetFlag write = 0xd0d01234
[11998] ======= Start Default Config Data =======
[12000] Hdr=STM32_ESP_AT,SSID=HueNet1,PW=password
[12004] SSID1=HueNet,PW1=password
[12007] Svr=account.duckdns.org,Prt=8080,Tok=new_token
[12014] BName=STM32_ESP_AT
[12017] i=0,id=mqtt,data=default-mqtt-server
[12021] i=1,id=mqpt,data=1883
[12023] SaveEEPROM,Sz=16384,DataSz=0,WCSum=0x2360
[12028] ======= Start Loaded Config Data =======
[12032] Hdr=SHD_ESP8266,SSID=HueNet1,PW=password
[12037] SSID1=HueNet,PW1=password
[12040] Svr=account.duckdns.org,Prt=8080,Tok=new_token
[12047] BName=STM32_ESP_AT
[12049] i=0,id=mqtt,data=default-mqtt-server
[12053] i=1,id=mqpt,data=1883
[12056] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on STM32 NUCLEO_F767ZI

[12069] ConMultiWifi
[12071] con2WF:SSID=HueNet1,PW=password
[12075] Remaining retry_time=3
[12078] Con2:HueNet1
[18645] AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
OK
[19189] Mac=68:c6:3a:a4:6a:97
[24253] IP=192.168.2.85
[24270] WOK
[24270] WOK, lastConnectedIndex=0
[24270] con2WF:OK
[24272] IP=192.168.2.85
[24290] b:WOK.TryB
[34457] Ready (ping: 12ms).
[34633] b:WBOK
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
B
Your stored Credentials :
MQTT Server = default-mqtt-server
Port = 1883
BBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB

Updated May 20th 2021

Major Releases v1.3.0

  1. Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower’s arduino-pico core v1.4.0+ to use with or without Blynk/WiFiManager features.
  2. Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core to use without Blynk/WiFiManager features.
  3. Fix bug
  4. Optimize code
  5. Update examples with new features

Releases v1.2.0

  1. Use new and more efficient FlashStorage_STM32 and FlashStorage_SAMD library versions.
  2. Fix Config Portal bug

Releases v1.1.1

  1. Add support to Teensy 3.x boards, using only Teensy core v1.51 if Config Portal is needed.

Major Releases v1.1.0

  1. Restore support to Teensy 4.x boards, using only Teensy core v1.51 if Config Portal is needed.
  2. Add STM32 emulated-EEPROM feature so that saving to EEPROM is usable and much faster.
  3. Add functions to control Config Portal from software or Virtual Switches. Check How to trigger a Config Portal from code #25
  4. Renew all examples to demo the new Virtual ConfigPortal SW feature
  5. Optimize code and fix many bugs.

RP2040_ESP8266Shield using LittleFS on RASPBERRY_PI_PICO with ESP8266-AT shield

Start RP2040_ESP8266Shield on RASPBERRY_PI_PICO
Blynk_Esp8266AT_WM v1.3.0
ESP_AT_Lib v1.2.0
DoubleResetDetector_Generic v1.2.0
Start Blynk_ESP8266AT_WM
[120835] AT version:1.7.4.0(May 11 2020 19:13:04)
SDK version:3.0.4(9532ceb)
compile time:May 27 2020 10:12:17
Bin version(Wroom 02):1.7.4
OK
LittleFS Flag read = 0xd0d04321
Flag read = 0xd0d04321
No doubleResetDetected
Saving DOUBLERESETDETECTOR_FLAG to DRD file : 0xd0d01234
Saving DRD file OK
SetFlag write = 0xd0d01234
[121384] LoadCfgFile 
[121388] OK
[121389] CCSum=0x1fed,RCSum=0x1fed
[121392] LoadCredFile 
[121393] OK
[121393] ChkCrR: Buffer allocated, Sz=35
[121393] ChkCrR:pdata=mqtt_server,len=34
[121393] ChkCrR:pdata=1883,len=6
[121394] CrCCsum=0x590,CrRCsum=0x590
[121394] Buffer freed
[121398] LoadCredFile 
[121398] OK
[121398] CrR:pdata=mqtt_server,len=34
[121398] CrR:pdata=1883,len=6
[121398] CrCCsum=0x590,CrRCsum=0x590
[121399] Valid Stored Dynamic Data
[121399] ======= Start Stored Config Data =======
[121399] Hdr=SHD_ESP8266,SSID=HueNet1,PW=password
[121399] SSID1=HueNet2,PW1=password
[121399] Svr=account.duckdns.org,Prt=8080,Tok=token
[121400] i=0,id=mqtt,data=mqtt_server
[121400] i=1,id=mqpt,data=1883
[121400] Check if isForcedCP
[121404] LoadCPFile 
[121404] OK
[121404] bg: noConfigPortal = true
[121405] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on RASPBERRY_PI_PICO

[121405] ConMultiWifi
[121405] con2WF:SSID=HueNet1,PW=password
[121405] Remaining retry_time=3
[121405] Con2:HueNet1
[127972] AT version:1.7.4.0(May 11 2020 19:13:04)
SDK version:3.0.4(9532ceb)
compile time:May 27 2020 10:12:17
Bin version(Wroom 02):1.7.4
OK
[128510] Mac=68:c6:3a:a6:f0:f1
[135496] IP=192.168.2.76

[135513] WOK
[135513] WOK, lastConnectedIndex=0
[135513] con2WF:OK
[135514] IP=192.168.2.76

[135531] b:WOK.TryB
[145798] Ready (ping: 19ms).
[145983] b:WBOK
Stop doubleResetDetecting
Saving to DRD file : 0xd0d04321
Saving DRD file OK
LittleFS Flag read = 0xd0d04321
ClearFlag write = 0xd0d04321
B
Your stored Credentials :
MQTT Server = mqtt_server
Port = 1883
BBBB

RP2040_ESP8266Shield on MBED RASPBERRY_PI_PICO with ESP8266-AT shield

The following is the sample terminal output when running example RP2040_ESP8266Shield on MBED RASPBERRY_PI_PICO with ESP8266-AT shield, using Arduino-mbed RP2040 core without Blynk/WiFiManager features.

Start RP2040_ESP8266Shield on MBED RASPBERRY_PI_PICO
Blynk_Esp8266AT_WM v1.3.0
ESP_AT_Lib v1.2.0
Start Blynk no WM with BlynkServer = account.duckdns.org and Token = token
[1173] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on MBED RASPBERRY_PI_PICO

[1173] Con2:HueNet1
[7507] AT version:1.7.4.0(May 11 2020 19:13:04)
SDK version:3.0.4(9532ceb)
compile time:May 27 2020 10:12:17
Bin version(Wroom 02):1.7.4
OK
[14050] IP = +CIPSTA:ip:"192.168.2.76"
+CIPSTA:gateway:"192.168.2.1"
+CIPSTA:netmask:"255.255.255.0"
[14051] WOK
[24152] Ready (ping: 19ms).
BBBBB