I’m looking to setup a time activated relay that will turn on/off during specific days of the week. Any suggestions on how I can approach this?
@oraclerouter There is a library you can try using DailyTimerSpark GitHub - BulldogLowell/DailyTimerSpark: Particle Library for setting daily timers I have used this in modified form to control the lights on my drive. I have also added calculation of the sunrise and sunset times so I don’t have to modify the on and off times throughout the year.
Thanks @armor.
Any thoughts on how to exposed a function that would allow me to change the timer on-demand and also save it to EEPROM?
@oraclerouter Splitting those requirements;
- dynamic update of the timer times, the library defines a Class with public methods. You instantiate the timer object with
DailyTimer myTimer();
and thenmyTimer.setStartTime(hour, minute)
andmyTimer.setEndTime(hour, minute)
.
2.save to eeprom, this is standard stuff, I would create a struct for whatever data you want to hold and recover after power up.
struct myData{
byte starthour;
byte startmins;
byte endhour;
byte endmins;
};
myData myTimers;
You save the memory based struct to EEPROM with:
EEPROM.put(0, myTimers);
And recover the data saved to EEPROM with:
EEPROM.get(0, myTimers);
you then access the values with dot notation myTimers.starthour = 11;
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.