Arduino thing resets on long setup()

Hi,

I am developing on the Arduino MKR IoT + Wifi1010 and the "thing" ARDUINO library.

I have is a somewhat long setup() procedure, with many waits,
so it lasts upt to 30 seconds, when I sum up all delays.

Unfortunately, it never gets to the end of this process; the card resets itself during a delay().
It is not a power issue since the card has no peripherals and in on USB power.

My hypotheses are:
a. wifi library gets some message and fills in some buffer that eventually overflows, triggering the reset;
b. there is a watchdog somewhere by default, but I could not find any doc about it

So the questions are:
a. Should I write my code in a non-blocking stateful fashion? (eg: with a list of tasks, every pass in the loop executes one task, and delays are implemented by checking the RTC.epoch() )
b. Should I call some Wifi-related buffer cleanup code regularly?
c. Should I avoid delays?
d. is it something else?

Thank you very much

Renaud

I think this is it.

Here it is:
https://github.com/arduino-libraries/ArduinoIoTCloud#watchdog

I have no experience with a long setup problem. However if it was a watchdog issue wouldn't the main (loop) code have to "kick the dog" to stay running?

I would put serial prints in the Setup to see where the issue is located. Or even numbers of LED blinks or an ON/OFF sequence.

Also if you think it is the WiFi can it be moved to the end of the setup?

Yes, all Arduino IoT Cloud Thing sketches have this call in loop:

ArduinoCloud.update();

So that takes care of the kicking, but the rest of the sketch code must not prevent that call.

OK i was not aware of that. Perhaps the OP should kick the dog in the setup routine, using a standard call.

Thank you, it did the trick