Help with feeder
Help with feeder
Hi, I am trying to automate the Eheim feeder and have some questions on how to do this (after having read some threads).
I want to initialize feed mode at a certain time, make sure that Vortech pumps also go into feed mode, "press" the automatic feeder 2 min later, and then things would come back to normal after 15 min.
In terms of the feeder mod, I am using an Eheim feeder and want to connect it to the PWM. I am using the mod where I keep the batteries, and use a 5v relay to press the manual feeding.
This would be my attempt, and have some questions:
if (hour()==13 && minute()==0 && second()==0) ReefAngel.FeedingModeStart(); //Start the feed mode
[Would this be enough for the Vortechs or do I need to add a line for this?]
if (hour()==13 && minute()==2 && second()==0) ReefAngel.FeedingModeStart(); // 2 min later activate auto feeder
[not sure how to close the 5v relay to launch the automatic feeder]
Thanks!
I want to initialize feed mode at a certain time, make sure that Vortech pumps also go into feed mode, "press" the automatic feeder 2 min later, and then things would come back to normal after 15 min.
In terms of the feeder mod, I am using an Eheim feeder and want to connect it to the PWM. I am using the mod where I keep the batteries, and use a 5v relay to press the manual feeding.
This would be my attempt, and have some questions:
if (hour()==13 && minute()==0 && second()==0) ReefAngel.FeedingModeStart(); //Start the feed mode
[Would this be enough for the Vortechs or do I need to add a line for this?]
if (hour()==13 && minute()==2 && second()==0) ReefAngel.FeedingModeStart(); // 2 min later activate auto feeder
[not sure how to close the 5v relay to launch the automatic feeder]
Thanks!
Re: Help with feeder
Look at the code in my INO...it might be in the vacation function.
Re: Help with feeder
Thanks Lee. I am not good on the programming side and have been trying to understand your INO for a while now (have it downloaded). I don't think that you are using the PWM port to run the feeder, right?
Re: Help with feeder
No I'm not but I can help you translate it. I'll post the relevant code later tonight.
Re: Help with feeder
Ok, so I did more homework.
To turn on the feeder, I would use the following:
analogWrite(daylightPWMPin,255);
delay(500);
analogWrite(daylightPWMPin,0);
Now, I have been reviewing your code Lee (and reading a lot about Arduino to make some sense) and have some questions:
- If I understand correctly, you can modify the value of the variable Mem_B_Vacation to trigger on vacation, right?
- That would be great to be able to trigger a feeding through my iPhone
- What I don't understand is why you need to go through the relay piece instead of directly doing the onVacation = Mem_B_Vacation
- I also don't understand the now()%SECS_PER_DAY==19*SECS_PER_HOUR piece. Is this to start feeding at 7 pm? Don't understand the logic.
Thanks a lot for the help!
To turn on the feeder, I would use the following:
analogWrite(daylightPWMPin,255);
delay(500);
analogWrite(daylightPWMPin,0);
Now, I have been reviewing your code Lee (and reading a lot about Arduino to make some sense) and have some questions:
- If I understand correctly, you can modify the value of the variable Mem_B_Vacation to trigger on vacation, right?
- That would be great to be able to trigger a feeding through my iPhone
- What I don't understand is why you need to go through the relay piece instead of directly doing the onVacation = Mem_B_Vacation
- I also don't understand the now()%SECS_PER_DAY==19*SECS_PER_HOUR piece. Is this to start feeding at 7 pm? Don't understand the logic.
Thanks a lot for the help!
Re: Help with feeder
Sorry for not posting the code sooner. I don't like using delay() but since you're only going to do it once or twice a day, then it shouldn't be an issue. I'll show you what I do shortly.
To answer your questions
- I use the Memory location because it's the only way to ensure that it stays on if the head unit reboots or any power issues. So Mem_B_Vacation stores whether the mode is enabled/disabled
- The memory location is not used to trigger the feeder, just sets whether the feeder will run at the scheduled time. If I trigger the relay that the feeder is on (you don't have one... but you could use an unused outlet or a virtual outlet) to trigger a feeding through the phone.
- The now()%SECS_PER_DAY==19*SECS_PER_HOUR is to start the feeding mode at 7pm!! The logic works like this:
When you divide now() (the current time in seconds since 1970) by the number of seconds per day, you get the current time as the remainder. The remainder is called the modulus and the % is called modulo. As an example
35 / 3 = 11, remainder 2
35 % 3 = 2
So now to find out if it is a certain time, we can do the == comparison and 19*SECS_PER_HOUR is 7pm in seconds.
For you what I would do is just this
So this will track feeding mode. Every time you go into feeding mode, the timer will be triggered. When 2 minutes have elapsed, the feeder will be activated. At 1pm you will automatically go into feeding mode. If you want to trigger the auto-feeder, you just put your RA in feeding mode manually and the feeder will trigger two minutes later.
To answer your questions
- I use the Memory location because it's the only way to ensure that it stays on if the head unit reboots or any power issues. So Mem_B_Vacation stores whether the mode is enabled/disabled
- The memory location is not used to trigger the feeder, just sets whether the feeder will run at the scheduled time. If I trigger the relay that the feeder is on (you don't have one... but you could use an unused outlet or a virtual outlet) to trigger a feeding through the phone.
- The now()%SECS_PER_DAY==19*SECS_PER_HOUR is to start the feeding mode at 7pm!! The logic works like this:
When you divide now() (the current time in seconds since 1970) by the number of seconds per day, you get the current time as the remainder. The remainder is called the modulus and the % is called modulo. As an example
35 / 3 = 11, remainder 2
35 % 3 = 2
So now to find out if it is a certain time, we can do the == comparison and 19*SECS_PER_HOUR is 7pm in seconds.
For you what I would do is just this
Code: Select all
static bool feedStart; // Flag to see when feed mode has started
static unsigned long feedTimer; // timer to track when to trigger the feeder
if (ReefAngel.DisplayedMenu!=FEEDING_MODE) feedStart=false; // Reset the flag...
if (ReefAngel.DisplayedMenu==FEEDING_MODE && feedStart==false) {
feedStart=true; // So we don't start the timer more than once per feeding mode.
feedTimer=now(); // We're going to use this time to see if 2 minutes is up before we trigger the feeder.
}
if ( now()-feedTimer == 120) // 2 min later activate auto feeder
analogWrite(daylightPWMPin,255);
else
analogWrite(daylightPWMPin,0);
// Start feed mode once per day at 1pm.
if (hour()==13 && minute()==0 && second()==0) ReefAngel.FeedingModeStart();
Re: Help with feeder
Lee, you are great! Let me digest this and will come back with questions if I don't get it (but I think I do). Super helpful.
One silly question: you can use VO from a non existent box to trigger things through the app? That is awesome and a great idea! As you point out, not really needed for this (since I can start feed model from the app), but will be helpful in the future!
Another last one:
I have Radions on the main tank, a Sol on the refugium, and building an algae scrubber (so more LEDs there). I used the mainlight function for the Algae scrubber (to turn on at night) and slope functions for the Sol and Radion. But if I am not mistaken the start and end time of the slope will come from what I have for the main lights, right? So I need to find an alternative to this (hard code or custom memory)
One silly question: you can use VO from a non existent box to trigger things through the app? That is awesome and a great idea! As you point out, not really needed for this (since I can start feed model from the app), but will be helpful in the future!
Another last one:
I have Radions on the main tank, a Sol on the refugium, and building an algae scrubber (so more LEDs there). I used the mainlight function for the Algae scrubber (to turn on at night) and slope functions for the Sol and Radion. But if I am not mistaken the start and end time of the slope will come from what I have for the main lights, right? So I need to find an alternative to this (hard code or custom memory)
Re: Help with feeder
This function turns on when your main lights are off.
Code: Select all
ReefAngel.MoonLights(Port1);
Roberto.
Re: Help with feeder
Or you can always hard code it:
Code: Select all
ReefAngel.StandardLights(Port1,20,0,9,0);
Roberto.
Re: Help with feeder
Thanks Roberto. Just to be sure:
Can I have the hard coded one for the Alga Scrubber as above, and have one StabdardLights that reads the memory for the Radions/Sol (of course the same for the two)?
Can I have the hard coded one for the Alga Scrubber as above, and have one StabdardLights that reads the memory for the Radions/Sol (of course the same for the two)?
Re: Help with feeder
I am sure the answer is yes since these are functions.