Hello Guys,
And first thank you for all the precious answers i got from here.
I’m running some esp8266 and ESP32 device on a local Wifi network and i connected a local Blynk server on Raspberry 4 on it.
I don’t need Blynk to run all the time ( just for few special control of my devices) , and i’m trying to find a way to bypass blynk when there is no local server on the network, and then continue the void setup() without blynk.
I checked solutions to go through Blynk.connect(timeout) , with a timer , but whatever i do, its working really well on ESP8266 ( i checked on a wemos D1 mini pro ) with less than 3s of timeout before telling me if Blynk local server is connected or not.But when i’m trying on an ESP32 ( Lolin D32) , its just like the device is not considering the timeout from the Blynk.connect(), and i have more than 18s before having an answer from the arduino, and its too much for my system. It’s exactly the same code , just switch
Esp8266Wifi> and to <Wifi.h> and
Any idea ?
This is my Esp8266 code , with the 2 libraries changed for ESP32.
> #include <ESP8266WiFi.h>
> #include <BlynkSimpleEsp8266.h>
> #define BLYNK_DEBUG
> #define BLYNK_PRINT Serial
>
> char auth[] = "IG_gS43Sshb8dOqVdVSI3GUgIlCszlln";
> char ssid[] = "Wifiled";
> char pass[] = "**";
> char server[] = "192.168.0.3";
>
> IPAddress local_ip(192, 168,0,69);
> IPAddress gateway(192, 168,0, 1);
> IPAddress subnet(255, 255, 255, 0);
>
> boolean ConnectWifi(void)
> {
> boolean state = true;
> int i = 0;
>
> WiFi.config(local_ip, gateway, subnet);
> WiFi.begin(ssid, pass);
> Serial.println("");
> Serial.println("Connecting to WiFi");
>
> // Wait for connection
>
> Serial.print("Connecting");
> //while (status != WL_CONNECTED) {
> while (WiFi.status() != WL_CONNECTED) {
> delay(500);
> Serial.print(".");
>
> if (i > 20) {
> state = false;
> break;
> }
> i++;
> }
> if (state) {
> Serial.println("");
> Serial.print("Connected to ");
> Serial.println(ssid);
> Serial.print("IP address: ");
> Serial.println(WiFi.localIP());
> } else {
> Serial.println("");
> Serial.println("Connection failed.");
> }
> return state;
> }
> void setup()
> {
> Serial.begin(9600);
>
> ConnectWifi();
> Serial.println("Wifi OK , now blink");
> Blynk.config(auth, server, 8080);
> int mytimeout = millis() / 1000;
>Blynk.connect(3000);
> if (Blynk.connected() == true ){
> Serial.print ("Blynk connected");
> }else
> {
> Serial.print ("Disconnected");
> }
>
> }
> void loop()
> {
> if(Blynk.connected() == true){
> Blynk.run();
> }
> }