Arduino watchdog timer becoming unreliable after extended period of time

I am using the <LowPower.h> library to put an arduino pro mini to sleep for 1 hour. It was working perfectly, until approximately after 28 days, it started reseting by itself erratically every 20 to 30 seconds. This problem has happened twice with different devices. Here it’s the code I used to put it to sleep and reset it.

for(int j = 0; j < (sleepTime/8); j++)  {
      LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    }
resetFunc(); 




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

Could it be an overflow issue? How can I test it?

Could it be and overflow issue?
]/quote]
Yes. But impossible to tell from that snippet.

Here is the code. Could it be an issue with the reset function?

#include "Bateria.h"
#include "Sensor.h"
#include "SensorSimples.h"
#include "ATCommands.h"

void setup() {
 
  pinMode(13, OUTPUT);
 
  Serial.begin(57600);
  mySerial.begin(9600);//Configura softserial do Modulo Sigfox
  
  Serial.println("Acordando o Radio Sigfox.");
  Serial.println();
  AcordaSigfox();

  Serial.println("Iniciando comunicação com o Modulo Sigfox.");
  PrintTestSerial();
  delay(500);
  ATPrintID();
  ATPrintPAC();
  Temperatura = ATGetTemp();
  SensorInit();
  Bateria.SetTipo("Pilha3S");
  TempoDeConfig = millis();
  
  Serial.println("Carga da bateria:" + String(Bateria.CargadaBateria( Bateria.getVbat()) )); 
  frame.Bat =  (int)Bateria.CargadaBateria( Bateria.getVbat());
}

void loop() {

  if (millis()> Timer0){
    frame.Leitura = DetectaNivel();
   
    Timer0 = millis() + 5000;

    frame.TempoA = millis();
    frame.Temp = Temperatura;
    ATRC();
    ATsendsigfox(&frame);
    Envios++;
  }
 
  if (Envios > 0){
    Serial.println("ZzZzZzZzZzZzZzZzZ  Dormindo por " + String(sleepTime)+ " segundos ZzZzZzZzZzZzZzZzZ");
    Envios = 0;
    mySerial.println("AT$P=1\r\n");  //  Coloca rádio no modo sleep
    delay(500);
    for(int j = 0; j < (sleepTime/8); j++)  {
      LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    }
//   sleep.pwrDownMode(); //set sleep mode
//   sleep.sleepDelay(sleepTime); //sleep for: sleepTime
    resetFunc(); 
  }
  
}
  if (millis()> Timer0){

This is probably the relevant error. Change the code so that you set Timer0 to millis() on a reset and check for millis() - 5000 > Timer0. That way you always have a correct check even if millis() overflow. Usually such an overflow happens every 49 days but I cannot find the declaration of the variables in your code (it's still not complete!), so you might have declared it incorrectly.

I don't understand why you're calling the resetFunc() after the going to sleep for several seconds. That way you loose your variables but don't reset the CPU. What is this good for?

Hello fernandolopes_38

fernandolopes_38:

..........

resetFunc();

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

Could it be an issue with the reset function?

Be cautious about using this method.
If you are using Arduino IDE, it’s not a secure way to do a clean reset.

Regards,
bidouilleelec