Eheim autofeeder

Request new hardware or ideas for the controller

Posts: 267
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA
PostPosted: Fri Mar 29, 2013 7:44 pm
jsclownfish wrote:Let me know if you want me to post the code (I'm not at my PC at the moment).

-Jon


That would be great if you could. That sounds like exactly what I want to do.

Thanks,
Charlie
User avatar
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis
PostPosted: Fri Mar 29, 2013 9:06 pm
OK, so here is how I do it. I tried to simplify my ino files down to the autofeeder stuff. Also, you'll see I slowly added more options so there are 4 now:
1. feed once a day
2. feed twice a day
3. feed every hour during the day
4. feed on command with a memory location read to trigger the event.

Here is the relevant main code...
Code: Select all
// Vacation autofeeder memory locations
#define Vacation         100
#define VacationEnable      Vacation  //autofeeder on=1
#define VacationStartHr      Vacation+1  //1st hour
#define VacationStartMin   Vacation+2  //1st minute
#define VacationStart2ndHr      Vacation+3   //2nd hour
#define VacationStart2ndMin   Vacation+4   //second minute
#define FastFeed    Vacation+5  //Fast feeder timer
#define VacationPulseFeed    Vacation+6  //pulse signal from the internal memory function

byte Feed = 0;

void setup()
{
}
void loop()
{
//Autofeeder Mode
  if (  (InternalMemory.read(VacationEnable) > 0) || (InternalMemory.read(VacationEnable) <= 2)  ) // check for vacation mode 1 time a day
   {
         // Check if the current time is equal to the start time.
            if (NumMins(hour(), minute()) == (NumMins(InternalMemory.read(VacationStartHr), InternalMemory.read(VacationStartMin))))
            {
              if (second() == 0)
                    {
         Feed = 1;   // Turn on feeder and feedmode
         ReefAngel.FeedingModeStart();
              }   
            }
            else Feed = 0;
         }
  if ( InternalMemory.read(VacationEnable) == 2 ) // check for vacation mode 2 times a day
   {
         // Check if the current time is equal to the start time.
            if (NumMins(hour(), minute()) == (NumMins(InternalMemory.read(VacationStart2ndHr), InternalMemory.read(VacationStart2ndMin))))
            {
              if (second() == 0)
                    {
         Feed = 1;   // Turn on feeder and feedmode
         ReefAngel.FeedingModeStart();
              }   
            }
            else Feed = 0;
         }
  if ( InternalMemory.read(VacationEnable) == 3 ) // check for vacation mode hourly
   {
           if ((hour() >= 10) || (hour() <= 19)) //from 10a-7p
             {
              if (minute() ==30 && second() == 0) //once an hour on the half hour
                    {
         Feed = 1;   // Turn on feeder and feedmode
                        ReefAngel.Timer[FEEDING_TIMER].SetInterval(InternalMemory.read(FastFeed));   //short feed timer      
                        ReefAngel.FeedingModeStart();
                        ReefAngel.Timer[FEEDING_TIMER].SetInterval(InternalMemory.FeedingTimer_read());  //reset original feed timer
              }   
             else Feed = 0;
             }
         }
  if ( InternalMemory.read(VacationPulseFeed) == 1 ) // feeder trigger for remote feeding
   {
          Feed = 1;   // Turn on feeder and feedmode
          ReefAngel.Timer[FEEDING_TIMER].SetInterval(InternalMemory.read(FastFeed));   //short feed timer      
          ReefAngel.FeedingModeStart();
          ReefAngel.Timer[FEEDING_TIMER].SetInterval(InternalMemory.FeedingTimer_read());  //reset original feed timer
          InternalMemory.write(VacationPulseFeed,0);     //reset variable to 0 to mimic a pulse or button release   
   }
         else Feed = 0;

//I/O module communication
  Wire.beginTransmission(7);      // transmit to device #7 (IO Module)
  Wire.write('$');         // send the $$$
  Wire.write('$');
  Wire.write('$');
  Wire.write(Feed);
  Wire.endTransmission();      // stop transmitting 


and here is the relevant IO code....
Code: Select all
#include <Wire.h>
#include <avr/wdt.h>

byte Feeder=0;   //autofeeder signal

void setup()
{
  Wire.begin(7);
  Wire.onReceive(receiveEvent);
  pinMode(10,OUTPUT);  //autofeeder pin
  digitalWrite(10,LOW);
}

void loop()
{
  //feeder
 if (Feeder == 0)
 {
   digitalWrite(10, LOW);
 }
 else if (Feeder == 1)
 {
   digitalWrite(10, HIGH);
 }
}

void receiveEvent(int howMany)
{
  if (howMany==4)  // Our custom protocol is 4 bytes
  {
    byte cmd1,cmd2,cmd3,cmd4;
    cmd1=Wire.read();
    cmd2=Wire.read();
    cmd3=Wire.read();
    cmd4=Wire.read(); 
    if (cmd1=='$' && cmd2=='$' && cmd3=='$') // the first 3 bytes of the custom protocol are $$$ to ensure it's coming from RA
    {
      Feeder=cmd4;
    }
  }
  else
    for (int a=0;a<howMany;a++)
      Wire.read(); // if the number of bytes is not 4, discard everything
}



Hope that helps.
-Jon
User avatar
Posts: 5362
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sat Mar 30, 2013 5:12 am
So it looks like the button "press" is really just a momentary action. Was trying to figure out how much time I needed to "hold" the button down for..i

For the electronics part. You are just going from the io module to relay and relay to button?
User avatar
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis
PostPosted: Sat Mar 30, 2013 8:10 am
Yes. I just used a little plastic box to to hold the 5V relay from RadioShack http://www.radioshack.com/product/index.jsp?productId=2062478.

Jon
User avatar
Posts: 5362
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sat Mar 30, 2013 9:30 am
That gives me a great idea... :)

Roberto can you sell me a small ReefAngel box with a mini usb port? i'm thinking like the pressure switch case. I can install the relay in that and run a mono audio cable up to the feeder :)

I could use the hole to mount the mono jack :) just need to make sure it'll be ok size wise...

If we can do something shoot me a PM with the options :)

Posts: 12309
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sat Mar 30, 2013 9:36 am
Sure. It's very tiny though.
Roberto.
User avatar
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis
PostPosted: Sat Mar 30, 2013 9:36 am
I like that idea! I don't like that mine is hard wired now and I haven't taken the time to change it. The RadioShack plastic box is also too big. I'd think you would need a IO size box though.


Jon
User avatar
Posts: 5362
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sat Mar 30, 2013 9:37 am
Yeah The pressure switch may be too tiny...but io module size would work :) i've no idea how big the relay is.. :)
User avatar
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis
PostPosted: Sat Mar 30, 2013 9:44 am
the one I used was maybe 1" long and 1/4" around.
Jon
User avatar
Posts: 5362
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sat Mar 30, 2013 10:38 am
Just picked up the relay some mono ports and jacks. The relay is not the one linked but it should be fine. Pretty small.
PreviousNext

Return to Requests

Who is online

Users browsing this forum: No registered users and 2 guests

cron