Why is my code not working for DS3231

When using code:

#include <DS3231.h>
#include <FastLED.h>
#define NUM_LEDS 144
#define DATA_PIN 8
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define  BRIGHTNESS 60
#define VOLTS 5
#define MAX_AMPS 500
CRGB leds[NUM_LEDS];

int Relay = 4;
int Relay2 = 7;

DS3231  rtc(SDA, SCL);
Time t;

const int OnHour = 9;
const int OnMin = 1;
const int OffHour = 9;
const int OffMin = 4;

const int OnHourM = 5;
const int OnMinM = 30;
const int OffHourM = 6;
const int OffMinM = 00;

const int OnHour2 = 18;
const int OnMin2 = 50;
const int OffHour2 = 18;
const int OffMin2 = 57;

const int OnHour2M = 5;
const int OnMin2M = 30;
const int OffHour2M = 6;
const int OffMin2M = 00;

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

FastLED.addLeds<CHIPSET,DATA_PIN,COLOR_ORDER>(leds,NUM_LEDS);
FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS,MAX_AMPS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
FastLED.show();

}

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 || t.hour == OnHourM && t.min == OnMinM){
    digitalWrite(Relay,HIGH);
    Serial.println("LIGHT ON");
 for (int i=0; i<NUM_LEDS; i++)  {
      leds[i] = CRGB(255,255,255);
      FastLED.show();
      delay(100);
  }

    }
        else if(t.hour == OffHour && t.min == OffMin || t.hour == OffHourM && t.min == OffMinM){
      digitalWrite(Relay,LOW);
      Serial.println("LIGHT OFF");
    }
  t = rtc.getTime();
  Serial.print(t.hour);
  Serial.print(" hour2(s), ");
  Serial.print(t.min);
  Serial.print(" minute2(s)");
  Serial.println(" ");
  delay (1000);
  
  if(t.hour == OnHour2 && t.min == OnMin2 || t.hour == OnHour2M && t.min == OnMin2M){
    digitalWrite(Relay2,HIGH);
    Serial.println("LIGHT ON");
    }
    
    else if(t.hour == OffHour2 && t.min == OffMin2 || t.hour == OffHour2 && t.min == OffMin2){
      digitalWrite(Relay2,LOW);
      Serial.println("LIGHT OFF");
    }



}

I'm getting an error:
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:5:21: error: no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'
DS3231 rtc(SDA, SCL);
^
In file included from C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:1:0:
c:\Users\ulfer\OneDrive\Dokument\Arduino\libraries\DS3231/DS3231.h:73:3: note: candidate: DS3231::DS3231(TwoWire&)
DS3231(TwoWire & w);
^~~~~~
c:\Users\ulfer\OneDrive\Dokument\Arduino\libraries\DS3231/DS3231.h:73:3: note: candidate expects 1 argument, 2 provided
c:\Users\ulfer\OneDrive\Dokument\Arduino\libraries\DS3231/DS3231.h:72:3: note: candidate: DS3231::DS3231()
DS3231();
^~~~~~
c:\Users\ulfer\OneDrive\Dokument\Arduino\libraries\DS3231/DS3231.h:72:3: note: candidate expects 0 arguments, 2 provided
c:\Users\ulfer\OneDrive\Dokument\Arduino\libraries\DS3231/DS3231.h:68:7: note: candidate: constexpr DS3231::DS3231(const DS3231&)
class DS3231 {
^~~~~~
c:\Users\ulfer\OneDrive\Dokument\Arduino\libraries\DS3231/DS3231.h:68:7: note: candidate expects 1 argument, 2 provided
c:\Users\ulfer\OneDrive\Dokument\Arduino\libraries\DS3231/DS3231.h:68:7: note: candidate: constexpr DS3231::DS3231(DS3231&&)
c:\Users\ulfer\OneDrive\Dokument\Arduino\libraries\DS3231/DS3231.h:68:7: note: candidate expects 1 argument, 2 provided
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:6:1: error: 'Time' does not name a type; did you mean 'time'?
Time t;
^~~~
time
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino: In function 'void setup()':
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:15:7: error: 'class DS3231' has no member named 'begin'
rtc.begin();
^~~~~
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino: In function 'void loop()':
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:21:3: error: 't' was not declared in this scope
t = rtc.getTime();
^
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:21:11: error: 'class DS3231' has no member named 'getTime'; did you mean 'getA1Time'?
t = rtc.getTime();
^~~~~~~
getA1Time

exit status 1

Compilation error: no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'

What is your Arduino board?
It seems like you compile the ESP32 DS3231 example for, say, Arduino Uno.

SDA and SCL are fixed on Uno/Nano, so you don't need to indicate it at initialization.
Try to use

DS3231 rtc();

1 Like

arduino R4 wifi

I tried to use:
DS3231 rtc();
but get an error:
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:6:1: error: 'Time' does not name a type; did you mean 'time'?
Time t;
^~~~
time
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino: In function 'void setup()':
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:15:7: error: request for member 'begin' in 'rtc', which is of non-class type 'DS3231()'
rtc.begin();
^~~~~
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino: In function 'void loop()':
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:21:3: error: 't' was not declared in this scope
t = rtc.getTime();
^
C:\Users\ulfer\AppData\Local\Temp.arduinoIDE-unsaved2023919-33620-9swjob.vmcr6\sketch_oct19a\sketch_oct19a.ino:21:11: error: request for member 'getTime' in 'rtc', which is of non-class type 'DS3231()'
t = rtc.getTime();
^~~~~~~

exit status 1

Compilation error: 'Time' does not name a type; did you mean 'time'?

It means that you fixed the error with rtc object and continue the compilation to the next error. Now you need to also fix this error and so on. This process could be quite long and can include dozens errors.

As I said, it seems that you try to compile the code, that written to the another board.
You need the DS3231 library, compatible to Uno R4

1 Like

Or he could use the RTC built into the Uno R4 WiFi

1 Like

i got this code to work on arduino uno but what should the code look like if i want to use arduino r4 wifi rtc

#include <DS3231.h>

#include <FastLED.h>
#define NUM_LEDS 144
#define DATA_PIN 8
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define BRIGHTNESS 60
#define VOLTS 5
#define MAX_AMPS 500
CRGB leds[NUM_LEDS];

int Relay = 4;
int Relay2 = 7;

DS3231 rtc(SDA, SCL);
Time t;

const int OnHour = 13;
const int OnMin = 41;
const int OffHour = 13;
const int OffMin = 43;

const int OnHour2 = 12;
const int OnMin2 = 44;
const int OffHour2 = 12;
const int OffMin2 = 46;

const int OnHour22 = 13;
const int OnMin22 = 44;
const int OffHour22 = 13;
const int OffMin22 = 46;

const int OnHour33 = 13;
const int OnMin33 = 47;
const int OffHour33 = 13;
const int OffMin33 = 49;


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

  FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS, MAX_AMPS);
  FastLED.setBrightness(BRIGHTNESS);
  FastLED.clear();
  FastLED.show();
}

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 || t.hour == OnHour2 && t.min == OnMin2) {
    digitalWrite(Relay, HIGH);
    Serial.println("LIGHT ON");
    for (int i = 0; i < NUM_LEDS; i++) {
      leds[i] = CRGB::White;
      FastLED.show();
      delay(50);
    }
  }

  else if (t.hour == OffHour && t.min == OffMin || t.hour == OffHour2 && t.min == OffMin2) {
    digitalWrite(Relay, LOW);
    Serial.println("LIGHT OFF");
  }

  if (t.hour == OnHour22 && t.min == OnMin22 || t.hour == OnHour33 && t.min == OnMin33) {
    digitalWrite(Relay2, HIGH);
    Serial.println("LIGHT ON");
    delay(50);
  } else if (t.hour == OffHour22 && t.min == OffMin22 || t.hour == OffHour33 && t.min == OffMin33) {
    digitalWrite(Relay2, LOW);
    Serial.println("LIGHT OFF");
  }
}

How can I use this code to control the relay at different times?

#include "RTC.h"

void setup() {
  Serial.begin(9600);

  RTC.begin();

  RTCTime startTime(20, Month::OCTOBER, 2023, 10, 29, 00, DayOfWeek::FRIDAY, SaveLight::SAVING_TIME_ACTIVE);

  RTC.setTime(startTime);
}

void loop() {
  RTCTime currentTime;

  // Get current time from RTC
  RTC.getTime(currentTime);

  // Print out date (DD/MM//YYYY)
  Serial.print(currentTime.getDayOfMonth());
  Serial.print("/");
  Serial.print(Month2int(currentTime.getMonth()));
  Serial.print("/");
  Serial.print(currentTime.getYear());
  Serial.print(" - ");

  // Print time (HH/MM/SS)
  Serial.print(currentTime.getHour());
  Serial.print(":");
  Serial.print(currentTime.getMinutes());
  Serial.print(":");
  Serial.println(currentTime.getSeconds());

  delay(1000);
}

I think no way, there is no relay in this code

with relay

#include "RTC.h"

int Relay = 4;

const int OnHour = 13;
const int OnMin = 41;
const int OffHour = 13;
const int OffMin = 43;

void setup() {
  Serial.begin(9600);
  pinMode(Relay, OUTPUT);

  RTC.begin();

  RTCTime startTime(20, Month::OCTOBER, 2023, 10, 34, 00, DayOfWeek::FRIDAY, SaveLight::SAVING_TIME_ACTIVE);

  RTC.setTime(startTime);
}

void loop() {
  RTCTime currentTime;

  // Get current time from RTC
  RTC.getTime(currentTime);

  // Print out date (DD/MM//YYYY)
  Serial.print(currentTime.getDayOfMonth());
  Serial.print("/");
  Serial.print(Month2int(currentTime.getMonth()));
  Serial.print("/");
  Serial.print(currentTime.getYear());
  Serial.print(" - ");

  // Print time (HH/MM/SS)
  Serial.print(currentTime.getHour());
  Serial.print(":");
  Serial.print(currentTime.getMinutes());
  Serial.print(":");
  Serial.println(currentTime.getSeconds());

  delay(1000);

  if (hour == onHour && minute == onMin) {
    digitalWrite(Relay, HIGH);
  } else if (hour == offHour & minute == offMin) {
    digitalWrite(Relay, LOW);
    delay(100);
  }
}

And what is the question?
If you need to turn relay in more than one time - add additional conditions with different onHour and onMin variables , as you done it in the code at post 7

I get this error:
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino: In function 'void loop()':
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:44:7: error: 'hour' was not declared in this scope
if (hour == onHour && minute == onMin) {
^~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:44:7: note: suggested alternative: 'OnHour'
if (hour == onHour && minute == onMin) {
^~~~
OnHour
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:44:15: error: 'onHour' was not declared in this scope
if (hour == onHour && minute == onMin) {
^~~~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:44:15: note: suggested alternative: 'OnHour'
if (hour == onHour && minute == onMin) {
^~~~~~
OnHour
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:44:25: error: 'minute' was not declared in this scope
if (hour == onHour && minute == onMin) {
^~~~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:44:25: note: suggested alternative: 'rintl'
if (hour == onHour && minute == onMin) {
^~~~~~
rintl
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:44:35: error: 'onMin' was not declared in this scope
if (hour == onHour && minute == onMin) {
^~~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:44:35: note: suggested alternative: 'OnMin'
if (hour == onHour && minute == onMin) {
^~~~~
OnMin
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:46:22: error: 'offHour' was not declared in this scope
} else if (hour == offHour & minute == offMin) {
^~~~~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:46:22: note: suggested alternative: 'OffHour'
} else if (hour == offHour & minute == offMin) {
^~~~~~~
OffHour
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:46:42: error: 'offMin' was not declared in this scope
} else if (hour == offHour & minute == offMin) {
^~~~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:46:42: note: suggested alternative: 'OffMin'
} else if (hour == offHour & minute == offMin) {
^~~~~~
OffMin

exit status 1

Compilation error: 'hour' was not declared in this scope

You have declared your own int variables for hour and minute and assign a current time values to it with :

and

fumctions

Your questions show that you need to review basic concepts such as variables, procedures and functions, otherwise you will constantly encounter errors in your code.

I tried like this but it doesn't work.

#include "RTC.h"

int Relay = 4;

const int OnHour = 13;
const int OnMin = 41;
const int OffHour = 13;
const int OffMin = 43;

Time t;

void setup() {
  Serial.begin(9600);
  pinMode(Relay, OUTPUT);

  RTC.begin();

  RTCTime startTime(20, Month::OCTOBER, 2023, 10, 34, 00, DayOfWeek::FRIDAY, SaveLight::SAVING_TIME_ACTIVE);

  RTC.setTime(startTime);
}

void loop() {
  RTCTime currentTime;

  // Get current time from RTC
  RTC.getTime(currentTime);

  // Print out date (DD/MM//YYYY)
  //Serial.print(currentTime.getDayOfMonth());
  //Serial.print("/");
  //Serial.print(Month2int(currentTime.getMonth()));
  //Serial.print("/");
  //Serial.print(currentTime.getYear());
  //Serial.print(" - ");

  // Print time (HH/MM/SS)
  //Serial.print(currentTime.getHour());
  //Serial.print(":");
  //Serial.print(currentTime.getMinutes());
  //Serial.print(":");
  //Serial.println(currentTime.getSeconds());

  //delay(1000);

  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.minute == onMin) {
    digitalWrite(Relay, HIGH);
  } else if (t.hour == offHour & t.minute == offMin) {
    digitalWrite(Relay, LOW);
    delay(100);
  }
}

error:
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:10:1: error: 'Time' does not name a type; did you mean 'time'?
Time t;
^~~~
time
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino: In function 'void loop()':
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:46:3: error: 't' was not declared in this scope
t = RTC.getTime();
^
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:46:19: error: no matching function for call to 'RTClock::getTime()'
t = RTC.getTime();
^
In file included from C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:1:0:
C:\Users\ulfer\AppData\Local\Arduino15\packages\arduino\hardware\renesas_uno\1.0.4\libraries\RTC\src/RTC.h:180:10: note: candidate: bool RTClock::getTime(RTCTime&)
bool getTime(RTCTime &t);
^~~~~~~
C:\Users\ulfer\AppData\Local\Arduino15\packages\arduino\hardware\renesas_uno\1.0.4\libraries\RTC\src/RTC.h:180:10: note: candidate expects 1 argument, 0 provided
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:54:17: error: 'onHour' was not declared in this scope
if (t.hour == onHour && t.minute == onMin) {
^~~~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:54:17: note: suggested alternative: 'OnHour'
if (t.hour == onHour && t.minute == onMin) {
^~~~~~
OnHour
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:54:39: error: 'onMin' was not declared in this scope
if (t.hour == onHour && t.minute == onMin) {
^~~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:54:39: note: suggested alternative: 'OnMin'
if (t.hour == onHour && t.minute == onMin) {
^~~~~
OnMin
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:56:24: error: 'offHour' was not declared in this scope
} else if (t.hour == offHour & t.minute == offMin) {
^~~~~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:56:24: note: suggested alternative: 'OffHour'
} else if (t.hour == offHour & t.minute == offMin) {
^~~~~~~
OffHour
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:56:46: error: 'offMin' was not declared in this scope
} else if (t.hour == offHour & t.minute == offMin) {
^~~~~~
C:\Users\ulfer\OneDrive\Dokument\Arduino\ArduionR4wifitimeset\ArduionR4wifitimeset.ino:56:46: note: suggested alternative: 'OffMin'
} else if (t.hour == offHour & t.minute == offMin) {
^~~~~~
OffMin

exit status 1

Compilation error: 'Time' does not name a type; did you mean 'time'?

To get current time please see the working example that you commented in your code!

once again - read some language textbook, don’t try to program by picking up similar lines from other people’s sketches - you must understand what you are doing

I'm not that experienced so I don't know how to write in the code to use getHour and getMinute.

#include "RTC.h"

int Relay = 4;

const int OnHour = 13;
const int OnMin = 41;
const int OffHour = 13;
const int OffMin = 43;


void setup() {
  Serial.begin(9600);
  pinMode(Relay, OUTPUT);

  RTC.begin();

  RTCTime startTime(20, Month::OCTOBER, 2023, 10, 34, 00, DayOfWeek::FRIDAY, SaveLight::SAVING_TIME_ACTIVE);

  RTC.setTime(startTime);
}

void loop() {
  RTCTime currentTime;

  // Get current time from RTC
  RTC.getTime(currentTime);

  // Print out date (DD/MM//YYYY)
  Serial.print(currentTime.getDayOfMonth());
  Serial.print("/");
  Serial.print(Month2int(currentTime.getMonth()));
  Serial.print("/");
  Serial.print(currentTime.getYear());
  Serial.print(" - ");

  // Print time (HH/MM/SS)
  Serial.print(currentTime.getHour());
  Serial.print(":");
  Serial.print(currentTime.getMinutes());
  Serial.print(":");
  Serial.println(currentTime.getSeconds());

  delay(1000);


  if (hour == onHour && minute == onMin) {
    digitalWrite(Relay, HIGH);
  } else if (hour == offHour & minute == offMin) {
    digitalWrite(Relay, LOW);
    delay(100);
  }
}
int hour = currentTime.getHour();
int minute = currentTime.getMinutes();

and where and how should I use these lines. I tried this and it didn't work

#include "RTC.h"

int Relay = 4;

const int OnHour = 13;
const int OnMin = 41;
const int OffHour = 13;
const int OffMin = 43;

int hour = currentTime.getHour();
int minute = currentTime.getMinutes();


void setup() {
  Serial.begin(9600);
  pinMode(Relay, OUTPUT);

  RTC.begin();

  RTCTime startTime(20, Month::OCTOBER, 2023, 10, 34, 00, DayOfWeek::FRIDAY, SaveLight::SAVING_TIME_ACTIVE);

  RTC.setTime(startTime);
}

void loop() {
  RTCTime currentTime;

  // Get current time from RTC
  RTC.getTime(currentTime);

  // Print out date (DD/MM//YYYY)
  Serial.print(currentTime.getDayOfMonth());
  Serial.print("/");
  Serial.print(Month2int(currentTime.getMonth()));
  Serial.print("/");
  Serial.print(currentTime.getYear());
  Serial.print(" - ");

  // Print time (HH/MM/SS)
  Serial.print(currentTime.getHour());
  Serial.print(":");
  Serial.print(currentTime.getMinutes());
  Serial.print(":");
  Serial.println(currentTime.getSeconds());

  delay(1000);


  if (hour == onHour && minute == onMin) {
    digitalWrite(Relay, HIGH);
  } else if (hour == offHour & minute == offMin) {
    digitalWrite(Relay, LOW);
    delay(100);
  }
}

thank you very much, it works

#include "RTC.h"

int Relay = 4;

const int OnHour = 13;
const int OnMin = 3;
const int OffHour = 13;
const int OffMin = 5;



void setup() {
  Serial.begin(9600);
  pinMode(Relay, OUTPUT);

  RTC.begin();

  RTCTime startTime(20, Month::OCTOBER, 2023, 13, 1, 00, DayOfWeek::FRIDAY, SaveLight::SAVING_TIME_ACTIVE);

  RTC.setTime(startTime);
}

void loop() {
  RTCTime currentTime;

  // Get current time from RTC
  RTC.getTime(currentTime);

  int hour = currentTime.getHour();
  int minute = currentTime.getMinutes();

  // Print out date (DD/MM//YYYY)
  Serial.print(currentTime.getDayOfMonth());
  Serial.print("/");
  Serial.print(Month2int(currentTime.getMonth()));
  Serial.print("/");
  Serial.print(currentTime.getYear());
  Serial.print(" - ");

  // Print time (HH/MM/SS)
  Serial.print(currentTime.getHour());
  Serial.print(":");
  Serial.print(currentTime.getMinutes());
  Serial.print(":");
  Serial.println(currentTime.getSeconds());

  delay(1000);


  if (hour == OnHour && minute == OnMin) {
    digitalWrite(Relay, HIGH);
    Serial.println("reay on");
  } else if (hour == OffHour & minute == OffMin) {
    digitalWrite(Relay, LOW);
    Serial.println("reay off");
    delay(100);
  }
}

just a shame that it doesn't work to connect battery to VRTC to save time when disconnecting Arduino R4 wifi