1

Is there a way to cause a periodic reset of an Arduino Nano under program control, short of some kind of external relay that signals the RST pin?

I'd like to do a full reset triggered by a digital write.

When the power is applied to the Nano it automatically pulls all the digital output pins to LOW so it appears that simply connecting a wire from a digital output to the RST pin would cause the system to continually reset and never run the program. This would apply equally to using the DS3231 RTC chip's alarm function. It would require the program to run in order to use it.

I suppose a relay would do the trick. Or maybe even just an inverter chip like the 7404 between a digital output and the RST pin. I am trying to fit this all in a small box so more hardware gets to be a problem.

So the question: Is there any way to do this without external hardware?

  • 1
    Use the watchdog. – Majenko Nov 8 '16 at 17:03
  • You didn't elaborate enough for me to know what you mean, @Majenko. Besides, I want to trigger it programatically, not just periodically, if possible. But maybe you are on to something - yet you didn't explain how to do it. If you have an answer, please post it as one. – SDsolar Nov 8 '16 at 18:48
  • 1
    You simply turn the watchdog on with a short period and don't bother kicking it. It'll reset. Be sure that the period is longer than the bootloader timeout so you can disable the watchdog at startup - otherwise only a poweroff will disable it. – Majenko Nov 8 '16 at 18:49
  • 1
  • @Majenko, thank you for this info. I upvoted all your comments. (If you had made this an answer I would have accepted and upvoted it that way.) If you read my comment on the other answer you will see why I needed this and why I thought program control was best. But upon further reflection I see that the watchdog is by far the simplest answer. This is why I like this forum. Thanks again. – SDsolar Nov 23 '16 at 19:50
1

Why do you want to reset you board? The reason affects the answer.

Do you want to reset the board because your program crashes after n hours? If so its probably better to fix the memory leak that you have in the code.

Is it because some global variables need to resetting every now and again? If so could you place them in a class and store a pointer to them as your only global. When you want to 'reset' the board delete the instance of the class and recreate it.

What happens if the software crashes? Have you got it configured to restart on a crash? If so could you just crash the code deliberately?

Because you have size constraints then it may be worth a bit of lateral thinking to see what the code can do for you.

  • The reason is that the communications over the wire to the LCD sometimes suffers bit errors which scrambles the screen. The only fix I have found is to power it off by unplugging the cable, then plugging it back in. I still haven't looked into the watchdog timer, but I do know that I can detect bit errors by reading back what I just wrote, periodically. If they don't match then I want to force a reset. – SDsolar Nov 23 '16 at 19:45
  • Upvote because your answer made me have to think harder..... I believe I will go with the watchdog instead of adding a bunch of new code. Thanks! – SDsolar Nov 23 '16 at 19:46
  • @Archway - Do you need to reset the whole system, would power cycling just the LCD fix it? – Code Gorilla Nov 24 '16 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.