Questions about Real Time Clock

Hello, I am working with An Arduino Uno R3 and an Adafruit PCF8523 Real Time Clock Assembled Breakout Board Adafruit PCF8523 Real Time Clock Assembled Breakout Board : ID 3295 : $6.95 : Adafruit Industries, Unique & fun DIY electronics and kits

I am creating a Light timer using a Relay Module and RTC that will control the relays -

I am working with the RTCLib that is "A fork of JeeLab's fantastic real time clock library for Arduino." - Found at RTClib/README.md at master · adafruit/RTClib · GitHub

In the following example (RTClib/examples/pcf8523/pcf8523.ino) , can anyone explain (7,12,30,6)?

// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now + TimeSpan(7,12,30,6));

I poked around in the Library File (RTClib/RTClib.cpp)and found the code below, but this doesn't really mesh up with how I understand the (7,12,30,6) -

TimeSpan (int32_t seconds = 0);
TimeSpan (int16_t days, int8_t hours, int8_t minutes, int8_t seconds);
TimeSpan (const TimeSpan& copy);
int16_t days() const { return _seconds / 86400L; }
int8_t hours() const { return _seconds / 3600 % 24; }
int8_t minutes() const { return _seconds / 60 % 60; }
int8_t seconds() const { return _seconds % 60; }
int32_t totalseconds() const { return _seconds; }

Also, Can I setup a string array to simplify calling upon times for an event timer?

My idea example:

char CurrentTime[2] = {now.hour()now.minute()}

if CurrentTime = currentTime[12,30] //12:30pm - Did I get the Syntax right?
//launch a subroutine –
if CurrentTime = currentTime[13,45] //1:45pm -
//launch a subroutine –
if CurrentTime = currentTime[16,25] //4:25pm –
//launch a subroutine –
if CurrentTime = currentTime[0,30] //12:30am –
//launch a subroutine –

Is there a good way to divide the day and easily modify the value to be 3x, 5x, 6x, etc. Per day?

Thank you in Advance :slight_smile:

Theratdude64:
In the following example (RTClib/examples/pcf8523/pcf8523.ino) , can anyone explain (7,12,30,6)?

I think the comment from the author

calculate a date which is 7 days and 30 seconds into the future

is just wrong, it should include the hours and minutes.

Also, Can I setup a string array to simplify calling upon times for an event timer?

My idea example:
Is there a good way to divide the day and easily modify the value to be 3x, 5x, 6x, etc. Per day?

char CurrentTime[2] = {now.hour()now.minute()}

if CurrentTime = currentTime[12,30]      //12:30pm - Did I get the Syntax right?

no, you can't compare arrays like that, sorry!
Even if you could, you would need '==' for compare, not '='
if (CurrentTime == currentTime[12,30])      but [x,y] isn't correct syntax either.
If you are just comparing minutes then I would multiply hours by 60 and add to minutes, and compare the totals. But if it's for an alarm or similar, make sure it only fires once each time and not continuously for a whole minute!

Also, use code tags (</>), not quote tags, for posting code.

quilkin:
I think the comment from the author is just wrong, it should include the hours and minutes.
no, you can't compare arrays like that, sorry!

I figured their comment had to be incorrect. Should I use that timeSpan to trigger the relay switch?

Darn, sounded good in my head @arrays lol. I am referencing this site @ https://www.arduino.cc/en/Reference/String and trying to apply it to this theory, but if I understand the timeSpan above, perhaps just go that route.

Even if you could, you would need '==' for compare, not '='

if (CurrentTime == currentTime[12,30])

but [x,y] isn't correct syntax either.
If you are just comparing minutes then I would multiply hours by 60 and add to minutes, and compare the totals. But if it's for an alarm or similar, make sure it only fires once each time and not continuously for a whole minute!

Also, use code tags (</>), not quote tags, for posting code.

The plan would be to trigger the relays to control lights on for 18 hours, then off for 6 hours to supply Pepper seedlings.

Thanks for the tip on code tags, I knew there was some kind of option like that but I didn't see it in the WYSIWYG interface