WM Config Portal using BlynkSimpleEsp32/8266_WM.h

Thanks khoih-prog for Blynk_WM.
Questions and observations on your Blynk_WM.

I’m old at ESP8266, older on Arduino, still pretty much a newbie at Blynk. I am on Win 10 using Arduino IDE 1.8.12, Blynk Lib 0.6.1, and Blynk_WiFiManager 1.0.12. I compile to a generic NODE MCU ESP8266 and an Adafruit ESP32 HUZZAH.

I find the <BlynkSimpleEsp32/8266.h> non-_WM versions work wonderfully for me, both SSL and non-SSL, both on ESP32 and ESP8266. Love it. Thanks.

I’m struggling with <BlynkSimpleEsp32/8266_SSL_WM.h> and <BlynkSimpleEsp32/8266_SSL_WM.h> with ESP8266 and ESP32.
On the _WM versions, I can get the WM Config Portal to post and can enter values to get Blynk connected and running. Thanks. It works.

Questions and observations:

  • How can my sketch pre-program default values for the WM Config Portal? It would be nice to not start with blanks everywhere in the Portal.

  • When using correct SSID and WiFi Password entered into the WM Config Portal, once WiFi connects, the device AP Config Portal WiFi signal shuts down, even if the device cannot connect to the Blynk server. So if the WM connects to WiFi but not to Blynk, there is no WM Portal WiFi signal from the ESP32 or ESP8266 to allow the user to change or update the WM Config Portal info for Blynk servers. Is there a way to change this behavior, keep the WM Config Portal WiFi running, or turn it on for a few minutes after reboot for changes to parameters?

  • I have been unable to get the WM Config Portal AP SSID and Password to set, keep getting the default WiFi name and password. (The Config Portal IP Address worked for me, thanks!) Any ideas?

My overly switched code is attached. It’s a simple demo program that pulses a heartbeat LED. It works for SSL, non-SSL, ESP32 and 8266.
If someone has time to look through this, I’d love to be able to use the WM Config Portal on my devices.

Thanks again and in advance.

#define SERIAL_SPEED 230400
#define PROGRAM_NAME "AAA-Blynk WiFiMgr Demo_ESP32_ESP8266"
// Uses ESP32 and ESP8266 to select compile choices


//BLYNK Stuff here
#define BLYNK_PRINT Serial

#define USE_SSL true // to easily select SSL or not
#define USE_WM true   // to easily select WiFi Manager or not
// REMEMBER: not using _WM means we manage our own initial WiFi connection


#if USE_WM
  #define USE_SPIFFS false  // Choosing EEPROM over SPIFFS here

  #if (!USE_SPIFFS)
    // EEPROM_SIZE must be <= 2048 and >= CONFIG_DATA_SIZE (currently 172 bytes)
    #define EEPROM_SIZE    (2 * 1024)
    // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE
    #define EEPROM_START   512
  #endif

  #define USE_DYNAMIC_PARAMETERS false  // see Github doc
  
  // Force some params in Blynk, only valid for library version 1.0.1 and later
  // (from the Github doc)
  #define TIMEOUT_RECONNECT_WIFI                    10000L
  #define RESET_IF_CONFIG_TIMEOUT                   true
  #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET    5
#endif


#if USE_SSL
  #ifdef ESP8266
    #if USE_WM
      #include <BlynkSimpleEsp8266_SSL_WM.h>
    #else
      #include <BlynkSimpleEsp8266_SSL.h>
    #endif
  #endif
  #ifdef ESP32
    #if USE_WM
      #include <BlynkSimpleEsp32_SSL_WM.h> 
    #else
      #include <BlynkSimpleEsp32_SSL.h>
    #endif
  #endif
  
#else // NOT using SSL
  #ifdef ESP8266
    #if USE_WM
      #include <BlynkSimpleEsp8266_WM.h>
    #else
      #include <BlynkSimpleEsp8266.h>
    #endif
  #endif
  #ifdef ESP32
    #if USE_WM
      #include <BlynkSimpleEsp32_WM.h>
    #else
      #include <BlynkSimpleEsp32.h>
    #endif
  #endif
#endif


#if USE_WM
  #define USE_DYNAMIC_PARAMETERS false

  MenuItem myMenuItems [] = {};

  uint16_t NUM_MENU_ITEMS = 0;
#endif // USE_WM



char blynkAuth[] = "<my auth>"; // BLYNK Auth 

char WiFiSSID[] = "<my ssid";  // network SSID (name)
char WiFiPass[] = "<my passcode>";  // network password



BlynkTimer myTimer;
// Blynk timers to blink a heartbeat LED on and off
int heartbeatLEDinterval = 3000; // interval between heartbeats for onboard and Blynk Virtual LED in millisec 
int heartbeatLEDtimerID; 

int heartbeatLEDduration = 750; // duraction of each blink in millisec (set as an interval timer)
int heartbeatLEDdurationTimerID;
bool heartbeatLEDon = false; // this lets me use the same routine for the turn-on timer and the turn-off interval

#define BLYNK_HEARTBEAT_LED V2
WidgetLED heartbeatLED( BLYNK_HEARTBEAT_LED );  // want a blinking LED on the display to show we're live



/* setup
 *  Set up WiFi, Blynk & Blynk timers 
 *  Set up Blue LED on board
 */
void setup() 
{
  Serial.begin ( SERIAL_SPEED );
  delay ( 500 );  
  Serial.println ( "\n\n=======================================" );
  Serial.print ( PROGRAM_NAME ); 
  #if USE_SSL
    Serial.println ( " ** Using SSL ** \n" );  
  #endif
  Serial.println();
  
  connectToLANandBlynk();  

  // Initialize Onboard LED 
  pinMode ( LED_BUILTIN, OUTPUT );  
  digitalWrite ( LED_BUILTIN, LOW ); 
    
  // Set Blynk Virtual LED OFF
  heartbeatLED.off(); // Blynk Virtual LED
  heartbeatLEDblink(); // first heartbeat 
  
  Serial.println ( "\nSetup complete \n" );    
  
} //end setup




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




void connectToLANandBlynk()
{
  // Setup WLAN and Blynk
  Serial.print ( "\nSetting up WLAN and Blynk " );  
  #if USE_WM
    Serial.println ( "WITH WiFiManager" ); 
  #else
    Serial.println ( "WITHOUT WiFiManager" );  
  #endif
  
  #if USE_WM
    Serial.println ( "Starting Blynk.begin (with WM)" );  

    Blynk.setConfigPortal ( "TestPortal", "123" );
    Serial.println ( "Blynk.setConfigPortal(TestPortal, 123);" );  

    Blynk.setConfigPortalIP ( IPAddress ( 192, 168, 220, 1 ) );  
    Blynk.config ( blynkAuth );
    Blynk.begin ( "Blynk-Configurator" ); 
    
  #else//NOT using WM
    Serial.println ( "Starting WiFi.begin (no WM)" );  
    WiFi.begin ( WiFiSSID, WiFiPass );
    Serial.println ( "... waiting a few seconds for WiFi ..." );    
    delay ( 7000 );  // For esp8266, it needs a delay to realize it has connected
    
    // REBOOT if we do not have a good WiFi connection
    if ( WiFi.status() != WL_CONNECTED )
    {
      Serial.println ( "Resetting in a few seconds..." );
      delay ( 3000 );  
      ESP.restart();
    } 
    
    // Configure and launch Blynk
    Blynk.config ( blynkAuth );
    Blynk.connect ( 2500 ); // Don't get stuck hanging for more than 2500 millis.
  #endif // using WM
  
  if ( Blynk.connected() ) Serial.println ( "Blynk connected just fine\n" ); 
  else Serial.println ( "Blynk NOT CONNECTED \n\n" );  

  #if USE_WM
    #if USE_SPIFFS
      Serial.println("\nBlynk using SPIFFS connected. Board Name : " + Blynk.getBoardName());
    #else
      Serial.println("\nBlynk using EEPROM connected. Board Name : " + Blynk.getBoardName());
      Serial.printf("EEPROM size = %d bytes, EEPROM start address = %d / 0x%X\n", EEPROM_SIZE, EEPROM_START, EEPROM_START);
    #endif
  #endif


  Serial.println ( "Setting up Blynk timer" );  
  // Interval timer for heartbeatLED (Blynk LED and onboard LED
  heartbeatLEDtimerID = myTimer.setInterval ( heartbeatLEDinterval, heartbeatLEDblink );  

  Serial.println ( "..Blynk config and timers setup complete\n" );  
} //end connectToBlynk




void heartbeatLEDblink()
/* Blink the on-board LED AND the Virtual Blynk LED
 * First time called, it turne the LEDs on, then sets a timer to turn LED off
 * When the timer triggers, same routine turns the LEDs off
 */
{
  if ( heartbeatLEDon ) // if LED is on, turn it off and vice cersa
  {
    heartbeatLED.off(); // Blynk Virtual LED
    
    digitalWrite ( LED_BUILTIN, LOW ); // On-board LED
    
    Serial.println ( " ..." );
  } else
  {
    heartbeatLED.on();      // Blynk Virtual LED
    
    digitalWrite ( LED_BUILTIN, HIGH );  // On-board LED
    
    // Set the timer to turn off the LEDs in a bit  
    heartbeatLEDdurationTimerID = myTimer.setTimeout ( heartbeatLEDduration, heartbeatLEDblink ); 
    
    Serial.print ( "... heartbeat of " ); Serial.print ( PROGRAM_NAME ); 
    Serial.print ( " WiFi.status() = " ); Serial.print ( WiFi.status() );  
  }
  
  heartbeatLEDon = ! heartbeatLEDon; // flip status
} //end heartbeatLEDblink




// CALLED WHEN CONNECTING TO BLYNK SERVERS
// GETS CALLED IMMEDIATELY ON FIRST CONNECT
// THIS SYNCS UP SLIDER AND PUSHBUTTON WHEN BLYNK CONNECTS - EVEN FOR THE FIRST TIME
BLYNK_CONNECTED()
{
  Serial.println ( "\nBLYNK_CONNECTED..." );  
}
1 Like

@khoih you aren’t tagged in the above post, so I’ve tagged you here in order to alert you to it.

Pete.

2 Likes

Thank @PeteKnight for the tag.

Hi @thorathome,

Thanks for using the library and encouraging words.

Your code is beautiful and proves you’re so good in coding.

Hereafter are the answers to your questions:

1Q. How can my sketch pre-program default values for the WM Config Portal? It would be nice to not start with blanks everywhere in the Portal.

1A. That’s a good idea for future version. Currently, at the first time without any valid data, the values are cleared to blank so that essential values must be input to be different from blank or ConfigPortal will stay.

2Q. When using correct SSID and WiFi Password entered into the WM Config Portal, once WiFi connects, the device AP Config Portal WiFi signal shuts down, even if the device cannot connect to the Blynk server. So if the WM connects to WiFi but not to Blynk, there is no WM Portal WiFi signal from the ESP32 or ESP8266 to allow the user to change or update the WM Config Portal info for Blynk servers. Is there a way to change this behavior, keep the WM Config Portal WiFi running, or turn it on for a few minutes after reboot for changes to parameters?

2A. After starting and trying to connect to Blynk Servers 10 times without success, the Config Portal will start automatically even if you have the valid Credentials. You have 60s ( or configurable by changing CONFIG_TIMEOUT ) to go to Config Portal.

You can also use the following way for this purpose

then to clear config Data, call

Blynk.clearConfigData();

See ConfigOnDoubleReset example

This is multi-purpose library and it’s not good to keep the ConfigPortal AP running or longer than necessary to avoid channel conflict. For example AP stays open issue

With full source code, you certainly can change to fit your special purpose.

3Q. I have been unable to get the WM Config Portal AP SSID and Password to set, keep getting the default WiFi name and password. (The Config Portal IP Address worked for me, thanks!) Any ideas?

3A. You have to change the code in void connectToLANandBlynk() to

#if USE_WM
    Serial.println ( "Starting Blynk.begin (with WM)" );  

    Blynk.setConfigPortal ( "TestPortal", "12345678" );   // WPA2 PW length must be 8+ to be valid
    Serial.println ( "Blynk.setConfigPortal(TestPortal, 12345678);" );  

    Blynk.setConfigPortalIP ( IPAddress ( 192, 168, 220, 1 ) );  
    //Blynk.config ( blynkAuth );                        // Don't use this with WM
    Blynk.begin ( "Blynk-Configurator" ); 
    
  #else//NOT using WM

This is the terminal output when running your nice code

=======================================
AAA-Blynk WiFiMgr Demo_ESP32_ESP8266 ** Using SSL ** 

Setting up WLAN and Blynk WITH WiFiManager
Starting Blynk.begin (with WM)
Blynk.setConfigPortal(TestPortal, 12345678);
[638] Hostname=Blynk-Configurator
[644] CCSum=0x3387,RCSum=0x3387
[644] CrCCsum=0,CrRCsum=0
[644] Hdr=SSL_ESP32,BrdName=ESP32-WM-SSL
[644] SSID=HueNet1,PW=***
[644] SSID1=HueNet,PW1=***
[646] Server=account.duckdns.org,Token=***
[649] Server1=account.ddns.net,Token1=***
[652] Port=9443
[653] Connecting MultiWifi...
[5536] WiFi connected after time: 1
[5536] SSID: HueNet, RSSI = -34
[5536] Channel: 10, IP address: 192.168.2.69
[5536] bg: WiFi OK. Try Blynk
[5537] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

[5543] BlynkArduinoClient.connect: Connecting to account.duckdns.org:9443
[7537] Certificate OK
[7553] Ready (ping: 8ms).

BLYNK_CONNECTED...
[7622] Connected to Blynk Server = account.duckdns.org, Token = ****
[7622] bg: WiFi+Blynk OK
Blynk connected just fine


Blynk using EEPROM connected. Board Name : ESP32-WM-SSL
EEPROM size = 2048 bytes, EEPROM start address = 512 / 0x200
Setting up Blynk timer
..Blynk config and timers setup complete

... heartbeat of AAA-Blynk WiFiMgr Demo_ESP32_ESP8266 WiFi.status() = 3
Setup complete 

 ...
... heartbeat of AAA-Blynk WiFiMgr Demo_ESP32_ESP8266 WiFi.status() = 3 ...
... heartbeat of AAA-Blynk WiFiMgr Demo_ESP32_ESP8266 WiFi.status() = 3 ...

Regards,

Thanks @khoih for the instantaneous response.

I changed the WiFi password to 8 characters and all is right with the world! I also killed the Blynk.config line when using _WM. I missed that.

Blynk.clearConfigData() works as advertised. Nice to know. I’ll intend to look into the ESP_DoubleReset Detector lib, thanks.

I will also look into CONFIG_TIMEOUT to see how that works.
I’m testing the 10 times server connection / reconnection now. It may be that if WM connects to the Blynk server, but with a bad authcode, it keeps retrying beyond the 10 times. It looks like 20 is the magic number !
But now that I know about .clearConfigData, I have the Power of Khoih in my hands.

Glad you like my code. In Coding, as in plumbing and with COVID-19, cleanliness is next to godliness.

Will keep you posted. Thanks again for the very quick and helpful reply. Be well.

1 Like

Good news it’s working as you expected.

it keeps retrying beyond the 10 times.

Because it’ll try10 times x 2 BlynkServers => total 20 times before it resets itself to begin a new cycle.

I intend to include the ESP_DoubleReset Detector function into next version of Blynk_WM libs as more and more applications requires that feature.

1 Like

You are awesome. Thanks again for being on top of this. You make it easy to continue working with your BlynkSimpleEsp library and with Blynk. Onward.

1 Like

Hi @Khoih
Having fun (in isolation) with BlynkSimpleESP32/8266 libraries on both ESP32 and ESP8266 platforms. Thanks again.

Kudos to you for the Controllable Config Portal. It works. I’m using it to configure Blynk Virtual Pins and Widget Labels.

Questions and suggestions based on a week working with these libraries.
Questions

  • On the DYNAMIC_PARAMETERS menu array, what is the first field in each row of the Menu table? (You have 4-character names in each row of your example: “mqtt”, “mqpt”, etc.)
    What do these names do?

  • Using your libraries, but NOT using _WM, can we set the device DHCP Hostname as we do using _WM in Blynk.begin ( “Hostname” )? Can we set Hostname when NOT using _WM?
    Now, I believe Blynk.begin, when not using _WM, takes a timeout integer. When using _WM, Blynk.begin takes the “Hostname” label. True?

A few “Nice to Haves”

  • Easily change the number of connection retries when WM cannot reach the Blynk server. 10 is ok, but not for debugging. Can this be changed by the sketchwriter without editing the library?

  • When using DYNAMIC_PARAMETERS, easily modify MAX_ID_LEN (do we need this?) and MAX_DISPLAY_NAME_LEN in the menu items for longer labels. Setting is 5 and 16 characters. Longer labels could be clearer.

  • Create a Simple title for the Config Portal at compile time would be nice.

  • It would be great in the Config Portal to recognize input character strings with blanks in them as data entries. My use case is to input the name of a Blynk Widget Label, which may want to have blanks in it.

  • Repeating our conversation yesterday: it would be useful to be able to pre-populate the Config Portal fields so we do not start with blanks each time.

Thanks again. Nothing urgent here. Everything is working: SSL, no SSL, _WM, no_WM, ESP32 and ESP8266. Nice work.

It’s good to see you’re having some fun / distraction to survive through this historic isolation period.

To answer those questions:

1Q. On the DYNAMIC_PARAMETERS menu array, what is the first field in each row of the Menu table? (You have 4-character names in each row of your example: “mqtt”, “mqpt”, etc.)
What do these names do?

1A. These names must be unique ( please also check the reserved names already used in library, such as

  • id for WiFi SSID
  • pw for WiFi PW
  • id1 for WiFi1 SSID
  • pw1 for WiFi1 PW
  • sv for Blynk Server
  • tk for Blynk Token
  • sv1 for Blynk Server1
  • tk1 for Blynk Token1
  • pt for Blynk Port
  • nm for Board Name
    I know these info must be in the README instructions, but I can only promise to do soon.
    These unique names / identifiers are used to replace the default / stored / input values to/from the corresponding fields in the HTML page.

2Q. Using your libraries, but NOT using _WM, can we set the device DHCP Hostname as we do using _WM in Blynk.begin ( “Hostname” )? Can we set Hostname when NOT using _WM?
Now, I believe Blynk.begin, when not using _WM, takes a timeout integer. When using _WM, Blynk.begin takes the “Hostname” label. True?

You can only set DHCP Hostname if you’re using _WM, where you can set Hostname by calling Blynk.begin(“HostName”);
Without using _WM, Blynk.begin(); has to be called with many other parameters such as this function prototype where you have to input hardcoded Blynk Credentials

void begin(const char* auth,
               const char* ssid,
               const char* pass,
               const char* domain = BLYNK_DEFAULT_DOMAIN,
               uint16_t    port   = BLYNK_DEFAULT_PORT)

A few “Nice to Haves”

3Q. Easily change the number of connection retries when WM cannot reach the Blynk server. 10 is ok, but not for debugging. Can this be changed by the sketchwriter without editing the library?

3A. Currently it’s can be configured in your sketch as follows:

// Default 10 if not defined, from 2-100 is permissible
#define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET          10

4Q. When using DYNAMIC_PARAMETERS, easily modify MAX_ID_LEN (do we need this?) and MAX_DISPLAY_NAME_LEN in the menu items for longer labels. Setting is 5 and 16 characters. Longer labels could be clearer.

4A. All is configurable and necessary for char array to avoid being dangerously overflowed.
MAX_ID_LEN too short will create duplication risk. See 1A.
MAX_DISPLAY_NAME_LEN is 16 now but you can increase with the memory usage trade-off.

5Q. Create a Simple title for the Config Portal at compile time would be nice.

5A. I still don’t know what you mean here. Can you clarify?

Do you mean the Title the WebBrowser displays when you enter the Config Portal? If so, certainly everything can be done if trade-off and justification are all carefully considered. I still don’t find it’s important enough to do.

6Q. It would be great in the Config Portal to recognize input character strings with blanks in them as data entries. My use case is to input the name of a Blynk Widget Label, which may want to have blanks in it.

6A. I believe the special chars can be input (but forget to check blank). Did you try? How did it behave?

Just testing and confirming that you can input and receive blank characters.

See the following terminal output


Starting ...
[131] Hostname=ESP32-WM-Config
[137] CCSum=0x3100,RCSum=0x3100
[137] CrCCsum=6470,CrRCsum=6470
[137] Hdr=ESP32,BrdName=12345 67890
[137] SSID=HueNet1,PW=****
[138] SSID1=HueNet2,PW1=****
[140] Server=account.ddns.net,Token=****
[146] Server1=account.duckdns.org,Token1=****
[153] Port=8080
[154] Connecting MultiWifi...
[6071] WiFi connected after time: 1
[6071] SSID:HueNet1,RSSI=-40
[6071] Channel:2,IP address:192.168.2.69
[6071] bg: WiFi OK. Try Blynk
[6072] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

[6085] BlynkArduinoClient.connect: Connecting to account.ddns.net:8080
[6205] Ready (ping: 9ms).
[6274] Connected to Blynk Server = account.ddns.net, Token = ****
[6274] bg: WiFi+Blynk OK

Blynk ESP32 using EEPROM connected. Board Name : 12345 67890 <==== space is OK
EEPROM size = 2048 bytes, EEPROM start address = 128 / 0x80
B
Your stored Credentials :
MQTT Server = mqtt-server
Port = 1883
MQTT UserName = mqtt user name          <==== space is OK
MQTT PWD = mqtt password                <==== space is OK
Subs Topics = SubTopic ESP32            <==== space is OK
Pubs Topics = PubTopic ESP32            <==== space is OK

7Q. Repeating our conversation yesterday: it would be useful to be able to pre-populate the Config Portal fields so we do not start with blanks each time.

The fields are cleared only when we don’t have any valid Credentials to use (the first time, clearConfigData() called, etc.). If you enter the Config Porta with valid stored Credentials, they will be displayed and you can change.

You can try by :

  • disconnect the WiFi Router(s) to simulate WiFi lost

If you’d like to pre-populate the fields with hardcoded data, it’s against the main purpose of this library is to avoid hardcoded Credentials in your sketch.

Next release, I’ll add feature to let you run Config Portal (with stored Credentials intact so that you can modify) by using ESP_DoubleResetDetector or by pressing a SW while reset. Hopefully not forget.

As you can see, no program can be perfect without bug or completely done. Thanks to people like you testing, finding bugs, requesting enhancements, collaborating, I can avoid my tunnel vision :wink:, and improve a lot of things.

Regards,

1 Like

Thanks, @Khoih. You are astonishing. I very much appreciate your quick replies and helpful answers to my many questions on your powerful BlynkSimpleESP32/8266 libraries. I continue to enjoy using these libraries. They work.

To your questions

  • Config Portal title. Your Config Portal is clean and usable today, thanks. I anticipate having a bunch of ESPx devices in my home and office as my Arduino inventory grows again. You’ve given the library (and me) the power to name the WiFi signals to be unique for each device. It would be helpful to avoid confusion to ALSO show a title at the top of the Config Portal page, above the data entry table, to remind me which device or application I am modifying. This is clearly a “nice to have,” absolutely not a necessity.

  • My request for pre-loaded Config Portal values is primarily for convenience in development and debugging.

  • Blanks in Config Portal data entry. My error. Your software appears to function perfectly here. Thanks.

  • Note. To test the connectivity with Blynk devices, I often use my phone’s WiFi hotspot. I find it’s far easier to turn it on and off than my router. Plus, it doesn’t disrupt everyone else in the house and the myriad little devices that depend on WiFi.

Again, I am impressed with your software libraries and more impressed with your helpfulness and responsiveness to my (many) questions. I hope to return the favor to others in the community.

Thank you. Stay healthy.

1 Like

Thanks so much and glad to see you enjoy and explore every corners of the library.

RE your point:

  1. Config Portal title.

I see your valid point now. I plan to include the feature into future release as follows:

  • ConfigPortal title will be either a valid “HostName” or “BoardName”, in that priority.
  • If there is nothing valid yet, use the current default generic string
  1. pre-loaded Config Portal values

I’ll explore and possibly let it be configurable (not mandatory, just optional )

  1. Blanks in Config Portal data entry. My error.

Good thing is I’m sure it’s working that way now. One guy can do so much test.

  1. To test the connectivity with Blynk devices, I often use my phone’s WiFi hotspot.

Good way. I here have to use an old and secret router to do it.

Be safe and enjoy exploring.

Happy to test and suggest. Thanks so much.

1 Like

Dear @thorathome

Just to warn :wink: you to spare some time to test new release soon :wink:

These features are done and tested OK

  1. Config Portal title, either
  • Hostname defined in defines.h and configurable such as Master-Controller, or
  • BoardName got via ConfigPortal, or
  • default undistinguishable names.
  1. Configurable pre-loaded default Config Portal values, including dynamic parameters. You can select either to load default pre-defined Credentials or “blank”
  2. Examples are redesigned to separate Credentials / Defines / Code so that you can change Credentials quickly for each device.

A real test screen to show Title and all the default Credentials are loaded onto Config Portal

Will add

  1. DoubleResetDetector to force starting ConfigPortal. DONE.
  2. Update README. Can you help write and update this?
  3. What else do you think?
  4. Your contribution will be noted in v1.0.13 (lucky number for me)

Will post v1.0.13 within today.

With all the work you are doing @khoih, I would be happy to write a Readme for/with you.

Give me the week to draft something. I’ll post it here along with my demo code which I now use as a starting template for new Blynk ESP32/8266 projects. If you think it’s helpful, you can use it.

Again, I find your software very helpful and quite usable. Thank you for your time and dedication. It made it easier for me to get started with Blynk.

2 Likes

Dear @thorathome

Just update and post v1,0,13 on GitHub, thanks to your enhancement requests.

I’ve also updated the README, but a hasty job with certainly many problems. Please fix and enhance it.

Your contribution is also noted in that README. Don’t delete it, please.

Have something for you to kill time now. I appreciate it and also would like bugs found and killed :slight_smile:

More enhancement requests always needed.

On it. Will have to learn how to contribute to Github! Still a newbie there. If I create a fork, are you able to evaluate and bring it into the master?

Yes, you can fork, then make pull request (PR) or just show me the link I’ll go there and get it.

But IMHO, testing, enhancement suggesting and bug finding / killing are more important and have higher priority.

I also updated the relating topic on this forum

Blynk WiFiManager for ESP8266/ESP32 with Multi-WiFi and Multi-Blynk

Hi @khoih
I have added
bool LOAD_DEFAULT_CONFIG_DATA = false;
early in my sketch, before any of the #includes, am getting error msg:
…\Arduino\My New Sketchbook\libraries\Blynk_Main\src/BlynkSimpleEsp8266_SSL_WM.h:808: undefined reference to `defaultConfig’

I get the same error msg if LOAD_DEFAULT_CONFIG_DATA = true
Your thoughts? Thanks.

Hi @thorathome

There are many changes in the library in v1.0.13, so your code must be changed to follow.

Could you pls have a look at the new examples to see how to restructure the code.

But from the error, I believe that you need to add this code snippet to your sketch (or copy to code directory and add #include “Credentials.h”), even you don’t use LOAD_DEFAULT_CONFIG_DATA

bool LOAD_DEFAULT_CONFIG_DATA = true;
//bool LOAD_DEFAULT_CONFIG_DATA = false;

Blynk_WM_Configuration defaultConfig =
{
  //char header[16], dummy, not used
#if USE_SSL  
  "SSL",
#else
  "NonSSL",
#endif
  //WiFi_Credentials  WiFi_Creds  [NUM_WIFI_CREDENTIALS]
  //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw
  "SSID1", "password1",
  "SSID2", "password2",
  // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS];
  // Blynk_Creds.blynk_server and Blynk_Creds.blynk_token
  "account.ddns.net",     "token",
  "account.duckdns.org",  "token1", 
  //int  blynk_port;
#if USE_SSL
  9443,
#else
  8080,
#endif
  //char board_name     [24];
  "Air-Control",
  //int  checkSum, dummy, not used
  0
};

This is your code modified to eliminate that error

#define SERIAL_SPEED 230400
#define PROGRAM_NAME "AAA-Blynk WiFiMgr Demo_ESP32_ESP8266"
// Uses ESP32 and ESP8266 to select compile choices


//BLYNK Stuff here
#define BLYNK_PRINT Serial

#define USE_SSL true // to easily select SSL or not
//#define USE_SSL false // to easily select SSL or not

#define USE_WM true   // to easily select WiFi Manager or not
//#define USE_WM false   // to easily select WiFi Manager or not

// REMEMBER: not using _WM means we manage our own initial WiFi connection


#if USE_WM
  #define USE_SPIFFS false  // Choosing EEPROM over SPIFFS here

  #if (!USE_SPIFFS)
    // EEPROM_SIZE must be <= 2048 and >= CONFIG_DATA_SIZE (currently 172 bytes)
    #define EEPROM_SIZE    (2 * 1024)
    // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE
    #define EEPROM_START   512
  #endif

  #define USE_DYNAMIC_PARAMETERS false  // see Github doc
  
  // Force some params in Blynk, only valid for library version 1.0.1 and later
  // (from the Github doc)
  #define TIMEOUT_RECONNECT_WIFI                    10000L
  #define RESET_IF_CONFIG_TIMEOUT                   true
  #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET    5
#endif


#if USE_SSL
  #ifdef ESP8266
    #if USE_WM
      #include <BlynkSimpleEsp8266_SSL_WM.h>
    #else
      #include <BlynkSimpleEsp8266_SSL.h>
    #endif
  #endif
  #ifdef ESP32
    #if USE_WM
      #include <BlynkSimpleEsp32_SSL_WM.h> 
    #else
      #include <BlynkSimpleEsp32_SSL.h>
    #endif
  #endif
  
#else // NOT using SSL
  #ifdef ESP8266
    #if USE_WM
      #include <BlynkSimpleEsp8266_WM.h>
    #else
      #include <BlynkSimpleEsp8266.h>
    #endif
  #endif
  #ifdef ESP32
    #if USE_WM
      #include <BlynkSimpleEsp32_WM.h>
    #else
      #include <BlynkSimpleEsp32.h>
    #endif
  #endif
#endif


#if USE_WM
  #define USE_DYNAMIC_PARAMETERS false

  MenuItem myMenuItems [] = {};

  uint16_t NUM_MENU_ITEMS = 0;

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

bool LOAD_DEFAULT_CONFIG_DATA = true;
//bool LOAD_DEFAULT_CONFIG_DATA = false;

Blynk_WM_Configuration defaultConfig =
{
  //char header[16], dummy, not used
#if USE_SSL  
  "SSL",
#else
  "NonSSL",
#endif
  //WiFi_Credentials  WiFi_Creds  [NUM_WIFI_CREDENTIALS]
  //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw
  "SSID1", "password1",
  "SSID2", "password2",
  // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS];
  // Blynk_Creds.blynk_server and Blynk_Creds.blynk_token
  "account.ddns.net",     "token",
  "account.duckdns.org",  "token1", 
  //int  blynk_port;
#if USE_SSL
  9443,
#else
  8080,
#endif
  //char board_name     [24];
  "Air-Control",
  //int  checkSum, dummy, not used
  0
};

/////////// End Default Config Data /////////////
  
#endif // USE_WM



char blynkAuth[] = "<my auth>"; // BLYNK Auth 

char WiFiSSID[] = "<my ssid";  // network SSID (name)
char WiFiPass[] = "<my passcode>";  // network password



BlynkTimer myTimer;
// Blynk timers to blink a heartbeat LED on and off
int heartbeatLEDinterval = 3000; // interval between heartbeats for onboard and Blynk Virtual LED in millisec 
int heartbeatLEDtimerID; 

int heartbeatLEDduration = 750; // duraction of each blink in millisec (set as an interval timer)
int heartbeatLEDdurationTimerID;
bool heartbeatLEDon = false; // this lets me use the same routine for the turn-on timer and the turn-off interval

#define BLYNK_HEARTBEAT_LED V2
WidgetLED heartbeatLED( BLYNK_HEARTBEAT_LED );  // want a blinking LED on the display to show we're live



/* setup
 *  Set up WiFi, Blynk & Blynk timers 
 *  Set up Blue LED on board
 */
void setup() 
{
  Serial.begin ( SERIAL_SPEED );
  delay ( 500 );  
  Serial.println ( "\n\n=======================================" );
  Serial.print ( PROGRAM_NAME ); 
  #if USE_SSL
    Serial.println ( " ** Using SSL ** \n" );  
  #endif
  Serial.println();
  
  connectToLANandBlynk();  

  // Initialize Onboard LED 
  pinMode ( LED_BUILTIN, OUTPUT );  
  digitalWrite ( LED_BUILTIN, LOW ); 
    
  // Set Blynk Virtual LED OFF
  heartbeatLED.off(); // Blynk Virtual LED
  heartbeatLEDblink(); // first heartbeat 
  
  Serial.println ( "\nSetup complete \n" );    
  
} //end setup




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




void connectToLANandBlynk()
{
  // Setup WLAN and Blynk
  Serial.print ( "\nSetting up WLAN and Blynk " );  
  #if USE_WM
    Serial.println ( "WITH WiFiManager" ); 
  #else
    Serial.println ( "WITHOUT WiFiManager" );  
  #endif
  
  #if USE_WM
    Serial.println ( "Starting Blynk.begin (with WM)" );  

    Blynk.setConfigPortal ( "TestPortal", "123" );
    Serial.println ( "Blynk.setConfigPortal(TestPortal, 123);" );  

    Blynk.setConfigPortalIP ( IPAddress ( 192, 168, 220, 1 ) );  
    Blynk.config ( blynkAuth );
    Blynk.begin ( "Blynk-Configurator" ); 
    
  #else//NOT using WM
    Serial.println ( "Starting WiFi.begin (no WM)" );  
    WiFi.begin ( WiFiSSID, WiFiPass );
    Serial.println ( "... waiting a few seconds for WiFi ..." );    
    delay ( 7000 );  // For esp8266, it needs a delay to realize it has connected
    
    // REBOOT if we do not have a good WiFi connection
    if ( WiFi.status() != WL_CONNECTED )
    {
      Serial.println ( "Resetting in a few seconds..." );
      delay ( 3000 );  
      ESP.restart();
    } 
    
    // Configure and launch Blynk
    Blynk.config ( blynkAuth );
    Blynk.connect ( 2500 ); // Don't get stuck hanging for more than 2500 millis.
  #endif // using WM
  
  if ( Blynk.connected() ) Serial.println ( "Blynk connected just fine\n" ); 
  else Serial.println ( "Blynk NOT CONNECTED \n\n" );  

  #if USE_WM
    #if USE_SPIFFS
      Serial.println("\nBlynk using SPIFFS connected. Board Name : " + Blynk.getBoardName());
    #else
      Serial.println("\nBlynk using EEPROM connected. Board Name : " + Blynk.getBoardName());
      Serial.printf("EEPROM size = %d bytes, EEPROM start address = %d / 0x%X\n", EEPROM_SIZE, EEPROM_START, EEPROM_START);
    #endif
  #endif


  Serial.println ( "Setting up Blynk timer" );  
  // Interval timer for heartbeatLED (Blynk LED and onboard LED
  heartbeatLEDtimerID = myTimer.setInterval ( heartbeatLEDinterval, heartbeatLEDblink );  

  Serial.println ( "..Blynk config and timers setup complete\n" );  
} //end connectToBlynk




void heartbeatLEDblink()
/* Blink the on-board LED AND the Virtual Blynk LED
 * First time called, it turne the LEDs on, then sets a timer to turn LED off
 * When the timer triggers, same routine turns the LEDs off
 */
{
  if ( heartbeatLEDon ) // if LED is on, turn it off and vice cersa
  {
    heartbeatLED.off(); // Blynk Virtual LED
    
    digitalWrite ( LED_BUILTIN, LOW ); // On-board LED
    
    Serial.println ( " ..." );
  } else
  {
    heartbeatLED.on();      // Blynk Virtual LED
    
    digitalWrite ( LED_BUILTIN, HIGH );  // On-board LED
    
    // Set the timer to turn off the LEDs in a bit  
    heartbeatLEDdurationTimerID = myTimer.setTimeout ( heartbeatLEDduration, heartbeatLEDblink ); 
    
    Serial.print ( "... heartbeat of " ); Serial.print ( PROGRAM_NAME ); 
    Serial.print ( " WiFi.status() = " ); Serial.print ( WiFi.status() );  
  }
  
  heartbeatLEDon = ! heartbeatLEDon; // flip status
} //end heartbeatLEDblink




// CALLED WHEN CONNECTING TO BLYNK SERVERS
// GETS CALLED IMMEDIATELY ON FIRST CONNECT
// THIS SYNCS UP SLIDER AND PUSHBUTTON WHEN BLYNK CONNECTS - EVEN FOR THE FIRST TIME
BLYNK_CONNECTED()
{
  Serial.println ( "\nBLYNK_CONNECTED..." );  
}

Hi @khoih
Getting there.

I am testing the code as you sent to me. Included below. Thanks for making it easy for me !

It appears the LOAD_DEFAULT_CONFIG_DATA is not doing what I’m expecting.
What I think I see is that the previous values stored in EEPROM are still being used after a new compile and upload.

In this log, you see items [628] – [632] show values that are not in the code. These are PREVIOUS values I loaded from the Config Portal in a previous compile and upload.
They appear to not be overwriting in the new compile and execute.

Additional question: what purpose does Blynk.config ( bklynkAuth ); have in line 197 now? How is the authcode set using WM?

My test code is below. Have fun. (I am.)

Here’s my log…

AAA-Blynk WiFiMgr Demo_ESP32_ESP8266 ** Using SSL ** 
Setting up WLAN and Blynk WITH WiFiManager
Starting Blynk.begin (with WM)
Blynk.setConfigPortal(TestPortal, 123);
[567] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on NodeMCU

[627] Hostname=Blynk-Configurator
[627] CCSum=0x2eea,RCSum=0x2eea
[628] Hdr=SSL_ESP8266,BrdName=Air-Control
[628] SSID=SSID2,PW=password2
[628] SSID1=<my_real_SSID>,PW1=<my_real_pass>
[629] Server=blynk-cloud.com,Token=<my_Blynk_auth_token>
[632] Server1=account.duckdns.org,Token1=token1
[634] Port=9443
[635] ======= End Config Data =======
[637] Connecting MultiWifi...
[3640] WiFi connected after time: 1
[3640] SSID: <my_real_SSID>, RSSI = -54
[3640] Channel: 6, IP address: 192.168.4.56
[3640] bg: WiFi OK. Try Blynk
[3641] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on NodeMCU

[4161] NTP time: Mon Apr 27 21:42:06 2020
[4161] Connecting to blynk-cloud.com:9443
[5017] Certificate OK
[5035] Ready (ping: 2ms).

BLYNK_CONNECTED...
[5120] Connected to Blynk Server = blynk-cloud.com, Token = <my_Blynk_auth_token>
[5120] bg: WiFi+Blynk OK
Blynk connected just fine


Blynk using EEPROM connected. Board Name : Air-Control
EEPROM size = 2048 bytes, EEPROM start address = 512 / 0x200
Setting up Blynk timer
..Blynk config and timers setup complete

... heartbeat of AAA-Blynk WiFiMgr Demo_ESP32_ESP8266 WiFi.status() = 3
Setup complete

end of log

Hers’s my code:

#define SERIAL_SPEED 230400
#define PROGRAM_NAME "AAA-Blynk WiFiMgr Demo_ESP32_ESP8266"
// Uses ESP32 and ESP8266 to select compile choices


//BLYNK Stuff here
#define BLYNK_PRINT Serial

#define USE_SSL true // to easily select SSL or not
//#define USE_SSL false // to easily select SSL or not

#define USE_WM true   // to easily select WiFi Manager or not
//#define USE_WM false   // to easily select WiFi Manager or not
// REMEMBER: not using _WM means we manage our own initial WiFi connection


#if USE_WM
  #define USE_SPIFFS false  // Choosing EEPROM over SPIFFS here

  #if (!USE_SPIFFS)
    // EEPROM_SIZE must be <= 2048 and >= CONFIG_DATA_SIZE (currently 172 bytes)
    #define EEPROM_SIZE    (2 * 1024)
    // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE
    #define EEPROM_START   512
  #endif

  #define USE_DYNAMIC_PARAMETERS false  // see Github doc
  
  // Force some params in Blynk, only valid for library version 1.0.1 and later
  // (from the Github doc)
  #define TIMEOUT_RECONNECT_WIFI                    10000L
  #define RESET_IF_CONFIG_TIMEOUT                   true
  #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET    5
#endif


#if USE_SSL
  #ifdef ESP8266
    #if USE_WM
      #include <BlynkSimpleEsp8266_SSL_WM.h>
    #else
      #include <BlynkSimpleEsp8266_SSL.h>
    #endif
  #endif
  #ifdef ESP32
    #if USE_WM
      #include <BlynkSimpleEsp32_SSL_WM.h> 
    #else
      #include <BlynkSimpleEsp32_SSL.h>
    #endif
  #endif
  
#else // NOT using SSL
  #ifdef ESP8266
    #if USE_WM
      #include <BlynkSimpleEsp8266_WM.h>
    #else
      #include <BlynkSimpleEsp8266.h>
    #endif
  #endif
  #ifdef ESP32
    #if USE_WM
      #include <BlynkSimpleEsp32_WM.h>
    #else
      #include <BlynkSimpleEsp32.h>
    #endif
  #endif
#endif


#if USE_WM
  #define USE_DYNAMIC_PARAMETERS false

  MenuItem myMenuItems [] = {};

  uint16_t NUM_MENU_ITEMS = 0;

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

bool LOAD_DEFAULT_CONFIG_DATA = true;
//bool LOAD_DEFAULT_CONFIG_DATA = false;

Blynk_WM_Configuration defaultConfig =
{
  //char header[16], dummy, not used
#if USE_SSL  
  "SSL",
#else
  "NonSSL",
#endif
  //WiFi_Credentials  WiFi_Creds  [NUM_WIFI_CREDENTIALS]
  //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw
  "SSID2", "password2",
  "Baloney", "Baloney",
  // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS];
  // Blynk_Creds.blynk_server and Blynk_Creds.blynk_token
  "account.duckdns.org",  "token1", 
  "blynk-cloud.com",     "<my_Blynk_auth_token>",
  //int  blynk_port;
#if USE_SSL
  9443,
#else
  8080,
#endif
  //char board_name     [24];
  "Air-Control",
  //int  checkSum, dummy, not used
  0
};

/////////// End Default Config Data /////////////
  
#endif // USE_WM



char blynkAuth[] = "<my auth>"; // BLYNK Auth 

char WiFiSSID[] = "<my ssid";  // network SSID (name)
char WiFiPass[] = "<my passcode>";  // network password



BlynkTimer myTimer;
// Blynk timers to blink a heartbeat LED on and off
int heartbeatLEDinterval = 3000; // interval between heartbeats for onboard and Blynk Virtual LED in millisec 
int heartbeatLEDtimerID; 

int heartbeatLEDduration = 750; // duraction of each blink in millisec (set as an interval timer)
int heartbeatLEDdurationTimerID;
bool heartbeatLEDon = false; // this lets me use the same routine for the turn-on timer and the turn-off interval

#define BLYNK_HEARTBEAT_LED V2
WidgetLED heartbeatLED( BLYNK_HEARTBEAT_LED );  // want a blinking LED on the display to show we're live



/* setup
 *  Set up WiFi, Blynk & Blynk timers 
 *  Set up Blue LED on board
 */
void setup() 
{
  Serial.begin ( SERIAL_SPEED );
  delay ( 500 );  
  Serial.println ( "\n\n=======================================" );
  Serial.print ( PROGRAM_NAME ); 
  #if USE_SSL
    Serial.println ( " ** Using SSL ** \n" );  
  #endif
  Serial.println();
  
  connectToLANandBlynk();  

  // Initialize Onboard LED 
  pinMode ( LED_BUILTIN, OUTPUT );  
  digitalWrite ( LED_BUILTIN, LOW ); 
    
  // Set Blynk Virtual LED OFF
  heartbeatLED.off(); // Blynk Virtual LED
  heartbeatLEDblink(); // first heartbeat 
  
  Serial.println ( "\nSetup complete \n" );    
  
} //end setup




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




void connectToLANandBlynk()
{
  // Setup WLAN and Blynk
  Serial.print ( "\nSetting up WLAN and Blynk " );  
  #if USE_WM
    Serial.println ( "WITH WiFiManager" ); 
  #else
    Serial.println ( "WITHOUT WiFiManager" );  
  #endif
  
  #if USE_WM
    Serial.println ( "Starting Blynk.begin (with WM)" );  

    Blynk.setConfigPortal ( "TestPortal", "12345678" );
    Serial.println ( "Blynk.setConfigPortal(TestPortal, 123);" );  

    Blynk.setConfigPortalIP ( IPAddress ( 192, 168, 220, 1 ) );  
    Blynk.config ( blynkAuth );
    Blynk.begin ( "Blynk-Configurator" ); 
    
  #else//NOT using WM
    Serial.println ( "Starting WiFi.begin (no WM)" );  
    WiFi.begin ( WiFiSSID, WiFiPass );
    Serial.println ( "... waiting a few seconds for WiFi ..." );    
    delay ( 7000 );  // For esp8266, it needs a delay to realize it has connected
    
    // REBOOT if we do not have a good WiFi connection
    if ( WiFi.status() != WL_CONNECTED )
    {
      Serial.println ( "Resetting in a few seconds..." );
      delay ( 3000 );  
      ESP.restart();
    } 
    
    // Configure and launch Blynk
    Blynk.config ( blynkAuth );
    Blynk.connect ( 2500 ); // Don't get stuck hanging for more than 2500 millis.
  #endif // using WM
  
  if ( Blynk.connected() ) Serial.println ( "Blynk connected just fine\n" ); 
  else Serial.println ( "Blynk NOT CONNECTED \n\n" );  

  #if USE_WM
    #if USE_SPIFFS
      Serial.println("\nBlynk using SPIFFS connected. Board Name : " + Blynk.getBoardName());
    #else
      Serial.println("\nBlynk using EEPROM connected. Board Name : " + Blynk.getBoardName());
      Serial.printf("EEPROM size = %d bytes, EEPROM start address = %d / 0x%X\n", EEPROM_SIZE, EEPROM_START, EEPROM_START);
    #endif
  #endif


  Serial.println ( "Setting up Blynk timer" );  
  // Interval timer for heartbeatLED (Blynk LED and onboard LED
  heartbeatLEDtimerID = myTimer.setInterval ( heartbeatLEDinterval, heartbeatLEDblink );  

  Serial.println ( "..Blynk config and timers setup complete\n" );  
} //end connectToBlynk




void heartbeatLEDblink()
/* Blink the on-board LED AND the Virtual Blynk LED
 * First time called, it turne the LEDs on, then sets a timer to turn LED off
 * When the timer triggers, same routine turns the LEDs off
 */
{
  if ( heartbeatLEDon ) // if LED is on, turn it off and vice cersa
  {
    heartbeatLED.off(); // Blynk Virtual LED
    
    digitalWrite ( LED_BUILTIN, LOW ); // On-board LED
    
    Serial.println ( " ..." );
  } else
  {
    heartbeatLED.on();      // Blynk Virtual LED
    
    digitalWrite ( LED_BUILTIN, HIGH );  // On-board LED
    
    // Set the timer to turn off the LEDs in a bit  
    heartbeatLEDdurationTimerID = myTimer.setTimeout ( heartbeatLEDduration, heartbeatLEDblink ); 
    
    Serial.print ( "... heartbeat of " ); Serial.print ( PROGRAM_NAME ); 
    Serial.print ( " WiFi.status() = " ); Serial.print ( WiFi.status() );  
  }
  
  heartbeatLEDon = ! heartbeatLEDon; // flip status
} //end heartbeatLEDblink




// CALLED WHEN CONNECTING TO BLYNK SERVERS
// GETS CALLED IMMEDIATELY ON FIRST CONNECT
BLYNK_CONNECTED()
{
  Serial.println ( "\nBLYNK_CONNECTED..." );  
}

1Q. How can my sketch pre-program default values for the WM Config Portal? It would be nice to not start with blanks everywhere in the Portal.

1A. That’s a good idea for future version. Currently, at the first time without any valid data, the values are cleared to blank so that essential values must be input to be different from blank or ConfigPortal will stay.

Repeating our conversation yesterday: it would be useful to be able to pre-populate the Config Portal fields so we do not start with blanks each time.

In this log, you see items [628] – [632] show values that are not in the code. These are PREVIOUS values I loaded from the Config Portal in a previous compile and upload.
They appear to not be overwriting in the new compile and execute.

I’m afraid that is the idea behind the Config Portal we’d agree on in previous conversation as the stored Cred are still valid and Config Portal not opened.

The default values for Config Portal is uploaded into Config Portal (to save time for you to retype and also permit you to change faster if for too many boards) and replace the old Credentials if and only if the Config Portal is opened and Save is selected.
Otherwise, the default Credentials is not used at all.

If you’d like the default Creds are always loaded and the stored Creds bypassed, that’s a different scenario. It’s can be done easily but I don’t know if this is good use case as this is similar to the hardcoded scenario we’d like to avoid.

Doing so,

  1. Config Portal is not used and
  2. it presents a potential danger as well as inconvenience as you have to always keep the correct (not just dummy) Credentials in the code instead of storing in EEPROM/SPIFFS. In development, whenever you have a blank Creds. Config Portal will open and get the valid Creds. From that moment, you can replace the valid Creds file with the dummy Creds file.

Certainly, If you wish, I’ll try to explore an option to always use the default hardcoded Creds instead of stored and still valid Creds.

In development, DRD comes to rescue. Did you have chance to try DRD? Like it?
Just pressing RESET twice within 10s, Config Portal will come and give you your wish :wink:

Please give this some more thoughts and discuss later.

Additional question: what purpose does Blynk.config ( bklynkAuth ); have in line 197 now? How is the authcode set using WM?

I think Blynk.config ( blynkAuth ); in line 197 is not necessary and must be deleted. I really haven’t looked thru your recent code to see it as we already knew previously

I also killed the Blynk.config line when using _WM. I missed that.

In WM, that Blynk.config ( blynkAuth ); must be called somewhere in the WM code so that Blynk Server is happy.

bool connectMultiBlynk(void)
{
#define BLYNK_CONNECT_TIMEOUT_MS      5000L

 ...
        config(BlynkESP32_WM_config.Blynk_Creds[i].blynk_token,
               BlynkESP32_WM_config.Blynk_Creds[i].blynk_server, 
               BLYNK_SERVER_HARDWARE_PORT);
...

    }

Happy go on searching and exploring :heart_eyes: