I'm dealing with two different timing issues for a hardware application: execution of critical code in loop() versus monitoring of device output.
In this application, it's acceptable to read device output every 15 / 60 / 300 seconds. But it's very necessary to keep loop() running at maximum speed without any hang-ups to data uploads.
Our current (and much older) application uses a Raspberry Pi to interface with two Arduino Nanos in the era before Arduino's IOT Cloud. The Pi is able to build data queues to our own data server in the 15 / 60 / 300 second intervals, while the Nano's run several iterations in loop() per second.
The goal is eliminate the Pi board and move to something like the Giga R1 or so forth and moving off our own data server to the IOT Cloud (for many reasons which we like).
The problem we could see is making calls to ArduinoCloud.update() within loop() as these default scripts have, and something happens with our network that causes hang-ups in data transfer, thus causing a back-up in critical code.
Is there any timeout feature in ArduinoCloud.update() which aborts the data transfer, flushes the data buffers and continues with the code in loop()?
Hi @hermosaranchllc. Unfortunately I don't have an answer to your actual question about a timeout mechanism. Hopefully one of the Arduino Cloud team members or forum helpers more familiar with the internals of the relevant libraries will be able to answer that.
I can tell you that the "ArduinoIoTCloud" library enables a "watchdog timer". This will automatically reset the GIGA R1 WiFi board if the program hangs:
If I use the Giga R1 Wifi board, I can program the M7 core to run the critical code to the external sensors and hardware in loop(). The M4 core can then be used to ping the M7 core through RPC to gather data as needed, and then use IOT Cloud data commands in M4 to report to the Arduino Cloud. This seems like it will handle the timing required for the job.
I was also thinking of making a timeout() function based on how ArduinoCloud.update() performs to the internal clockspeed. Might use this as a back-up.