Hello everybody,
I use Blynk in my Project and all works fine.
Last night the Accesspoint for WLAN ,and this is the accesspoint for the ESP8266 and Blynk is fall out.
This was because of power lose in the main town.
So what happens.
The Main Power was lost for WLAN Accespoint and also the Power for ESP 8266.
After Power come up the Accespoint with Wlan hang up.
The ESP8266 starts normal , but do not can connect to the WLAN, because the Wlan hang up.
What I See is, that the whole Programm in ESP 8266 do not work, while the WLAN connection is missing.
Iám a little bit afraid, because I thing the measure and control Programm what the ESP8266 has to do should be the first Priority …and the great Blynk features should be only for watching and viewing what is going on.
I do not thing , that the main Programm do not works if a connection to Wlan become failed.
Is there a solution how I can make a bridge over this situation, so that the connection was some few times was proved and if it not can connect, the the Main programm start nevertheless?
For the Blynk routines I only take all this was recommended here on the side.
I assume that you’re using Blynk.begin in your void setup?
This is a blocking function and will halt all code execution if the WiFi connection or the connection to the Blynk server cannot be established.
This has been discussed many times before on the forum, search for “Blynk.config” and “Blynk.connect” for information about how to overcome this.
Dear Pete,
now I read and serach about the “Blynk.config” and “Blynk.connect”.
But I do not really sure how to adapt this to me. and I do not understand some topic how to adapt this to my problem.
I try something with Blynk connect and false but, it do not works.
Do you can forward me a tip or topic were is similar to my problem?
This would be great.
Thanks Rainer
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
bool result = Blynk.connect(20);
if (result == false)
{
// What must stand here to go further in script without connection ???
}
else {};
Wire.begin(); // FRAM
Wire.setClock(400000); // 400kHz // FRAM```
Step 1, connect to WiFi using non-Blynk processes
Step 2, define the Blynk connection parameter with Blynk.config
Step 3, connect to the Blynk server using Blynk.connect
Blynk.connected is a test, to see if the device is connected to the server or not. This is very different to Blynk.connect.
Dear Pete,
thanks,
I do this and now I have the problem on the site of the Standard Wifi.
In den Lib in Keywords, there should be possible to say Wifi.End(). Buit this do not work.
Do you have a Idea , also how i can Stop the Wifi.begin after 25 tries ?
WiFi.begin(ssid, password); // Connect to the network
Serial.print("Connecting to ");
Serial.print(ssid); Serial.println(" ...");
int i = 0;
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(1000);
if (i >= 25) {
Serial.print("Timeout");
// WiFi.end(); <-------------do not works , but keyword are in Lib
}
Serial.print(++i); Serial.print(' ');
}
Serial.println('\n');
Serial.println("Connection erfolgreich");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
Blynk.config(auth);
Blynk.connect(30);
Hi Pete, thanks for your inspiration of your listed Steps.
So I come to the Solution.
Now it works…
WiFi.begin(ssid, password); // Connect to the network
Serial.print("Connecting to ");
Serial.print(ssid); Serial.println(" ...");
int i = 0;
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(1000);
if (i >= 25) {
break;
Serial.print("Timeout");
WiFi.mode(WIFI_OFF);
}
Serial.print(++i); Serial.print(' ');
}
Serial.println('\n');
Serial.println("Connection ok ");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
// ...................Blynk Parameter
Blynk.config(auth);
Blynk.connect(30);````
in this combination, the Wifi.beginn try 25 times to connect.
If not then Wifi was set off because there is no Wifi.
So the Wifi.beginn stops fur sure and the normal programm runs.
In my situation it must be sure that a lost WLAN or Blynk connection do not stop the Main programm.
The sketch I post al last works perfect for me and the situation.
If Wifi was set of , i also set blynk.disabled…
So everthing works like no Blynk and Wlan was never set… High Priorty to work Main Program.
I use Blynk in a very different way, so my code will be meaningless.
I’d suggest that you do quite a bit more testing of various scenarios to ensure that you are correct,
Connecting an ESP8266 to WiFi is a standard non-Blynk process and there are thousands of examples on the internet of how to do this, including many with limited connection attempts to allow stand-alone functionality.