Need your input on my time-coutning circuit - Having Issues

Long story short, I wrote a small program that counts 5 minutes by seconds, then sets a pin HIGH, delays for 2.5 secs, then sets the pin LOW, and resets the count and repeats. I tested the code to 15 minutes and it was working just fine, doing exactly what it should every 5 minutes. But it seems when the program has been running for past an hour, it stops functioning. Resetting the board clears up the problem for another hour worth of time, and then it stops functioning. There must be something in my code that is causing this, be it a variable that I need to clear every time but don’t, or maybe I’m using the wrong type of variable. Any suggestions or advice would be much appreciated! This is a time-constrained project and the sooner the issue is resolved the sooner i can relax!

Here is my code:

int DUMP = 52; // Pin connected to big dump relay
int GND = 21; // Pin connected to ground of big dump relay
int SEC;

long prevTIME;


void setup()
{
  pinMode (DUMP, OUTPUT);
  pinMode (GND, OUTPUT);
  
  digitalWrite(GND, LOW);
  
  digitalWrite(DUMP, HIGH);
  delay(2500);
  digitalWrite(DUMP, LOW);
  
  SEC = 0;
  
}


void loop()
{
  
  unsigned long currTIME = millis();
    
  if ((currTIME - prevTIME) >= 1000)
   {
     SEC++;
     prevTIME = currTIME;
   }
    
  if (SEC >= 300)
  {
    digitalWrite(DUMP, HIGH);
    delay(2500);
    digitalWrite(DUMP, LOW);
    SEC = 0;
  }

Thanks in advanced for your help!
-Adam

The symptoms sound like a variable overflow issue, and this caught my eye:

long prevTIME;

Probably, you meant that to be an unsigned long since it's holding the result from millis().

Peter is right that is a bug, however a long could still hold more millis than one hour: 3.600.000 << 2.000.000.000++ so a long could hold ~24 days

Think the problem is in:

int DUMP = 52; // Pin connected to big dump relay
int GND = 21; // Pin connected to ground of big dump relay

How much amps uses “the dump relay?”

Another point is that SEC seconds is an int with a max value of 32767, that is max 9 hours, so it

Why not shorter?

void loop()
{
  unsigned long currTIME = millis();
    
  if ((currTIME - prevTIME) >= 300000UL)   // not the L for LONG casting 
  {
    digitalWrite(DUMP, HIGH);
    delay(2500);
    digitalWrite(DUMP, LOW);
    prevTIME = currTime;
  }
}

Homework: how to remove the delay(2500)? Tip use a flag to indicate state

Thanks guys! I am 95% sure with the changes you suggested the code functions properly for well past an hour. I tested it over a 5 hour period last night at home. Just set the the code to turn the on board LED on every 5 minutes and just casually checked it every 30 minutes or so to see that it was functioning, and it was! Big help much appreciated!

Adam