I am trying to turn on and off the heaters in three zones, Office, Lounge and Bedroom.
int officeStart = ( 7 * 60) + 0; // 7:00am ON
int officeStop = (15 * 60) + 0; // 3:00pm OFF
int loungeStart = (15 * 60) + 45; // 3:45pm ON
int loungeStop = (21 * 60) + 15; // 9:15pm OFF
int bedroomStart =(21 * 60) + 0; // 9:00pm ON
int bedroomStop = ( 6 * 60) + 0; // 6:00am OFF <<-- PROBLEM as next day
void Loop ()
{
RTC.read(tm);
int tempMins = (tm.Hour * 60) + tm.Minute;
if (tempMins >= officeStart && tempMins <= officeStop)
relaySwitchOn(idxOffice); else
relaySwitchOff(idxOffice);
if (tempMins >= loungeStart && tempMins <= loungeStop)
relaySwitchOn(idxLounge);
relaySwitchOff(idxLounge);
if (tempMins >= bedroomStart && tempMins <= bedroomStop)
relaySwitchOn(idxBedroom);
relaySwitchOff(idxBedroom);
The problem is that bedroomStart = 1260 and bedroomEnd = 360 the next morning
How do I define a Stop time that can be less than the Start time? Not just for the bedroom, but the other two zones also? This will eventually include the A/C for Summer cooling so several zones could stretch across Midnight.
Thanks