RTC module

Hello everybody,
I would like to operate my lamp every three hours for two minutes. I can’t do it can you help me because i try things but nothing works.

#include <DS3231.h>

int Relay = 4;

DS3231  rtc(SDA, SCL);
Time t;

const int OnHour = 15; //relay ON
const int OnMin = 48;
const int OffHour = 15; //relay OFF
const int OffMin = 50;

void setup() {
  Serial.begin(115200);
  rtc.begin();
  pinMode(Relay, OUTPUT);
  digitalWrite(Relay, LOW);
}

void loop() {
  t = rtc.getTime();
  Serial.print(t.hour);
  Serial.print(" hour(s), ");
  Serial.print(t.min);
  Serial.print(" minute(s)");
  Serial.println(" ");
  delay (1000);
  
  if(t.hour == OnHour && t.min == OnMin){
    digitalWrite(Relay,HIGH);
    Serial.println("LIGHT ON");
    }
    
    else if(t.hour == OffHour && t.min == OffMin){
      digitalWrite(Relay,LOW);
      Serial.println("LIGHT OFF");
    }
}

What serial output do you get when the lamp is supposed to come on?

Sorry i don't understand i'm a beginner... :frowning:

You have some serial.prints in your code. If you use the serial monitor in the IDE, what do they say?

I can’t see anymore I have a bug

Please provide a link to the RTC library.

Which Arduino? Which relay and how is it connected to the Arduino? How is the lamp connected to the relay?