Blynk.edgent nodemcu example, unable to reset configuration by pressing flash button during this condition (CONNECTING_NET => CONNECTING_CLOUD)

• Hardware model NodeMCU + communication type.Wifi
• Smartphone OS (Android) + 8
• Blynk server or local server Blynk server
• Blynk Library version Latest

02:02:37.789 → [660] INIT => CONNECTING_NET
02:02:37.789 → [662] Connecting to WiFi: Red4mi
02:02:45.529 → [8398] Using Dynamic IP: 192.168.43.76
02:02:45.529 → [8398] CONNECTING_NET => CONNECTING_CLOUD
02:02:53.270 → [16159] Hold the button for 10 seconds to reset configuration…
02:03:04.811 → [27669] CONNECTING_CLOUD => RESET_CONFIG
[658] --------------------------
02:03:14.201 → [658] INIT => CONNECTING_NET
02:03:14.201 → [660] Connecting to WiFi: Red4mi
02:03:21.981 → [8415] Using Dynamic IP: 192.168.43.76
02:03:21.981 → [8415] CONNECTING_NET => CONNECTING_CLOUD

Have you tried to reconfigure the device using the app ?

Yes, But in this condition device is not connected with internet. So it won’t react.
You can also create this situation, when internet is turned off but wifi is connected.
In this situation either we press flash button for 10 sec, or reboot. But after this it will again try to connect previous wifi address.

I’m attaching ConfigMode.h lines here.
/**************************************/

void enterConnectCloud() {
  BlynkState::set(MODE_CONNECTING_CLOUD);

  Blynk.disconnect();
  Blynk.config(configStore.cloudToken, configStore.cloudHost, configStore.cloudPort);
  Blynk.connect(0);

  unsigned long timeoutMs = millis() + WIFI_CLOUD_CONNECT_TIMEOUT;
  while ((timeoutMs > millis()) &&
        (Blynk.connected() == false))
  {
    Blynk.run();
    if (!BlynkState::is(MODE_CONNECTING_CLOUD)) {
      Blynk.disconnect();
      return;
    }
  }
  
  if (Blynk.connected()) {
    BlynkState::set(MODE_RUNNING);

    if (!configStore.flagConfig) {
      configStore.flagConfig = true;
      config_save();
      DEBUG_PRINT("Configuration stored to flash");
    }
  } else {
    BlynkState::set(MODE_ERROR);
  }
}

void enterSwitchToSTA() {
  BlynkState::set(MODE_SWITCH_TO_STA);

  DEBUG_PRINT("Switching to STA...");

  WiFi.mode(WIFI_OFF);
  delay(1000);
  WiFi.mode(WIFI_STA);

  BlynkState::set(MODE_CONNECTING_NET);
}

void enterError() {
  BlynkState::set(MODE_ERROR);
  
  unsigned long timeoutMs = millis() + 10000;
  while (timeoutMs > millis() || g_buttonPressed)
  {
    delay(10);
    if (!BlynkState::is(MODE_ERROR)) {
      return;
    }
  }
  DEBUG_PRINT("Restarting after error.");
  delay(10);

  restartMCU();
} ```

With me there's no timeout & nor (g_buttonPressed) is working. Either you flash wifi settings or setup a new AP/Wifihotspot with same name & password which device wants & turn off the previous one. Then only you can do anything with it.

Open arduino ide and go to tools / erase flash / all flash contents

@Seth_MSR please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

It won’t resolve problem permanently, If it’s in remote client location then the problem will be more worse. Need help in ConfigMode.h, Can we put some condition there ? If you have any idea then please suggest.

https://docs.blynk.io/en/getting-started/activating-devices/blynk-edgent-wifi-provisioning#how-wifi-provisioning-works

Actually i simulated this scenario and it works as intended to. Like :

What ever the state of the connection is -

wifi available but no internet.

Wifi available, internet is available.

No wifi is available.

If the re-configure button is pressed, the device reboots and starts in AP mode. So now we can connect to it and configure the device on Blynk app.

I dont get it, why this is not happening in your case. But this is how it should work.

Madhukesh while condition no 01 (Wifi available, but no internet…). Please press a reboot button.

I’m getting this situation in serial monitor.

INIT => CONNECTING_NET
20:17:18.747 → [660] Connecting to WiFi: Redmti1
20:17:22.697 → [4651] Using Dynamic IP: 192.168.43.56
20:17:22.697 → [4651] CONNECTING_NET => CONNECTING_CLOUD

Yeah i understood your situation. But i am not facing the same here. Did you modify the header files by any chance?

EDIT:

Have you mistaken the reset button to configure button ? Ex: nodemcu has on board reset button, and re configure button is different.

Just making sure you doing the right thing.

You can find the pin number in settings.h

Obviously Yaar :smile:

Using inbuilt flash button, but even after pressing it for 10secs or more Nothing gets changed.

21:39:38.066 → [623] INIT => CONNECTING_NET
21:39:38.066 → [625] Connecting to WiFi: Red4mi
21:39:46.796 → [9383] Using Dynamic IP: 192.168.43.76
21:39:46.796 → [9383] CONNECTING_NET => CONNECTING_CLOUD
21:40:42.216 → [64804] Hold the button for 10 seconds to reset configuration…
21:40:57.945 → [80527] CONNECTING_CLOUD => RESET_CONFIG
21:40:57.945 → [80527] Hold the button for 10 seconds to reset configuration…

In my case nothing is happened after [CONNECTING_CLOUD => RESET_CONFIG]. Its just showing RESET_CONFIG but not doing anything further. If I press reset button then it will again show
[INIT => CONNECTING_NET
Connecting to WiFi: Red4mi
Using Dynamic IP: 192.168.43.76
CONNECTING_NET => CONNECTING_CLOUD]

What if you reboot the device after the Reconfig is carried out ?

Are you using the example sketch of edgent ? No edits ?

Have you selected the 3M 4M flash size while uploading the sketch ? I dont know this may or may not cause the issue just a guess work.

What if you reboot the device after the Reconfig is carried out ? – Actually situation doesn’t change after pressing flash button for 10 sec, Then I reboot it to reconfirm.

Are you using the example sketch of edgent ? No edits ? – 100% example
Have you selected the 3M 4M flash size while uploading the sketch ? Tried Both of top two, without sucess.

(Ideal situation)
CONNECTING_NET => RESET_CONFIG
22:01:23.835 → [29221] Hold the button for 10 seconds to reset configuration…
22:01:23.835 → [29221] Hold the button for 10 seconds to reset configuration…
22:01:23.835 → [29226] Resetting configuration!
22:01:23.883 → [29259] Configuration stored to flash
22:01:23.883 → [29259] RESET_CONFIG => WAIT_CONFIG
22:01:23.977 → [29377] Hold the button for 10 seconds to reset configuration…
22:01:23.977 → [29377] Hold the button for 10 seconds to reset configuration…
22:01:24.446 → [29867] AP SSID: Blynk NodeMCUIR-12B07
22:01:24.493 → [29867] AP IP: 192.168.4.1
22:01:24.493 → [29868] AP URL: blynk.setup

In short not getting – Resetting configuration!

What board type do you have un-commented in Edgent_ESP8266.ino ?

What does the portion of the Settings.h file that relates to that board type look like?

What version of the Blynk library are you using, and is your Edgent example taken from that version, and earlier version, or the core files on GitHub?

Pete.

What board type do you have un-commented in Edgent_ESP8266.ino ? - → #define USE_NODE_MCU_BOARD.

What does the portion of the Settings.h file that relates to that board type look like? →


  #define BOARD_BUTTON_PIN            0
  #define BOARD_BUTTON_ACTIVE_LOW     true

  #define BOARD_LED_PIN               2
  #define BOARD_LED_INVERSE           true
  #define BOARD_LED_BRIGHTNESS        255 ```


What version of the Blynk library are you using? -->  1.0.1
and is your Edgent example taken from that version? ---> Yes

I installed blynk from Arduino Library manager.

During Connection failed if you press flash button you can reach to Resetting configuration!

23:46:47.811 → [1033626] CONNECTING_CLOUD => RUNNING
23:46:47.857 → [1033659] Configuration stored to flash
23:47:50.824 → [1096626] Heartbeat timeout
23:47:51.105 → [1096928] RUNNING => CONNECTING_CLOUD
23:47:51.151 → [1096939] Current time: Tue Nov 2 18:17:51 2021
23:47:51.151 → [1096939] Connecting to blynk.cloud:443
23:47:51.151 → [1096944] Connection failed
23:47:56.145 → [1101950] Current time: Tue Nov 2 18:17:56 2021
23:47:56.145 → [1101950] Connecting to blynk.cloud:443
23:47:56.145 → [1101958] Connection failed
23:48:01.134 → [1106953] Current time: Tue Nov 2 18:18:01 2021
23:48:01.134 → [1106953] Connecting to blynk.cloud:443
23:48:01.134 → [1106962] Connection failed
23:48:06.170 → [1111958] Current time: Tue Nov 2 18:18:06 2021
23:48:06.170 → [1111958] Connecting to blynk.cloud:443
23:48:06.170 → [1111966] Connection failed
23:48:11.171 → [1116961] Current time: Tue Nov 2 18:18:11 2021
23:48:11.171 → [1116961] Connecting to blynk.cloud:443
23:48:11.171 → [1116969] Connection failed
23:48:16.164 → [1121967] Current time: Tue Nov 2 18:18:16 2021
23:48:16.164 → [1121967] Connecting to blynk.cloud:443
23:48:16.164 → [1121976] Connection failed
23:48:21.168 → [1126970] Current time: Tue Nov 2 18:18:21 2021
23:48:21.168 → [1126970] Connecting to blynk.cloud:443
23:48:21.168 → [1126978] Connection failed
23:48:26.161 → [1131975] Current time: Tue Nov 2 18:18:26 2021
23:48:26.161 → [1131975] Connecting to blynk.cloud:443
23:48:26.161 → [1131983] Connection failed
23:48:31.159 → [1136984] Current time: Tue Nov 2 18:18:31 2021
23:48:31.159 → [1136984] Connecting to blynk.cloud:443
23:48:31.207 → [1137005] Connection failed
23:48:36.204 → [1141989] Current time: Tue Nov 2 18:18:36 2021
23:48:36.204 → [1141989] Connecting to blynk.cloud:443
23:48:36.204 → [1142001] Connection failed
23:48:41.204 → [1146995] Current time: Tue Nov 2 18:18:41 2021
23:48:41.204 → [1146996] Connecting to blynk.cloud:443
23:48:41.204 → [1147010] Connection failed
23:48:46.211 → [1151996] Current time: Tue Nov 2 18:18:46 2021
23:48:46.211 → [1151996] Connecting to blynk.cloud:443
23:48:46.211 → [1152005] Connection failed
23:48:51.119 → [1156934] Timeout
23:48:51.119 → [1156934] CONNECTING_CLOUD => ERROR
23:49:01.119 → [1166936] Restarting after error.

But not succesful if device enters:

23:49:01.865 → [622] INIT => CONNECTING_NET
23:49:01.865 → [624] Connecting to WiFi: Redmti1
23:49:09.560 → [8296] Using Dynamic IP: 192.168.43.56
23:49:09.560 → [8296] CONNECTING_NET => CONNECTING_CLOUD
23:49:30.696 → [29438] Hold the button for 10 seconds to reset configuration…
23:49:44.935 → [43681] CONNECTING_CLOUD => RESET_CONFIG

Not getting any time out for [ CONNECTING_NET => CONNECTING_CLOUD ].

How I get out of this situation: Just turn off internet not connected wifi & press reset button. After that press flash button for 10 sec. Then you will get something like this.

23:59:47.690 → [623] INIT => CONNECTING_NET
23:59:47.690 → [625] Connecting to WiFi: Redmti1
00:00:17.722 → [30635] CONNECTING_NET => ERROR
00:00:27.724 → [40639] Restarting after error.

00:00:28.469 → [623] INIT => CONNECTING_NET
00:00:28.469 → [625] Connecting to WiFi: Redmti1
00:00:33.987 → [6169] Hold the button for 10 seconds to reset configuration…
00:00:46.143 → [18301] CONNECTING_NET => RESET_CONFIG
00:00:46.143 → [18302] Resetting configuration!
00:00:46.190 → [18335] Configuration stored to flash
00:00:46.190 → [18336] RESET_CONFIG => WAIT_CONFIG
00:00:46.798 → [18943] AP SSID: Blynk NodeMCUIR-12B07
00:00:46.798 → [18944] AP IP: 192.168.4.1
00:00:46.798 → [18944] AP URL: blynk.setup.

Conclusion: If wifi not connected we can reach reconfiguration.
But if wifi is connected but internet is not there, then after some time you will reach at [ CONNECTING_NET => CONNECTING_CLOUD], from there you cant reach configuration untill you try the condition mentioned in start of this reply.