how to set watch dog timer to 3600 seconds/1 hour?

how do you set watch dog timer to 3600 seconds/1 hour? or is that even possible? if not, are there any alternative steps to set a timer to reset in 1 hour? please reply. thanks!

/*Arduino-Based Rain Gauge and Flood Early Warning System Code*/

// List of libraries (provide extra functionality for use in sketches) used in code:
#include <LiquidCrystal.h> 
#include "Wire.h"
#include <RTClib.h>
#include <avr/wdt.h>

RTC_DS1307 RTC;

// States the numbers of the Arduino pins that are connected to the rs, enable, d4, d5, d6, d7 pins
// RS pin - the register select pin enables a user to select the instruction mode or the character mode of a LCD
// Enable pin - it enables the writing to the registers
// d4, d5, d6, d7 - are optional but if omitted, the LCD will be controlled using only the four data lines
LiquidCrystal lcd(12,11,5,4,3,2);
// Integers (primary data-type for number storage)
int Buzzer = 8;
int RainPin = 7;
// Double precision floating point number (the changing variable in the code)
double rainfall = 0.000;
// A bool (holds one of two values, true or false)
bool bucketPositionA = false;
// constant float (used for creating numeric or string constants)
const float LowAmt=0.031; 
const float HiAmt=0.031; 
// Long variables (are extended size variables for number storage)
long minorflood = 2;
long majorflood = 8;

// A byte (stores an 8-bit unsigned number, from 0 to 255)
 byte lastSec=0;
 
// The setup() function (is called when a sketch starts. it initializes variables, pin modes, start using libraries, etc.)
void setup() 
{
  Wire.begin();
  RTC.begin();
  wdt_disable();
  wdt_enable(WDTO_1H);

  pinMode(RainPin, INPUT);

  pinMode(Buzzer, OUTPUT);
  
  lcd.begin(20,4);
  lcd.clear();
  lcd.setCursor(0,2);
  lcd.print("Total Rainfall:");

  if (digitalRead(RainPin)==HIGH)
    {
        bucketPositionA=true;
    }
   else 
   {
        bucketPositionA=false;
    }
}
void loop()
{
  delay(500); // every half-second
  if((bucketPositionA==false)&&(digitalRead(RainPin)==HIGH))
  {
    bucketPositionA=true;
    rainfall+=LowAmt;
  }
  if((bucketPositionA==true)&&(digitalRead(RainPin)==LOW))
  {
    bucketPositionA=false;
    rainfall+=HiAmt;
  }
  lcd.setCursor(0,3);
  lcd.print(rainfall);
  lcd.print(" inches");
  if(minorflood < rainfall)
  {
    digitalWrite(Buzzer, HIGH);
    tone(Buzzer, 3000, 500);
    delay(200);
    digitalWrite(Buzzer, LOW);
    noTone(Buzzer);
    delay(200);
    lcd.begin(20,4);
    lcd.clear();
    lcd.setCursor(0,2);
    lcd.print("FLOOD WARNING");
  }
  if(majorflood < rainfall)
  {
    digitalWrite(Buzzer, HIGH);
    tone(Buzzer, 10000, 500);
    delay(200);
    digitalWrite(Buzzer, LOW);
    noTone(Buzzer);
    delay(200);
    lcd.begin(20,4);
    lcd.clear();
    lcd.setCursor(0,2);
    lcd.print("FORCED EVACUATION");
  }
  else
  {
    digitalWrite(Buzzer, LOW);
  } 
  DateTime now = RTC.now();
  if(lastSec!=now.second())
  {
    lastSec=now.second();
    lcd.setCursor(0,0);
    lcd.print(now.year(), DEC);
    lcd.print('/');
    lcd.print(now.month(), DEC);
    lcd.print('/');
    lcd.print(now.day(), DEC);
    lcd.setCursor(0,1);
    lcd.print(now.hour(), DEC);
    lcd.print(':');
    lcd.print(now.minute(), DEC);
    lcd.print(':');
    lcd.print(now.second(), DEC);
  }
}

Google:

Arduino narcoleptic

larryd: Google:

Arduino narcoleptic

can you explain to me further? im a beginner and i have no idea how it works so i would really appreciate it if you would explain to me how to do it. thanks!

Get library here: https://github.com/rcook/narcoleptic

The sleep time can range from 16 to 8,000 milliseconds (eight seconds). To sleep for longer periods, you can repeat the delay intervals until you get the period you want:

void longDelay(unsigned long milliseconds) 
{
   while(milliseconds > 0) 
   { 
       if(milliseconds > 8000) 
       { 
         milliseconds -= 8000; 
         Narcoleptic.delay(8000); 
       } 
       else 
       { 
        Narcoleptic.delay(milliseconds); 
        break; 
       }
   }
}

larryd: Get library here: https://github.com/rcook/narcoleptic

The sleep time can range from 16 to 8,000 milliseconds (eight seconds). To sleep for longer periods, you can repeat the delay intervals until you get the period you want:

void longDelay(unsigned long milliseconds) 
{
   while(milliseconds > 0) 
   { 
       if(milliseconds > 8000) 
       { 
         milliseconds -= 8000; 
         Narcoleptic.delay(8000); 
       } 
       else 
       { 
        Narcoleptic.delay(milliseconds); 
        break; 
       }
   }
}

so i have to do it 450 times? :O is there any other way to do it?

What’s wrong with calling

longDelay(3600000); // 1 hour 60 * 60 * 1000

larryd: What’s wrong with calling

longDelay(3600000); // 1 hour 60 * 60 * 1000

can you please edit the code in for me? i really have no idea what to do. sorry

Did you install the narcoleptic library?

larryd: Did you install the narcoleptic library?

yeah

Did you try the example that comes with the library? MerlinTheCat.pde

Why do you want to put the Arduino to sleep?

What Arduino do you have?

larryd: Did you try the example that comes with the library? MerlinTheCat.pde

Why do you want to put the Arduino to sleep?

What Arduino do you have?

yeah. i just want it to reset its data back to zero within an hour. an arduino uno.

const unsigned long resetInterval = 3600L * 1000; //milliseconds, times 3600 seconds in an hour
int data;

void setup() {
  Serial.begin(9600);
  Serial.print("Arduino starting with data: ");
  Serial.println(data);
}

void loop() {
  static unsigned long lastResetTime = 0;
  if(millis() - lastResetTime > resetInterval) {
    data = 0; //reset data to zero
    lastResetTime = millis();
  }

  Serial.print("New data: ");
  Serial.println(data);

  data++; //need to make some change to data to show that it's moving along

  delay(2000); //delay so we're not printing too much to the screen
}

MorganS: ``` const unsigned long resetInterval = 3600L * 1000; //milliseconds, times 3600 seconds in an hour int data;

void setup() {   Serial.begin(9600);   Serial.print("Arduino starting with data: ");   Serial.println(data); }

void loop() {   static unsigned long lastResetTime = 0;   if(millis() - lastResetTime > resetInterval) {     data = 0; //reset data to zero     lastResetTime = millis();   }

  Serial.print("New data: ");   Serial.println(data);

  data++; //need to make some change to data to show that it's moving along

  delay(2000); //delay so we're not printing too much to the screen }

omg thank you!

i just want it to reset its data back to zero within an hour.

The WDT is used to put the Arduino to sleep, not time events. correction: as used with narcoleptic library.

Since you have an RTC already, use it to reset things after an hour.

Edit Or as shown by MorganS use the BWD millis() timing to reset things after an hour.

larryd: The WDT is used to put the Arduino to sleep, not time events.

I had the impression that watchdog is to reset the board when the loop stops looping for some unexpected reason. I use it for that.

It depends on the application.

The WDT can be used to reset. And As in the Narcoliptic library you can use it to sleep the controller.

but OP did not ask about sleep