I've got some code for you to try out. This will work for you as long as you do not have the Wavemaker port running on the toggle. If you did, you may encounter a problem. There is probably a better way to handle this, BUT this is a good start and should handle most scenarios.
It's designed to work like I previously mentioned. You will have to specify the ports you want to turn off. It also assumes that your autofeeder is plugged into a port that just needs power to start it up.
The example I'm giving will turn off Port8 and Port4 the specified amount of time (PortDelay) before the Start time. Then it will run the autofeeder for the specified amount of time (FeedDelay) then shut off the feeder port (Port5) and turn back on Port8 and Port4. You can change the ports if you like, but I just picked a couple for the example.
Also, my example uses memory locations as follows:
700 - Enable / Disable the "vacation mode", 1 enables, all other values disable
701 - Start Hour for vacation feeding mode (in 24 hr format)
702 - Start Minute for vacation feeding mode
703 - Pump Delay in minutes (amount of time before vacation feeding mode that the pumps should be shutoff)
704 - Feed Delay in minutes (amount of time that the autofeeder will run for before getting shutoff)
You will need to set those values with the client or via the serial monitor or web interface get it to work properly. NOTE: You will probably need help setting this. If so, just ask.
Here's the complete code based:
Code: Select all
// RAMenus.pde
//
// This version designed for v0.8.5 Beta 10 and later
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
// Vacation autofeeder memory locations
#define Vacation 700
#define VacationEnable Vacation
#define VacationStartHr Vacation+1
#define VacationStartMin Vacation+2
#define VacationPumpDelay Vacation+3
#define VacationFeedDelay Vacation+4
void setup()
{
ReefAngel.Init(); //Initialize controller
// Ports that are always on
ReefAngel.Relay.On(Port8);
ReefAngel.Relay.On(Port4);
}
void loop()
{
ReefAngel.ShowInterface();
if ( InternalMemory.read(VacationEnable) == 1 )
{
// Vacation mode is enabled
/*
Check if the current time is equal to the start time minus the pump delay. The pump delay is the amount
of time the pumps should be off prior to starting the feeding mode
*/
if ( NumMins(hour(), minute()) == (NumMins(InternalMemory.read(VacationStartHr), InternalMemory.read(VacationStartMin))
- InternalMemory.read(VacationPumpDelay)) )
{
// Let's shutoff the ports
ReefAngel.Relay.Off(Port8); // return pump off
ReefAngel.Relay.Off(Port4); // wavemaker off
}
/*
Check if the current time is equal to the start time, if it is, we need to start the feeding mode
*/
if ( NumMins(hour(), minute()) == NumMins(InternalMemory.read(VacationStartHr), InternalMemory.read(VacationStartMin)) )
{
// turn on the auto feed ports
ReefAngel.Relay.On(Port5); // auto feeder port on
}
/*
Check if the current time is equal to the feeding delay/run time, if it is we need to stop the
auto feeder and then turn back on the pumps
*/
if ( NumMins(hour(), minute()) == (NumMins(InternalMemory.read(VacationStartHr), InternalMemory.read(VacationStartMin))
+ InternalMemory.read(VacationFeedDelay)) )
{
ReefAngel.Relay.Off(Port5); // auto feeder port off
ReefAngel.Relay.On(Port8); // return pump on
ReefAngel.Relay.On(Port4); // wavemaker on
}
}
}
I tested it out on my end exactly like this and it works as designed. If modifications are needed, just ask and we can figure something out.
curt