Using reset pin and millis() how i reset Mega board every 1 hour interval

I have to reset my Arduino mega board every 1 hour. Can anyone help?

why?

Juraj:
why?

I bet everyone wanted to ask that but you beat everyone to it :wink:

Juraj:
why?

When I checking continuously sensor data device give wrong value and if restart it starts working fine.
So, I want to restart the device.

bytebd:
When I checking continuously sensor data device give wrong value and if restart it starts working fine.
So, I want to restart the device.

solve the problem

Juraj:
solve the problem

Or to put it another way :wink: if you want help solving the problem post the code and schematic, and link to the sensor datasheet.

Resetting the device is so I.T. Crowd...

have you tried.GIF

have you tried.GIF

Juraj:
solve the problem

No, Now I am now doing this by manually, so I want to do it by automatically

and you don't know how to code the timing or the reset?

bytebd:
Now I am now doing this by manually, so I want to do it by automatically

Yeah we get that, but you still haven't said why you don't fix the underlying problem in the first place.

:slight_smile: Maybe you could rig a small servo to press the reset button?

bytebd:
No, Now I am now doing this by manually, so I want to do it by automatically

With properly written code there should be no need to reset the Arduino.

If you really need a back-up in case of a failure of the program then that is what the Watchdog Timer is for.

...R

I am using something like this with Watchdog

#include <avr/wdt.h>

void setup() {
  wdt_disable();
  Serial.begin(19200);
  Serial.println("Setup! Check the LED.");
  pinMode(13, OUTPUT);
  delay(5000);
  wdt_enable(WDTO_2S);
}

void loop() {
  Serial.println("Main Loop!");
  for (int cnt = 0; cnt < 5; cnt++) {
    Serial.println(cnt);
    delay(500);
    digitalWrite(13, LOW);
    delay(500);
    digitalWrite(13, HIGH);
    wdt_reset();
  }

  Serial.println("Reset by Watch Dog?");
  delay(3000);

  // Code should never get to here
  Serial.println("Reset failed");
}

bytebd:
I am using something like this with Watchdog

Did it solve the problem?

Micros() rollover, 71.5827882667 minutes? Need to see code.

outsider:
Micros() rollover, 71.5827882667 minutes? Need to see code.

I was thinking millis() and wondered how it could be the culprit; but I always forget about micros()- you're probably right.

bytebd:
I am using something like this with Watchdog

The difference between your code and "something like it" could be fatal. Post the actual program that is causing the problem.

...R