My very simple Blynk examples always fail to connect to my wifi network every other time of re-booting. It is quite consistent. First the connection dialogue stalls at connecting to DAVETT (my SSID). Re-booting repeats and connects correctly. Re-booting again repeats the failure, and so on. It’s too consistent to be a random connection issue. Am I missing something?
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
//Pullup on IP34 (not by default)
pinMode(34,INPUT_PULLUP);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
Just noticed that on the failed dialogue, it goes WIFI_READY, STA_START, STA_DISCONNECTED, AUTH_FAIL.
On the successful dialogue, it goes WIFI_READY, STA_START, STA_CONNECTED, STA_GOT_IP.
Could it simply be that because I’m not properly disconnecting each time I re-boot, the next STA_START results in the AP toggling to disconnect?
Is there some sort of routine I could include in startup that ensure a proper disconnection, before re-connection?
Or simply a repeated attempt on receipt of the AUTH_FAIL response?
I realise I haven’t read the documentation well enough (RTFM!), so will do some more bedtime reading. The clue is to break down my use of the Blynk.begin into Blynk.connect, etc, so can trap failures. Also use the server connect and disconnect functions so that the internet activity only occurs when I’m running the app. This should sort me, once I fully understand it.
Okay, have just returned to this after completing the original project using an ESP2866. This worked perfectly and would connect faultlessly with my WiFi network on every reset - so not a router issue. I loaded the very basic ESP32_WiFi sketch from the Blynk library and the problem is back.
Here’s the failed dialogue:
12:16:45.425 -> ets Jun 8 2016 00:22:57
12:16:45.425 ->
12:16:45.425 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
12:16:45.472 -> configsip: 0, SPIWP:0xee
12:16:45.472 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
12:16:45.472 -> mode:DIO, clock div:1
12:16:45.472 -> load:0x3fff0018,len:4
12:16:45.472 -> load:0x3fff001c,len:1216
12:16:45.472 -> ho 0 tail 12 room 4
12:16:45.472 -> load:0x40078000,len:9720
12:16:45.472 -> ho 0 tail 12 room 4
12:16:45.472 -> load:0x40080400,len:6352
12:16:45.472 -> entry 0x400806b8
12:16:45.706 -> [32] Connecting to DAVETT
It stops at this point , seeming to get no response from the router.
Pressing reset then produces the correct connection:
There is no difference in the pre-fail dialogue. Interestingly, while working with the ESP2866, I noted ‘open’ and ‘close’ commands embedded in the heartbeat data when the app is opened and closed on the 'phone. No such commands with the ESP32.
The ESP32 is a Chinese clone ‘ESP32-DevKitC 32U’ of the usual Espressif thing. It has the Wroom and an antenna socket - I have fitted the correct Molex antenna.