Module stops working/restarts within 24 hours

Hi everyone,
I am working with the module, and I am doing some tests with the standalone module using RUI3. I am using the “SPI.h” and “SD.h” libraries. My code basically does a write test on a SD CARD by printing a timeStamp every second in a TXT file. The problem arises after hours the module stops writing/restarts and does not complete the 24 hour cycle. Attached is some code. Does anyone know what could be happening.

#include <SD.h>
#include <SPI.h>
int segundos=0;
int minutos=0;
int horas=0;
int pin=PA13;
//unsigned long cont;

void setup() {
  pinMode(pin,OUTPUT);
  // Open serial communications and wait for port to open:
  Serial.begin(9600);//, RAK_AT_MODE);
  // initialize serial communication at 115200 bits per second, and use the custom mode
  //Serial1.begin(115200, RAK_CUSTOM_MODE);
  delay(2000);
  while (!Serial) {
   ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  // see if the card is present and can be initialized:
  if (!SD.begin(PA4)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    while (1);
  }
  Serial.println("card initialized.");
}

void loop() {
  //digitalWrite(PA13,HIGH);
  segundos=segundos+1;
   if (segundos>=60){
     segundos=segundos-60;
     minutos=minutos+1;
     if(minutos>=60){
       minutos=minutos-60;
       horas=horas+1;
     } 
   }

  digitalWrite(pin,HIGH);
  delay(500);
  digitalWrite(pin,LOW);
  delay(500);

  File dataFile = SD.open("datarak.txt", FILE_WRITE);
  // if the file is available, write to it:
  if (dataFile) {
    dataFile.print(horas);
    dataFile.print(":");
    if(minutos<10){
    dataFile.print("0");
    }
    dataFile.print(minutos);
    dataFile.print(":");
    if(segundos<10){
    dataFile.print("0");
    }
    dataFile.println(segundos);
    //dataFile.println();
    dataFile.close();
    // print to the serial port too:
  }// if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
  Serial.print(horas);
  Serial.print(":");
  if(minutos<10){
    Serial.print("0");
  }
  Serial.print(minutos);
  Serial.print(":");
  if(segundos<10){
    Serial.print("0");
  }
  Serial.println(segundos);
}

Welcome to the forum @jjuno

What library is SD.h from?

Hello,

The library used is the one that comes in arduino by default to read and write SD and microSD cards.

Dear @beegee ,
Any cause of this problem? Since I have done several tests if the result is always repeated.
Best regards

I have no idea and I do not have a SD card module to test.