Recommended architecture for iot application

Hi.

Is there any architecture recommendation for an iot cloud application - especially that the cloud connector and my app do not block each other?

Reason: when going with the standard implementation (running ArduinoCloud.Update in the main loop together with the program logic)
I found out, that ArduinoCloud.Update() can take 60 seconds, if the connection is not established yet). Yes really, the underlying library seems to do some busy waiting. Even a blink LED application does not work. After connection is established, the runtime seems to drop.

With this, it is impossible to add any other tasks into the main loop, especially if they are time dependant.

So how do you recommend to implement the iot cloud? Move the whole sketch to interrupt based so it is not blocked by the iot cloud?
Or: what is the longest runtime, the ArduinoCloud.Update() function can take?

Greetings!

You can try using real multitasking with a library like Taskfun (for Avr and Samd21). You can run independent tasks and let the library handle running them in non blocking fashion

Interesting, thanks for the hint. And all the IoT libraries will work with taskfun? (Since eg. a wait operation will now take longer than expected)

I run into this all the time with control applications. My basic logic is start the task. If true process it, if not true skip and try the next time. That keeps it from locking up.

If they don’t and this is something that can be fixed in Taskfun then we can look into it

This is strange, I have made a device based on ESP32, with ArduinoCloud.Update() in the main loop along with two HW serials handling, for sensors and Nextion display, some calculations and 20mS of ADC readings every 2 seconds. I`ve never had a problem like this even if wi-fi rooter is turned off and the device is constantly trying to reconnect.

Yes, I use LoRaWan and I suspect the MKRWAN library. There are even some comments like "this can be improved"
But this is more a general question. IoT uses several libs for connecting handling. How much delay are these libraries allowed to have?

I'll ask the same question in the MKRWAN bugtracker.

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