I dont know it is bug or i am something doing wrong, i relase that BLYNK not connecting to server if during start time not have wifi connection (like all power restarted and arduino started before wifi not ready) .
Blynk.run () command not connecting server and serial monitor wrote about failing connect wifi.
I have waited more than one hour, when I saw that it was not connected to the server, I turned the arduino off and on. After that arduino joined the sever.
Maybe in such cases blynk.begin settings should be re-entered on the loop controlled functions?
You’d be better managing your WiFi connection yourself, with appropriate WiFi connection checking via a timer (not in the void loop), then using Blynk.config and Blynk.connect.
Inside setup function :
(I am using #include <BlynkSimpleShieldEsp8266.h> library, so i dont find wifi check function, i use just Blynk.connected() command.
while (!Blynk.connected())
{
timer.setInterval(7000L,ConnectServerAgain);
}
And
this function for reconnection to server till succesful connection
That’s because Blynk.begin is a blocking function and will halt all code execution at that point if a connection to WiFi or the Blynk server can’t be established.
On some topic adviced to add Wifi.h library so i added, now i can check WiFi.status()
void setup()
{
//Blink ve serial xeberlesme ucun
// Initialise the debug serial port
Serial.begin(115200);
// Initialise the Hardware serial1 port…
Serial3.begin(ESP8266_BAUD);
delay(10);
WiFi.begin(ssid, pass);
while (WiFi.status()!=WL_CONNECTED )
{
delay(500);
Serial.print(".");
timer.setInterval(2000L,ConnectServerAgain);
}
if(WiFi.status()==WL_CONNECTED )
{
Blynk.begin(auth, wifi, ssid, pass);
}
}
void ConnectServerAgain()
{
WiFi.begin(ssid, pass);
Serial.println("connection to wifi");
delay(500);
}
Blynk.config(auth) give error .
Upper codes not give any error but device not connection to wifi with this function (WiFi.begin(ssid, pass); , it is strange.
I’ve looked a little deeper, but there are errors that don’t match with the documentation. @Gunner wrote in this topic how to solve it
char server[] = "blynk-cloud.com";
unsigned int port = 8080;
wifi.setDHCP(1, 1, 1); //Enable dhcp in station mode and save in flash of esp8266
Blynk.config(wifi, auth, server, port);
if (Blynk.connectWiFi(ssid, pass)) {
Blynk.connect();
}
In my case (maybe blynk 2 version something changed) auth not taken
[23]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v1.1.0 on Arduino Mega
#StandWithUkraine https://bit.ly/swua
[534] Connecting to Ibadovlar
[3582] WIFI CONNECTED
AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
compile time:May 20 2016 15:08:19
OK
[8652] +CIFSR:STAIP,"192.168.1.7"
+CIFSR:STAMAC,"dc:4f:22:22:29:8d"
[8653] Connected to WiFi
[19844] Invalid auth token
Also, i have tried to delay before begin function, it is strange that after a while delay time begin function not working.
Tested, work normally for now )
Thanks for support
My code like this
wifi.setDHCP(1, 1, 1); //Enable dhcp in station mode and save in flash of esp8266 - (i dont know what it is ) )))
Blynk.config(wifi, auth, server, port);
while (Blynk.connectWiFi(ssid, pass)==false) {
delay(500);
Serial.println("repeat checking");
}
while (Blynk.connect() == false) {
// Wait until connected
}