Sleep Mode

Hola chicos necesito ayuda:
Soy un poco nuevo en arduino estoy trabajando con los SLEEP_MODE para guardar la información de unos sensores cada minuto.
En la línea 50 tengo RTC.setAlarm(ALM1_MATCH_MINUTES ,0,minute(t)+time_interval,0), donde establezco que me mida cada minuto. Todo funciona bien durante una hora, sin embargo cuando cambia de hora se para. Es decir, si la última lectura me la da a las 14:59 la de las 15:00 ya no me la da. ¿Cómo puedo solucionar esto?

/* Programa para conectar varios sensores MLX90614
// Author: Apolo Apolo O. Enrique
// Escuela Técnica Superior de Ingeniería Agronómica de la Universidad de Sevilla
// Departamento de ingeniería aeroespacial y mecánica de fluídos
*/

/*Incluimos las librerías necesarias*/
#include <avr/sleep.h>//Esta librería controla los modos sleep para el arduino
#include <SD.h>
#include <Wire.h>
#include <DS3232RTC.h>
#include <SPI.h> 
#include <Adafruit_MLX90614.h>
/* Declaramos la variables necesarias*/
#define interruptPin 2
const int chipSelect = 10 ;
/*Establecemos el tiempo de cada cuanto queremos que se realice la medida*/ 
const int time_interval= 1;
File logFile;
/*Declaramos los sensores con su respectiva dirección la cual debe ser única para cada sensor*/
Adafruit_MLX90614 sensor_17_plt_ww = Adafruit_MLX90614(0x17);//Exterior 
//Adafruit_MLX90614 sensor_5A_plt_ww = Adafruit_MLX90614(0x5A);//Interior
//Adafruit_MLX90614 sensor_5C_plt_ww = Adafruit_MLX90614(0x5C);
Adafruit_MLX90614 sensor_01_plt_ws = Adafruit_MLX90614(0x01);//Exterior 
Adafruit_MLX90614 sensor_22_plt_ws = Adafruit_MLX90614(0x22);//Interior
Adafruit_MLX90614 sensor_20_plt_ws = Adafruit_MLX90614(0x20); 
Adafruit_MLX90614 sensor_23_wwro_01= Adafruit_MLX90614(0x23);//Exterior 
Adafruit_MLX90614 sensor_13_wwro_01= Adafruit_MLX90614(0x13);//Interior
Adafruit_MLX90614 sensor_5F_wwro_02= Adafruit_MLX90614(0x5F);  
void setup()
{  
 time_t p; //create time object for time and date stamp
  p=RTC.get();
  Serial.begin(9600);
  pinMode(LED_BUILTIN,OUTPUT);
  pinMode(interruptPin,INPUT_PULLUP);
  digitalWrite(LED_BUILTIN,HIGH);
  RTC.setAlarm(ALM1_MATCH_DATE, 0,0 , 0, 1);  
    RTC.alarm(ALARM_1); 
   
    RTC.alarmInterrupt(ALARM_1, false);
    RTC.squareWave(SQWAVE_NONE);
     time_t t; //create a temporary time variable so we can set the time and read the time from the RTC
    t=RTC.get();//Gets the current time of the RTC
    // Serial.print(t);
/*int    tiempo_despierto = second(t)+time_interval;
    if (tiempo_despierto > 59) {
        tiempo_despierto -= 60;
    }*/
    RTC.setAlarm(ALM1_MATCH_MINUTES ,0,minute(t)+time_interval,0);// Setting alarm 1 to go off 5 minutes from now
    // clear the alarm flag
    RTC.alarm(ALARM_1);
    // configure the INT/SQW pin for "interrupt" operation (disable square wave output)
    RTC.squareWave(SQWAVE_NONE);
    // enable interrupt output for Alarm 1
    RTC.alarmInterrupt(ALARM_1, true);
  Wire.begin();
  //Serial.print(F("Iniciando tarjeta SD..."));
  if (!SD.begin(chipSelect))
  {
    //Serial.println(F("Error al iniciar la tarjeta SD..."));
    return;
  }
  //Serial.println(F("Tarjeta SD iniciada correctamente..."));

  //creates the file name we are writing to.
  logFile = SD.open("datalog.txt", FILE_WRITE);
/*Esto se va a aimprimir en el encabezado del archivo txt*/
  if (logFile) {
  logFile.print("Fecha");
  logFile.print(";"); 
  logFile.print("Hora");
  logFile.print(";"); //
   logFile.print("T(°C)_sensor_17_plt_ww");
  logFile.print(";");
   //logFile.print("T(°C)_sensor_5A_plt_ww");
  //logFile.print(";");
  //logFile.print("T(°C)_sensor_5C_plt_ww");
  //logFile.print(";");
  logFile.print("T(°C)_sensor_01_plt_ws");
  logFile.print(";");
  logFile.print("T(°C)_sensor_22_plt_ws");
  logFile.print(";");
  logFile.print("T(°C)_sensor_20_plt_ws");
  logFile.print(";");
  logFile.print("T(°C)_sensor_23_wwro_01");
  logFile.print(";");
  logFile.print("T(°C)_sensor_13_wwro_01");
  logFile.print(";");
   logFile.println("T(°C)_sensor_5F_wwro_02");
   logFile.close();
  }
 
 
 sensor_17_plt_ww.begin(); 
 //sensor_5A_plt_ww.begin(); 
 //sensor_5C_plt_ww.begin();
 sensor_01_plt_ws.begin();
 sensor_22_plt_ws.begin();
 sensor_20_plt_ws.begin();
sensor_23_wwro_01.begin();
 sensor_13_wwro_01.begin(); 
sensor_5F_wwro_02.begin(); 
}
void loop(){

time_t p; //create time object for time and date stamp
  p=RTC.get();//gets the time from RTC
 //creates the file name we are writing to.
  logFile = SD.open("datalog.txt", FILE_WRITE); 

  if (logFile) { 
/*Guardamos la fecha y la hora para cada intervalo de medición*/
 // Serial.print("Writing to "+ file_Name);
   
    logFile.print(String(day(p))+"/"+String(month(p))+"/"+String(year(p))+";"+String(hour(p))+":"+String(minute(p))+":"+String(day(p)));
    // close the file:

  /*Guardamos las medidas de los sensores*/
  //logFile.print("T(°C)_sensor_18_plt = ");
  logFile.print(";"); 
  logFile.print(sensor_17_plt_ww.readObjectTempC());
  logFile.print(";"); 
  //logFile.print("T(°C)_sensor_14_wro = "); 
  //logFile.print(sensor_5A_plt_ww.readObjectTempC()); 
  //logFile.print(";");
  //logFile.print("T(°C)_sensor_07_wri = "); 
  //logFile.print(sensor_5C_plt_ww.readObjectTempC()); 
  //logFile.print(";");
  //logFile.print("T(°C)_sensor_07_wri = "); 
  logFile.print(sensor_01_plt_ws.readObjectTempC()); 
  logFile.print(";");
  //logFile.print("T(°C)_sensor_07_wri = "); 
  logFile.print(sensor_22_plt_ws.readObjectTempC());
  logFile.print(";");
  //logFile.print("T(°C)_sensor_07_wri = "); 
  logFile.print(sensor_20_plt_ws.readObjectTempC());
  logFile.print(";");
  //logFile.print("T(°C)_sensor_07_wri = "); 
  logFile.print(sensor_23_wwro_01.readObjectTempC()); 
  logFile.print(";");
  //logFile.print("T(°C)_sensor_07_wri = "); 
  logFile.print(sensor_13_wwro_01.readObjectTempC()); 
  logFile.print(";");
  //logFile.print("T(°C)_sensor_07_wri = "); 
  logFile.println(sensor_5F_wwro_02.readObjectTempC()); 
 

  //Serial.println();
        
        logFile.close();
  
  } 
  else {
    //Serial.println("Error al abrir el archivo");
  }
  delay(5000);//wait 5 seconds before going to sleep. In real senairio keep this as small as posible
 Going_To_Sleep();
}

void wakeUp(){
  Serial.println("Interrrupt Fired");//Print message to serial monitor
   sleep_disable();//Disable sleep mode
  detachInterrupt(0); //Removes the interrupt from pin 2;
 
}
/*Función para pausar el arduino*/

void Going_To_Sleep(){
    sleep_enable();//Enabling sleep mode
    attachInterrupt(0, wakeUp, LOW);//attaching a interrupt to pin d2
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);//Setting the sleep mode, in our case full sleep
    digitalWrite(LED_BUILTIN,LOW);//turning LED off
    time_t t;// creates temp time variable
    t=RTC.get(); //gets current time from rtc
    sensor_17_plt_ww.readObjectTempC();
//Serial.println("Sleep  Time: "+String(hour(t))+":"+String(minute(t))+":"+String(second(t)));//prints time stamp on serial monitor
    delay(1000); //wait a second to allow the led to be turned off before going to sleep
    sleep_cpu();//activating sleep mode
    //Serial.println("just woke up!");//next line of code executed after the interrupt 
    digitalWrite(LED_BUILTIN,HIGH);//turning LED on
    t=RTC.get();
    //Serial.println("WakeUp Time: "+String(hour(t))+":"+String(minute(t))+":"+String(second(t)));//Prints time stamp 
    //Set New Alarm
   RTC.setAlarm(ALM1_MATCH_MINUTES , 0, minute(t)+time_interval, 0, 0);
  
  // clear the alarm flag
  RTC.alarm(ALARM_1);
}

program_box_01_sleep.ino (6.88 KB)

No veo librería ni instancia del objeto RTC.