Inquire mode BLYNK, ESP8266WiFi, ESP32 for offline connection

How do you make it work when the wireless connection is off or not connected to BLYNK, ESP8266WiFi and ESP32?

Lots of old posts about offline functionality and use of Blynk.config and Blynk.connect rather than Blynk.begin (which is a blocking function).

Do a bit of searching and you’ll find some useful info.

Pete.

Is this the code?

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

/* Fill-in your Template ID (only if using Blynk.Cloud) */
//#define BLYNK_TEMPLATE_ID   "YourTemplateID"


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

void setup()
{
  // Debug console
  Serial.begin(9600);

  WiFi.mode(WIFI_STA);

  int cnt = 0;
  while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
if (cnt++ >= 10) {
  WiFi.beginSmartConfig();
  while (1) {
    delay(1000);
    if (WiFi.smartConfigDone()) {
      Serial.println();
      Serial.println("SmartConfig: Success");
      break;
    }
    Serial.print("|");
  }
}
  }

  WiFi.printDiag(Serial);

  Blynk.config(auth);
}

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

Not really. I have no idea what…

does. You’d normally specify your SSID and password.

It also needs the three lines of firmware configuration from the Device > Device info screen in the web console pasting at the very top of your sketch.

Also, it needs a Blynk.connected() test in your void loop with Blynk.run() inside it, otherwise it will function the same way as if you were using Blynk.begin.

Pete.

I tried to make like this but in Serial.println(“Blynk Not Connected!”); and Serial.println(“Wifi no Connected!”); cant show up when i make changes

  // check WiFi connection:
  if (millis() - lastConnectionAttempt >= connectionDelay) {
    lastConnectionAttempt = millis();
    if(WiFi.status()== WL_CONNECTED){
        if(Blynk.connected() == true) {
          Serial.println("Blynk Connected!");
        } else if (Blynk.connected() == false) {
          Serial.println("Blynk Not Connected!");
          Blynk.connect();
        }
    } else {
        Serial.println("Wifi no Connected!");
    }
  }

Im not quite sure what you’re trying to achieve here, but it’s nothing like what I said here…

There are lots of examples in the forum about how to do this, you’d be better searching and reading these rather than adding random code to your sketch (which isn’t a good starting point anyway).

Pete.