I used Blynk app and Arduino panel to control my garage door. It works magically.
However, sometimes my app disconnect with a “Exclamation mark” on app interface.
It happens like every week. Don’t really have a regular interval.
I need to manually cut off my panel’s power, reset the panel, and reset app. So it can connect again.
I doubt if it is due to my house’s unstable WiFi. Also, Blynk set its Default timeout in 30 seconds.
Leaned from the manual
Blynk.connect()
This functions will continue trying to connect to Blynk server. Returns true when connected, false if timeout have been reached. Default timeout is 30 seconds.
That is, my app will crash if my WiFi is out for more than 30 sec.
I’m a newbie for coding, so I would like to have your help to
Extend Default timeout to 5 mins?
Create a loop to reconnect after timeout?
Not sure which way is easier/more efficient, cuz both are difficult for me…
Version -
Android 9 (2.20.709.2)
Blynk 2.27.21
NodeMCU Arduino 1.8.13
Simply resetting or power-cycling your NodeMCU should be sufficient. I’m not sure what you mean by “reset the app”.
I think you’re misunderstanding the documentation, and anyway, you aren’t using Blynk.connect in your sketch.
Blynk.begin (which is what you are using) is a blocking process. This means that the code execution will not progress beyond that point unless the Blynk.begin command can successfully connect to both the WiFi and Blynk server.
Blynk.connect is an alternative solution which is non-blocking. It requires you to manually manage the WiFi connection in your code, then you call Blynk.config to establish the server/auth code settings and Blynk.connect to set-up that connection. It will try to connect for the default timeout period (30 seconds) then continue with the code execution if this is unsuccessful. Switching to Blynk.Coinfig/Connect and extending the timeout isn’t the solution to your problem.
If you search the forum for re-connection routines you’ll see how to automatically manage reconnections after a connection loss.
You may also want to add some code that sends the current WiFi signal strength (RSSI) to your app, which will allow you to understand how good the WiFi signal strength is. Obviously this data will only be updated when the NodeMCU is connected to the app, but it will provide valuable information about possible causes of the issue you are facing.
Simply resetting or power-cycling your NodeMCU should be sufficient. I’m not sure what you mean by “reset the app”.
I did what I could do to troubleshooting.
(1) Reboot button on the relay.
(2) Power on/off the relay.
(3) Plug/Unplug micro-usb on the relay.
(4) Re-edited “D0” 1/0 on Blynk app.
For now, my fifth step. Very thanks for your clarification.
I’m not sure what you mean by “is 30s and it’s not enough for me”.
Each time Blynk encounters a Blynk.run command it will attempt to do a Blynk.connect(), so in reality the Blynk.connect() command is redundant in most (if not all) situations. I still advocate the use of Blynk.connect(), as it makes the code more readable and understandable.
I suggest that you start a new “need help with my project” topic and provide all of the information that is requested when you create the topic, and explain exactly what issues you are facing.