Recently I noticed that when the WiFi router is on (WiFi is available) but the internet connection is lost from ISP the program stops. Even if I hard reboot the ESP board it will start and then stop here. “CONNECTING_NET => CONNECTING_CLOUD”
In order to eliminate all variables I used the example Edgent program, I made no changes other than adding Template ID and name, adding a timer, set the interval to 3 seconds to print some to the serial monitor so I monitor function in the serial monitor.
This is the output from the serial monitor
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/__/ v1.1.0 on ESP8266
#StandWithUkraine StandWithUkraine | #StandWithUkraine banner and related documents
 Product: GCU 3114
 Firmware: 3.1.14 (build Jan 6 2023 18:08:50)
 Token: fodJ - •••• - ••���• - ••••
 Device: ESP8266 @ 80MHz
 MAC: 84:F3:EB:B2:CA:DA
 Flash: 4096K
 ESP core: 3.0.2
 ESP SDK: 2.2.2-dev(38a443e)
 Boot Ver: 31
 Boot Mode:1
 FW info: 560560/1536000, MD5:6c444c9d66ab2766922a6ddc09333025
 Free mem: 29352
 INIT => CONNECTING_NET
 Connecting to WiFi: SenseIQ 2.4G
 Using Dynamic IP: 10.0.0.4
 CONNECTING_NET => CONNECTING_CLOUD
It does not move past this point when the router is on (no internet). In order to get past this point I switch off the router, and reboot the ESP then it will search for wifi, but not get it and my program continues to the point Edgent reboot the ESP (when it reaches the “WIFI_CLOUD_MAX_RETRIES”) and we start over (which is fine).
What can be done so that my code can run ‘offline’? I have customers where devices are not working due to this.
I’d suggest using FreeRTOS with an esp32 board. No matter whether there is an internet connection or not, FreeRTOS code will keep running.
That’s the way that the Blynk Edgent example sketch is designed to work.
Blynk is an IoT system, and the Edgent example is designed to go through a process of attempting to connect to WiFi and the Blynk cloud server until it succeeds. Without these connections Blynk can’t operate.
If you want to change the behaviour of the Edgent example then it’s a fairly major re-write of that sketch.
An alternative is to switch to using an ESP32 board, and make use of the dual core features of that processor. You’d need to run the Blynk Edgent code in one core and your offline code (which presumably allows control via physical buttons) in the other core. You’d need to remove the calls to
restartMCU() in the Edgent code, as this would reboot the entire board, not just core that’s running the Blynk code.
It’s still a fairly substantial rewrite, but there are a few topic on the subject in the forum if you do some searching.
Thanks John and Pete,
I am using FreeRTOS with ESP projects, and it works great.
I want to focus on resolving the first issue where the program halt/hang and never recover unless a hard reboot to the D1 mini is introduced.
Problem: When the WiFi router loses internet (ISP problem etc) the program will reboot when an error is detected and will start up, connecting to WiFi, allocating dynamic IP, then only to get stuck trying to connect CONNECTING_NET => CONNECTING_CLOUD.
As I already mentioned, I used a blank Edgent example to eliminate any code mistakes I may have on my side. Trying to get to the root cause we switched off the router (simulating internet loss) the program then work as it should (detect error and reboot, repeat until the issue is resolved). So all is fine IF the router is not present. The moment the router is on (WiFi is on but ISP cable unplugged) and there is no internet the program gets stuck at CONNECTING_NET => CONNECTING_CLOUD and never recovers.
Is there from your experience anything that can be done here? I have many devices in the field that is failing due to this.
I did report an official issue also.
Thanks in Advance
My esp32 doesn’t reset even if I turn off the router. Do you have an ESP32 board? If yes, I can send you a simple sketch to try.
Yes please, that would be great.
Just a note, we made a few changes to the code adding ‘Serial.print’ to understand where the code hangs, during the “enterConnectCloud” call, it hangs when the program call “Blynk.run();”
Waiting for your code,
We ran the code you provided on a Lolin32 board and it’s very similar to what we use in our larger products where we utilize the FreeRTOS (similar).
The problem is not with the ESP32, it’s how Edgent execute while WiFi is available but not internet!
What exactly happens when “enterConnectCloud” call Blynk.run();?
The program halts here when the above scenario is true. If I can find a place to add a ‘timeout’ (reboot) then we will be ok if there is no internet but WiFi is present.