BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk.connectWiFi() vs WiFi.begin(ssid, pass)

The only difference in between the 2 commands is that Blynk.connectWiFi(ssid, pass) is a blocking code where the WiFi.begin(ssid, pass) does not?

I don’t think either one is blocking. Although I tend to use the wifi.begin() for all my devices.

#include <ESP8266WiFi.h>  // Espressif? WiFi setup
#include <BlynkSimpleEsp8266.h>

char auth[] = "xxxxxxxxxx";
char server[] = "blynk-cloud.com";
char ssid[] = "xxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
int port = 8080;

void setup() {
  // Connect to your WiFi network, then to the Blynk Server
  WiFi.begin(ssid, pass);
  Blynk.config(auth, server, port);
  Blynk.connect();
}

It seems using Blynk.connectWiFi() simply removes the need for #include <ESP8266WiFi.h>

//#include <ESP8266WiFi.h>  // Espressif? WiFi setup
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxxxxxxxxx";
char server[] = "blynk-cloud.com";
char ssid[] = "xxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
int port = 8080;

void setup() {
  // Connect to your WiFi network, then to the Blynk Server
  //WiFi.begin(ssid, pass);  // Espressif? WiFi setup
  Blynk.connectWiFi(ssid, pass);  // Blynk WiFi setup
  Blynk.config(auth, server, port);
  Blynk.connect();
}

Probably much like the inclusion of SimpleTimer into the library with BlynkTimer instead of needing to include the SimpleTimer library.

2 Likes

I found out that Blynk.connectWiFi(ssid, pass) is a blocking code and it is not covering wifi issues first by testing your example from here, then by reading your notes. So, thanks! :slight_smile:

So I tried with WiFi.begin(ssid, pass) instead and I ran it through all the connection failure situations I could think of.

Here is the final example in case if someone finds it useful.

2 Likes