How to reset arduino via code?

I want to reset my arduino in every single minute. Can anyone help me with the code???

Can anyone help me with the code???

No. You need to rethink your requirements.

Why do you think you need to reset the Arduino every minute? Do you reset your watch every minute? Do you restart your car every minute?

I’d also be interested in hearing why you’d want to do that. Of course it’s possible, but there shouldn’t be any need.

Here is the code :slight_smile:
I thought about doing this at a known time each night to prevent the rollover of micros();

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("at the beginning");

  delay(1000);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("resetting");
  WDTCSR = (1 << WDE) | (1 << WDCE) ;
  WDTCSR = (1 << WDE);
  for (;;);
}

I thought about doing this at a known time each night to prevent the rollover of micros();

There being absolutely no problem when micros rolls over, why?

I thought about doing this at a known time each night to prevent the rollover of micros();

Considering that micros() rolls over after about 70 minutes then, even if there were a problem with it doing so, which there is not, then resetting the Arduino every 24 hours would not be a solution anyway.

I used this to reset Arduino.

void software_Reset() // Restarts program from beginning but does not reset the peripherals and registers
{
asm volatile ("  jmp 0");  
}

PaulS:
Why do you think you need to reset the Arduino every minute?

OldSteve:
I'd also be interested in hearing why you'd want to do that.

Perhaps OP managed to install Windows on his Arduino?

bunny_1994:
I want to reset my arduino in every single minute. Can anyone help me with the code???

You can use a hardware solution, but as mentioned:

Perhaps OP managed to install Windows on his Arduino?

:slightly_frowning_face:

Sorry I meant millis() working on ping code and have been typing micros() a lot :slight_smile:

millis():
Returns the number of milliseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days.

and this is unrelated to the question bunny_1994 asked anyway

thanks for your concerns…

I may ask the question tonight as to how to software reset this early… that would resolve my long term issues.

There is no problem with millis() rollover if you write your code correctly and hence, no need to reset the Arduino.

Please post the code that is causing you a problem.

Bad millis(). >:(

http://www.gammon.com.au/forum/?id=12127

Like said befor, the roll over is NOT a problem. Just keep the Arduino running. As long as you use millis() in the way of blink without delay aka

if (currentMillis - previousMillis >= interval) {

you never have a problem. Not after a day, not after 50 days, not after a year.

Actually I'm stuck in my heart rate monitoring project. Need help. I'm using Arduino uno,Pulse sensor amped module.

Actually I'm stuck in my heart rate monitoring project.

How is programmatically resetting the Arduino going to get you unstuck?

Need help.

I'm sure.

I'm using Arduino uno,Pulse sensor amped module.

So? What IS the problem?

PaulS:
So? What IS the problem?

Guessing it's this....

JimboZA:
Guessing it's this....

Ah. Complete clueless-ness. I see.

I found this page through google. I had a similar problem. What worked for me:

void(* resetFunc) (void) = 0; //declare reset function @ address 0

resetFunc();  //call reset

If you are wondering why I want to reset my arduino automatically, its because I cant figure out how to restart the ethernet DHCP. Everything works great until I unplug my router. After it powers back on the arduino doesn't seem to be able to re-establish a connection. Calling Ethernet.begin(mac) again didnt do anything. Resetting the arduino works though. Im able to start fresh with calling ethernet and everything is good.

Get an ESP unit ...