Writing Relay State in EEPROM.

I have been working on a project for my greenhouse using a arduino uno and a day1307 RTC to switch on/off the lights at a particular time which is set using 3 push buttons. I have got the buttons working and i can set the time using them. I also connected a output pin to a relay which is working perfectly using switch cases.

In India, and particularly where I live, we have a lot of power failures which makes a simple task of using the timer difficult.

Where an I stuck : I have read about the bool/boolean function and i have set a relay state for the relay. In the relay stage, i have compared the now.hour() to the timeron function and set a relay state according.

I have also made a checkrelaystatus function where i am using the eepron value of the last saved state and comparing that yo the current state when the arguing fires up again. This is where I am stuck.

Anyone out there has a better solution of doing it. I will post my code tomorrow as we are out of power again and I am using my phone to write this post :

You don't need an eeprom for this. After a power failure, check if the time is between the times that a relay must be on and switch it on again if that's the case, else switch off.

You'll have to show your code for us to understand where and why you are stuck. In case you haven't read it yet, please read How to sue this forum - please read, specifically point 7 about posting code.

Rather than saving relay states to the EEPROM, I'd just save the schedule to the EEPROM. You read the schedule from EEPROM in setup() and then set the relays according to the comparison of the schedule with the current time from the RTC.

The last relay states before the power outage are irrelevant.