Go Down

Topic: Arduino fish tank (Read 3240 times) previous topic - next topic

myreprapinfo

pwillard, yes that is me! I play drums with my Dad's music education program! I'm in high school now (I know, a little young to be doing this kind of stuff) and I'm just starting to get into coding and the Arduino. This is all a learning experiance for me.

That's really funny that you found that!  ;)

Elijah

Ran Talbott

Quote
I know, a little young to be doing this kind of stuff


No,  you're not.

Maybe someday I'll post a long rant in Bar Sport about this,  but I think it's vitally important to the future,  especially of the U.S.,  but also of the whole planet,  that we have high school students,  and even grade school students,  actively interested in activities like tinkering with Arduinos and learning how to make stuff work.  Encouraging people who are trying to learn is one of the best investments of our time we can make.

(Which is also why I occasionally bitch about people whose idea of "education" is getting forum members to design their college projects for them:  having people who can pretend to solve problems in the workforce is almost as bad for technological progress as having people who can't even do that   >:()

Ran

pwillard

Finding you... Neat trick, huh?  I so admire good drummers.  

You are not too young by the way!  Go for it.

My father was an Electronics engineer and he realized I had an interest when I was about 13.  By the time I was a senior in High School I pretty much already knew more than my Physics textbook  could teach me about electronics.  I did a senior electronics project for the science fair about about advancements in electronics and semiconductor theory which sort of blew people away.  Granted, it was 1977 then.   I pursued a different career... but I have always kept this geeky stuff going on around me.  It never hurts to understand how to make electronic things...


myreprapinfo

#18
Feb 10, 2010, 03:15 am Last Edit: Feb 10, 2010, 04:05 pm by myreprapinfo Reason: 1
Great! Thanks everybody for their comments!

I think I just finished the code:

Code: [Select]
/*
Made by Elijah Wood
Based off of Rob Glinka's version
Auto fish feeder
From start up, it will feed fish every 24 hours and change the water every week.
It will send email notifiers to conferm feeding when away from your home.
Made to be used with the Arduino ethernet sheild.
*/

#include <Ethernet.h>
#include <Servo.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xAF, 0xCE, 0xDD }; // whatever mac you want
byte ip[] = { 192, 168, 1, 100 };
byte server[] = { 98, 136, 86, 109 }; // Mail server address  (this is for yahoo's mobile smtp

int time = 5000;

Servo myservo; //declares servo

int LED = 2;
int motor1 = 9;
int relay1 = 8;
int relay2 = 7;
int switch1 = 3;
int switch2 = 4;

unsigned long lastWaterChange = 0;
unsigned long lastFeeding = 0;


void setup()
{
 
myservo.attach(1); //attaches servo on pin 9

pinMode(switch1, INPUT);
pinMode(switch2, INPUT);
pinMode(LED, OUTPUT);
pinMode(motor1, OUTPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);

Ethernet.begin(mac, ip);

Client client(server, 587);  // yahoo's mobile smtp server ip/port

if (client.connect()) {
  client.println("EHLO MYSERVER");
  client.println("AUTH PLAIN *************************************==");  // replace the **'s with your auth info from the perl script.
  client.println("MAIL FROM:<myreprapinfo@yahoo.com>");
  client.println("RCPT TO:<drummerboyx@verizon.net>");
  client.println("DATA");
  client.println("From: <myreprapinfo@yahoo.com>");
  client.println("TO: <drummerboyx@verizon.net>");
  client.println("SUBJECT: FishBot");
  client.println();
  client.println("FishBot has just been activated");
  client.println("Sincerly, FishBot");
  client.println(".");
  client.println(".");
  client.println("QUIT");
                       
  client.stop();
}

delay(1000); //wait 1 seconds before starting program

}

void loop() {
 
 digitalWrite(LED, HIGH); //turns on program light

delay(1000);

if (digitalRead(switch1) == HIGH) {
 digitalWrite(motor1, HIGH);
 delay(4100);
 digitalWrite(motor1, LOW);
 
  Client client(server, 587);
 
if (client.connect()) {
  client.println("EHLO MYSERVER");
  client.println("AUTH PLAIN *******************************************==");  // replace the **'s with your auth info from the perl script.
  client.println("MAIL FROM:<myreprapinfo@yahoo.com>");
  client.println("RCPT TO:<drummerboyx@verizon.net>");
  client.println("DATA");
  client.println("From: <myreprapinfo@yahoo.com>");
  client.println("TO: <drummerboyx@verizon.net>");
  client.println("SUBJECT: FishBot");
  client.println();
  client.println("You have manually fed the fish");
  client.println("Sincerly, FishBot");
  client.println(".");
  client.println(".");
  client.println("QUIT");
  client.stop();

}
}

if (digitalRead(switch2) == HIGH) {
    digitalWrite(relay1, HIGH);
    delay(3000); //wait untill tank fills
    digitalWrite(relay1, LOW);
    delay(500); //stop and wait
    digitalWrite(relay2, HIGH);
    delay(3000); //wait untill tank empties
    digitalWrite(relay2, LOW);
    delay(500); //stop and wait
   
    myservo.write(180); //turns servo w/ water conditioner
    delay(1000);
    myservo.write(0); // puts servo back in nuetral position
   
  Client client(server, 587);
 
if (client.connect()) {
  client.println("EHLO MYSERVER");
  client.println("AUTH PLAIN ****************************************************==");  // replace the **'s with your auth info from the perl script.
  client.println("MAIL FROM:<myreprapinfo@yahoo.com>");
  client.println("RCPT TO:<drummerboyx@verizon.net>");
  client.println("DATA");
  client.println("From: <myreprapinfo@yahoo.com>");
  client.println("TO: <drummerboyx@verizon.net>");
  client.println("SUBJECT: FishBot");
  client.println();
  client.println("You have just manually changed the water in the tank");
  client.println("Sincerly, FishBot");
  client.println(".");
  client.println(".");
  client.println("QUIT");
  client.stop();
}
}




   
 
  if ( (getMinutes() - lastFeeding) > 1440 ) // minutes per day
{
    digitalWrite(motor1, HIGH);
    delay(4100);
    digitalWrite(motor1, LOW);
   
  Client client(server, 587);

if (client.connect()) {
  client.println("EHLO MYSERVER");
  client.println("AUTH PLAIN **********************************************==");  // replace the **'s with your auth info from the perl script.
  client.println("MAIL FROM:<myreprapinfo@yahoo.com>");
  client.println("RCPT TO:<drummerboyx@verizon.net>");
  client.println("DATA");
  client.println("From: <myreprapinfo@yahoo.com>");
  client.println("TO: <drummerboyx@verizon.net>");
  client.println("SUBJECT: FishBot");
  client.println();
  client.println("FishBot has just fed the fish today automaticly");
  client.println("Sincerly, FishBot");
  client.println(".");
  client.println(".");
  client.println("QUIT");
  client.stop();
}

   lastFeeding = getMinutes();
}

 
if ( (getMinutes() - lastWaterChange) > 10080 )  // minutes in a week
 {
    digitalWrite(relay1, HIGH);
    delay(3000); //wait untill tank fills
    digitalWrite(relay1, LOW);
    delay(500); //stop and wait
    digitalWrite(relay2, HIGH);
    delay(3000); //wait untill tank empties
    digitalWrite(relay2, LOW);
    delay(500); //stop and wait
   
    myservo.write(180); //turns servo w/ water conditioner
    delay(1000);
    myservo.write(0); // puts servo back in nuetral position
   
    Client client(server, 587);
   
if (client.connect()) {
  client.println("EHLO MYSERVER");
  client.println("AUTH PLAIN ***********************************************==");  // replace the **'s with your auth info from the perl script.
  client.println("MAIL FROM:<myreprapinfo@yahoo.com>");
  client.println("RCPT TO:<drummerboyx@verizon.net>");
  client.println("DATA");
  client.println("From: <myreprapinfo@yahoo.com>");
  client.println("TO: <drummerboyx@verizon.net>");
  client.println("SUBJECT: FishBot");
  client.println();
  client.println("FishBot has just changed the water in the tank automaticly");
  client.println("Sincerly, FishBot");
  client.println(".");
  client.println(".");
  client.println("QUIT");
  client.stop();
}

    lastWaterChange = getMinutes();
 }
}

// useful variables to keep track of millis overflows
unsigned long millisCounter = 0; // needs to be an unsigned long to store millis's.
unsigned int millisOverflows = 0; // int is plenty, cause the minutes will overflow before this hits unsigned maxint.

unsigned long getMinutes()
{
 unsigned long currentMillis = millis(); // grab the current time, cause it's likely to change during execution.
 // max millis = 4,294,967,294. / 1000 for seconds / 60 for minutes = 71582.788. Not sure if rounding down or up is good?
 // The local timer isn't that accurate, so I guess it doesn't matter. This will gain a minute every 135 days or so.
 unsigned long MAX_MINUTES = 71583;      // how many total minutes are possible before rollover?

 if (currentMillis < millisCounter) {    // did we overflow? If so, increment the counter.
   millisOverflows += 1;
 }

 unsigned long currentMinutes = currentMillis / 60000; // calculate the toal minutes on this millis loop.
 unsigned long overflowMinutes = MAX_MINUTES * millisOverflows; // calculate the total minutes of all previous loops.

 millisCounter = currentMillis;  // keep track of what the millis was.
 return (currentMinutes + overflowMinutes); // return the total of the current + previous loops.
}





It sucsessfully emails me and it runs everything properly.

But...I want to be able to control it manually via my iphone when I'm away. I'm thinking maybe a web app that can tell me the temp/ph/last water change/last feeding and have 2 buttons for manually feeding and water changes.

Has anyone tried to do anything similar to this(sending and receiving data between the iphone and the arduino)?

Thanks,
Elijah

GnobarEl

HI,
i'm also making a fish feeder, can you post some pictures or video from your project?

Thanks!

Paul K

I'd like to see it in action too :)

Paul

myreprapinfo

#21
Aug 04, 2010, 06:21 pm Last Edit: Aug 04, 2010, 06:22 pm by myreprapinfo Reason: 1
Hey guys!!
Ok, my fish feeder has turned into something really crazy now! It feeds my fish, emails me, iphone GUI, live video, light control, temperature, and auto tank change.

Give me an email at drummerboyx(at)verizon(dot)net and I'll send some stuff.

Go Up