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&)'
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
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
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.
#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