Automatically restart Arduino if it hangs?

Hi, for some reason my arduino sometimes just hangs and doesn't loop anymore. I'm suspecting it might be the way i handle the get data from the ethernet shield.

Before i start debugging, i was thinking about sacrificing one I/O pin to automatically reset the arduino, if it doesn't loop for some time.

My basic idea was to hook up a capacitor to the reset pin and trickle charge it constantly. Every loop, i would then drain it via one of the pins.

If it doesn't loop the charge would build up and reset the arduino.

Has anyone ever done this or any ideas or tips on how to build something like this?

Bye, NsN

Haven't seen any one do that yet. It's probably because it's simpler to use the internal AVR watch dog timer that will do the same thing. The Arduino core software doesn't directly support the it, but if you search this forum on WDT you should find some examples.


Thanks i didn’t even know about the wdt.

Just to be clear, i’ve read in a few comments, that you should adapt the bootloader, otherwise you might get stuck in a reboot cycle. Is this still an issue, or can i safely use the wdt without changing the bootloader.?

If you wanted to do something external (which will reset even if the WDT fails?) - look into a "missing pulse detector" circuit; it should be possible to use this, with the external pin being pulse, so that if the pulse stops, the detector fires and triggers a reset.