RTC and Interval Timing

I think you are going distracted by other things than your case at hand.

You stated your intent was as follow "I am trying to get one of my relays to switch on during the first 10 minutes of the hour, and a 10 minute block in the middle of the hour (XX:30-XX:40). "

The hardware you have available for this is

  • Mega 2560
  • an RTC3231.
  • a DHT11 temp/humidity sensor
  • 4 relays to take actions

From a programming standpoint you have 2 options:

Option 1
use to loop() and poll the RTC
see if you have reached a time where action needs to be start and action is not started
if so take the action and mark in some way that this action is started
see if you have reached a time where action needs to be stop (and is started)
if so take the action and mark in some way that this action is stopped

this is pretty straightforward to code assuming your RTC is properly set and you know how to extract time information. Usually best way to proceed is to build a unique number from hour, minute, second by doing (hour x 3600 + minute x 60 + second) which gives you a unique time stamp for a day and compare that to the timestamp of your actions.

Option 2
The RTC component you have has "alarm" capabilities. so instead of polling constantly in the loop() the RTC, use the alarm functions the RTC to call you back when something needs to happen.

Does this help?