Arduino R4 Wifi board loses connection with cloud randomly

I have looked elsewhere in the forum with no luck. I was able to load up a garden automation program to my board and it functions perfectly from the board at all times but loses connection to the cloud randomly. Sometimes the "thing" will function for days, sometimes for only hours. It is very aggravating and defeats the purpose of setting up the devices and IOT in the first place (remote monitoring and control of a grow room) I have tried substituting millis for any delays but no matter what changes to the software I make, When I lose connection the board does not reconnect until I unplug or reset the board manually. I bought the Arduino R4 because I was having the same problem with the Arduino MKR 1010 and with a couple of the Adafruit Feather series boards. The program is a very simple monitoring and slider control of soil moisture level, lights heat and humidity using relays and sensors. I bet I'm not the only one with this issue. Has this been addressed by Arduino or can someone direct me to a permanent fix.

Everyone has that issue. Internet connections always drop out at some point, so your code needs to know how to detect that situation, restart the connection and if necessary, recover to where it left off.

1 Like

Do you have any links to reliable reconnection snippets? Lots of suggested ones but apparently spotty success. Thanks for the reply, glad I'm not alone but would be more glad if Arduino bigwigs would address. I wouldnt want my 5hp shaper running outside my control. So their outreach to the business community is moot without this solved.

1 Like

Nothing is 100% reliable. If your external network connection or router goes down there is not a thing that any amount of Arduino code can do about it.

In that case your code has to turn off the 5hp shaper, and since that process can fail, the shaper itself should automatically shut down if it doesn't receive commands at (say) regular intervals. That calls for the use of a watchdog timer, at least one of which is built in to every modern microprocessor. Standalone watchdog modules are also available.

Process security and safety requires multiple layers of checking and control. So, if you are concerned about overall failure, the first step is to analyze all the weak points of your setup, and plan to handle failures at every one of those.

1 Like

I completely agree that remote devices need to be fail-safe with respect to Internet & cloud connectivity. But bux12 was asking about automatically reconnecting.

bux12's problem is the same as mine: The suggested or auto-generated code for cloud connectivity does not automatically reconnect after a connection loss. And no instructions for how to fix this. This means having a remote Arduino device is simply unworkable, never mind at a customer site.

Adding to the difficulty, the Opta (and Portenta H7) use the mbed ecosystem and a different Ethernet library with different API behavior. I noticed that the Arduino cloud connection software is using the beta ArduinoMQTTClient library, version 0.1.8, as well as ArduinoSecureElement version 0.1.2. Not exactly confidence-building.

1 Like

I've been suffering this issue for months. There is a terrible reboot solution that works most of the time. Please add to this thread to keep it up the list.
R4 device fails to stay connected to Arduino Cloud - Software / IoT Cloud - Arduino Forum

After more testing I found that my Opta does indeed reconnect on its own when the Ethernet cable is temporarily disconnected, the LAN is shut off, or the server is unreachable. This reconnection is automatically handled by the Arduino cloud software. The problem occurs when the server connection is lost, for whatever reason, for longer than the cloud watchdog timeout. The watchdog's soft reset was causing the Opta to get stuck, or at least run extremely slowly, as something is blocking the code everywhere. A hard reset with a power cycle or reset button gets everything running and connected again as normal. I'm addressing that particular problem in another thread: https://forum.arduino.cc/t/5-uptime-connecting-to-ardiuno-cloud/1279922

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.