How to reset arduino when program is stuck

Hi, I am running a mkrnb1500 and occasionally it looses cellular signal. When that happens it has trouble reconnecting so I have a timeout function in the void loop that calls NVIC_systemReset(). My problem is that sometimes when starting the board it will hang up in void setup trying to get connected to a network. Is there a way to call for a board reset when that happens even though it never makes it to void loop? Thanks for any help.

If you know it’s stuck, then you could identify the issue and unstuck it.
Otherwise using the WDT is the most common unuversal approach to unlocking hung code.

With cellular modems, reinitializing is a multi-step process, so you could power-cycle the modem, then reinitialize it as needed.

Well it randomly gets stuck on this line of code in setup.

Blynk.begin(auth, nbAccess, gprs, client, pin, domain, port);

But just how do I figure out what here is causing the problem??
I don't understand how I would power cycle the modem either.
Coming from learning on the Uno I haven't been able to figure out the watchdog timer on the samd21 but I will keep trying.

Is it getting STUCK (locked up), or failing to run past this?
Without looking ar the code, my first guess would be if the WiFi actually connected"..

Some Serial.print() will help you work through this.

So when the problem happens the program never progresses past this line of code.

Blynk.begin(auth, nbAccess, gprs, client, pin, domain, port);

Maybe I wrongly assumed it gets stuck??
I should have stated that this is connecting to an LTE network not wifi. And I have good signal at this location.
So I see that I'm getting this from the serial monitor when the program gets stuck.



cannot init

and then it just does nothing.
I think I need to figure out what all is happening in the .begin() function but I'm not sure just how to find it.

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