blynkkk / blynk-library

Blynk library for IoT boards. Works with Arduino, ESP32, ESP8266, Raspberry Pi, Particle, ARM Mbed, etc.
https://blynk.io
MIT License
3.81k stars 1.38k forks source link

[ESP32] SimpleWifi Reconnect #460

Closed cujomalainey closed 4 years ago

cujomalainey commented 5 years ago

Blynk library version: 0.6.1 IDE: Neovim IDE version: N/A Board type: Adafruit Feather HUZZAH32 Additional modules: External LEDs

Scenario, steps to reproduce

Start a device, let it connect to wifi, disconnect wifi (e.g. disconnect router or turn off hotspot) then plug back in an resume wifi

Expected Result

Device would resume wifi when it becomes available

Actual Result

Device is stuck forever re-attempting to connect to the server

[21543] Connecting to blynk-cloud.com:80
[E][WiFiClient.cpp:220] connect(): lwip_connect_r: 118
[26544] Connecting to blynk-cloud.com:80
[E][WiFiClient.cpp:220] connect(): lwip_connect_r: 118

Side notes

From what I can tell. It appears the ESP32 needs an explicit disconnect when a WiFi connection fails. I was digging around but I can't tell if it is getting that call from within the framework.

cujomalainey commented 5 years ago

For those also experiencing this issue, I found a work around


bool connected = false;
void setup() {}

void loop()
{
  if(!Blynk.connected() && connected) {
    Blynk.disconnect();
    delay(500);
    connected = false;
    Blynk.begin(auth, ssid, pass);
  } else {
    connected = true;
  }
  Blynk.run();
}
pradgood commented 5 years ago

Hi I tried it but no success Find a way to repower the board.

cujomalainey commented 5 years ago

@pradgood there is a fix upstream in the ESP32 library for this wifi issue, should roll out in the next while https://github.com/espressif/arduino-esp32/issues/2769#issuecomment-491580150

vshymanskyy commented 4 years ago

I think this was mainly related to instability of ESP32 Arduino core. Feel free to reopen the issue if it still happens

nodoubtman commented 2 years ago

An easy workaround i found on youtube :)

Blynk.begin(BLYNK_AUTH, ssid, password, "blynk-cloud.com", 8080);

that's all :) Have a good day. Marc.