cattledog:
That makes two of us.I still don't know which library you are using. I strongly recommend that you start over with the Christensen library. It integrates with the time library well, and will handle alarms.
Break your project into smaller pieces, and learn how to handle the relays and RTC by themselves. Then add in the DHT.
I'm not sure I see why this is the code you posted, so I would go back to a known and reliable library and verify how the relays are driven.
Ok so in response to this I have downloaded the suggested libraries. I agree with breaking this into smaller pieces. You have to understand the existing device I built/programmed was the first electronics project I have ever taken on and I haven't tried to refine in almost a year so Please, Please be patient. I am trying to get back into this.
J-M-L:
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 stoppedthis 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?
In response to this. I would like to do this using the Alarm capabilities and am trying to base this off of the Time Alarms library. I think I would be using
"Alarm.timerRepeat(Period, TimerFunction);
Description: Continuously calls user provided TimerFunction after the given period in seconds has elapsed."
to accomplish this. Also, I assume that "TimerFunction" is a generic phrase? Would I place my own callback function? For instance, can i have my on/off function assigned as AlarmOn and AlarmOff in the setup?
Let me ask this. Is there a way to express this so that I am only using recalled minutes data to perform an action like this for every hour without writing 24 blocks?
"
if time = 00,00,00 - relay on
if time = 00,08,00 - relay off
if time = 00,30,00 - relay on
if time = 00,38,00 - relay off
"
DoW is not any concern.
Seconds are not any concern.
This is not an emergency situation mind you. I have my current microcontroller running but in the coming months i am going to need the freedom to adjust things so that I can manipulate the amount of times per hour this relay turns on and for what period of minutes.