ESP32 hangs when booting without wifi (Blynk.begin ();)

Help.
When I start the ESP32 with the WIFI network turned on, the program performs as correct.
The manual trigger only works when the network is switched off, when the network is switched on BLYNK automatically connects.

But if you start with the WIFI turned off, the program gets stuck, and does not even start LOOP ().
In other posts I realized that this happens because (Blynk.begin ():wink: tries to connect, and the LOOP is only going to work when ouver connect

Is there a way to make the program work without this failure?


#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

const int bt_anderson = 23;
const int led_manual = 19; 

char auth[] = "xxxxxxxx";
char ssid[] = "poixx";
char pass[] = "12345678";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  
pinMode (bt_anderson, INPUT_PULLUP); 
pinMode(led_manual, OUTPUT);   
}

void loop() {
Serial.println("LOOP ON");
while(true){
  if(Blynk.connected ()){
        Blynk.run();
        }else{
              Blynk.connect ();
              if(bt_anderson == 0){
                digitalWrite(led_manual, HIGH);
                }else{digitalWrite(led_manual, LOW);}
             }
   
  }
 }
}

There a ton of examples in this forum, search for Blynk.config

1 Like

really, but in none of them have I found the solution to this problem, it’s been a while since I’ve been searching here. But I need help.

Really?

I tried to help but you didn’t listen.

By searching for Blynk.config I found:

2 Likes

Calm.
Calm.
I know how to use basic Blynk.config () code, just connected in Wfi, but I always start the program without a Wifi network the program gets locked inside the SETUP (), as already said in the help request.
in this part that peciso helps.

Did you have a look on my suggestion? If you did you would have noticed that you should replace:

By

  WiFi.begin(ssid, pass);  // Non-blocking if no WiFi available
  Blynk.config(auth);
  Blynk.connect();

in case this example you mentioned is applicable to ESP32?
because when I did the search I searched for ESP32

Should be applicable, have you tried?

1 Like

Yes it is… and ESP8266, and Arduino with Ethernet, or something else with GSM…etc, and so on.

As per the Docs, it is basically a way of configuring Blynk independently of the connection method, and hardware, used.

I had read the data on this link, but I could not understand it well.
because I have to translate, the translation comes out a bit confusing.
For a better understanding, the Blynk masters always help.

I edited the programming in ESP32, I will carry out the tests.

thank you so far.

Any luck?

With what? This OP’s particular issue… who knows :stuck_out_tongue_winking_eye:

Or with the overall solution? Which was already answered in the link above… but here it is again…

Just switch to Blynk.config() and additional connection management as needed

Here is an example for such, just adjust the libraries for ESP32

If you have any further questions, please create your own topic with full details, Thank you.

Hello everyone. I have the same problem. Has anyone solved this problem? At the moment I want to build a new project on ESP32. This project requires high stability regardless of the availability of the Internet or wifi.
This code works fine if the wifi router online:

  1. Blynk.connectWiFi(ssid, pass);
  2. Blynk.config(auth, server ,port);
  3. Blynk.connect(timeout);
    However, if the router is offline the ESP32 hangs on the line №1.
    If I use instead of the first line: WiFi.begin(ssid, pass);, the code always hangs on the line №3 regardless of the connection status and timeout.