I’ve done some more testing with the example sketch I posted above in post #31, this time leaving the wireless access point switched-on and pulling the LAN cable out of the back. This keeps the WiFi connection between the device and the WAP, but kills the internet connection.
It still works as expected.
I’ve added comments , which look like this: <<< my comment in here >>>
to explain what is happening at each stage…
09:01:10.945 -> ___ __ __
09:01:10.945 -> / _ )/ /_ _____ / /__
09:01:10.945 -> / _ / / // / _ \/ '_/
09:01:10.945 -> /____/_/\_, /_//_/_/\_\
09:01:10.945 -> /___/ v1.1.0 on ESP8266
09:01:10.945 ->
09:01:10.945 -> #StandWithUkraine https://bit.ly/swua
09:01:10.945 ->
09:01:10.945 ->
09:01:10.945 -> Connecting to Wi-Fi...
09:01:10.945 -> Wi-Fi connection - attempt # 1 of 15
09:01:11.422 -> Wi-Fi connection - attempt # 2 of 15
09:01:11.941 -> Wi-Fi connection - attempt # 3 of 15
09:01:12.419 -> Wi-Fi connection - attempt # 4 of 15
09:01:12.931 -> Wi-Fi connection - attempt # 5 of 15
09:01:13.442 -> Wi-Fi connection - attempt # 6 of 15
09:01:14.640 -> Wi-Fi connection - attempt # 7 of 15
09:01:15.158 -> Successfully connected to Wi-Fi
09:01:15.158 -> Attempting to connect to Blynk...
09:01:15.158 -> [4312] Connecting to blynk.cloud:80
09:01:15.193 -> [4350] Ready (ping: 16ms).
09:01:15.262 -> Blynk.connect() attempt ended
09:01:15.262 -> Blynk connection attempt succeeded - connected
09:01:45.144 -> Checking connections.. WiFi Okay, Blynk Okay
09:02:15.139 -> Checking connections.. WiFi Okay, Blynk Okay
09:02:45.172 -> Checking connections.. WiFi Okay, Blynk Okay
<<< LAN plug pulled at around 09:03:00 Blynk.connected() still returns true, because no heartbeat timeout yet... >>>
09:03:15.162 -> Checking connections.. WiFi Okay, Blynk Okay
09:03:45.173 -> Checking connections.. WiFi Okay, Blynk Okay
<<< Heartbeat interval for this device is 45 seconds, heartbeat times-out around 48 seconds after the internet connection is cut... >>>
09:03:48.289 -> [157430] Heartbeat timeout
<< Now reports that WiFi is connected but Blynk is not - this is correct... >>>
09:04:15.154 -> Checking connections.. WiFi Okay, Blynk not connected
<<< Because Blynk is not connected the sketch attempts to reconnect to Blynk. This fails, because no internet connection. Connection attempt times-out after 6.220 seconds... >>>
09:04:15.154 -> Attempting to connect to Blynk...
09:04:15.154 -> [184311] Connecting to blynk.cloud:80
09:04:21.383 -> Blynk.connect() attempt ended
09:04:21.383 -> Blynk connection attempt failed - not connected
<<< Attempts to connect to Blynk again, this time the timeout is 6.235 seconds... >>>
09:04:45.170 -> Checking connections.. WiFi Okay, Blynk not connected
09:04:45.170 -> Attempting to connect to Blynk...
09:04:45.170 -> [214311] Connecting to blynk.cloud:80
09:04:51.405 -> Blynk.connect() attempt ended
09:04:51.405 -> Blynk connection attempt failed - not connected
<<< Attempts to connect to Blynk again, this time the timeout is 6.233 seconds... >>>
09:05:15.165 -> Checking connections.. WiFi Okay, Blynk not connected
09:05:15.165 -> Attempting to connect to Blynk...
09:05:15.165 -> [244311] Connecting to blynk.cloud:80
09:05:21.398 -> Blynk.connect() attempt ended
09:05:21.398 -> Blynk connection attempt failed - not connected
The timeout periods are slightly longer than the 5 seconds specified in the Blynk.connect(timeout)
command, but I think that’s to be expected.
Pete.