IMPORTANT: how to reset data without resetting time/rtc module?

i want to reset the data collected on my lcd screen but i dont want it to affect the time it already has. i want the time to continue despite resetting the arduino board. any advice on how to do it??? pls respond to this message. thank you!

try3.ino (3.08 KB)

i want to reset the data collected on my lcd screen but i dont want it to affect the time it already has. i want the time to continue despite resetting the arduino board. any advice on how to do it??? pls respond to this message. thank you!

/*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();
  RTC.adjust(DateTime(__DATE__,__TIME__));

  wdt_disable();
  wdt_enable(WDTO_2S);

  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.begin();
    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);
  }
}

comment out => RTC.adjust(DateTime(DATE,TIME));

When clock runs OK it is not needed to set it

Take out line 38. That sets the time to the time that the sketch was compiled.

And your sketch is small enough to fit in a post; next time please post in your post instead of attaching it. Post it between
** **[code]** **
and
** **[/code]** **
so it looks like below (your code)

/*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();
  RTC.adjust(DateTime(__DATE__,__TIME__));

  wdt_disable();
  wdt_enable(WDTO_2S);

  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.begin();
    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);
  }
}

knut_ny:
comment out => RTC.adjust(DateTime(DATE,TIME));

When clock runs OK it is not needed to set it

how about when you set the watch dog timer to 3600 seconds? is that okay or even possible?

@rhonarae, please do not cross-post. Threads merged.

an hour sleep is not possisble. What IS possible, is to replace the clock with a DS 3132.
This one has alarms witch can be used to wake your arduino.