Hello!
I've been trying to get some code together for an auto fish tank feeder.
Here is the code I have so far:
/*
Made by Elijah Wood
Based off of Rob Glinka's version
Auto fish feeder
It will feed fish everyday 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.
* are used to protect my personal information. You must replace them with your info.
*/
#include <Ethernet.h>
#include <Servo.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xAF, 0xCE, 0xDD }; // whatever mac you want
byte ip[] = {LOCAL IP};
byte server[] = { 98, 136, 86, 109 }; // Mail server address (this is for yahoo's mobile smtp)
Client client(server, 587); // yahoo's mobile smtp server ip/port
Servo myservo; //declares servo
int switch1 = 1;
int switch2 = 2;
int motor1 = 3;
int relay1 = 4;
int relay2 = 5;
void setup()
{
myservo.attach(9); //attaches servo on pin 9
pinMode(switch1, INPUT);
pinMode(switch2, INPUT);
pinMode(motor1, OUTPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
Ethernet.begin(mac, ip);
}
void loop() {
while(true) { //manual water change/feeding
if (digitalRead(switch1) == HIGH) {
digitalWrite(motor1, HIGH);
delay(4100);
digitalWrite(motor1, LOW);
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:<drummerboyx@yahoo.com>");
client.println("RCPT TO:<drummerboyx@verizon.net>");
client.println("DATA");
client.println("From: <drummerboyx@yahoo.com>");
client.println("TO: <drummerboyx@verizon.net>");
client.println("SUBJECT: FishBot feeding");
client.println();
client.println("Fish have been feed today");
client.println("FishBot has sucsessfully emailed Elijah Wood! YAY!");
client.println(".");
client.println(".");
}
}
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
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:<drummerboyx@yahoo.com>");
client.println("RCPT TO:<drummerboyx@verizon.net>");
client.println("DATA");
client.println("From: <drummerboyx@yahoo.com>");
client.println("TO: <drummerboyx@verizon.net>");
client.println("SUBJECT: FishBot water change");
client.println();
client.println("Water change has been accomplished today");
client.println("FishBot has sucsessfully emailed Elijah Wood! YAY!");
client.println(".");
client.println(".");
}
}
}
while(true) { //auto water change
delay(604800000); //wait 1 week from start-up (604,800,000 MS)
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
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:<drummerboyx@yahoo.com>");
client.println("RCPT TO:<drummerboyx@verizon.net>");
client.println("DATA");
client.println("From: <drummerboyx@yahoo.com>");
client.println("TO: <drummerboyx@verizon.net>");
client.println("SUBJECT: FishBot water change");
client.println();
client.println("Water change has been accomplished today");
client.println("FishBot has sucsessfully emailed Elijah Wood! YAY!");
client.println(".");
client.println(".");
}
}
while(true) { //auto feeding
delay(86400000); //wait 24 hours from start-up (86,400,000 MS)
digitalWrite(motor1, HIGH);
delay(4100);
digitalWrite(motor1, LOW);
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:<drummerboyx@yahoo.com>");
client.println("RCPT TO:<drummerboyx@verizon.net>");
client.println("DATA");
client.println("From: <drummerboyx@yahoo.com>");
client.println("TO: <drummerboyx@verizon.net>");
client.println("SUBJECT: FishBot feeding");
client.println();
client.println("Fish have been feed today");
client.println("FishBot has sucsessfully emailed Elijah Wood! YAY!");
client.println(".");
client.println(".");
}
}
if (client.available()) {
char c = client.read();
Serial.print(c);
}
}
}
What I'm trying to accomplish is this; every day my tank will be fed and every week my tank will go through a water change. I want it to send me an email after it does these two actions. For example, it just fed the fish at 7:00 AM and then it will send me a conformation email telling me that they have been fed.
My question: based some of my code off of Rob Glinka's email sender. But I'm not sure how to get auth info for my yahoo account. His version says that it's created via some perl script. Being a beginer in programming; I'm not sure what that is. Can someone help?
Also, if anyone spots any problems with the code, please tell me.
Thanks,
Elijah