I have a sketch to send emails over the internet (I will replace some code with xxxx because I don't want any one seeing my information, not that i don't trust you guys :P) Anyways, the sketch works fine for several hours before it stops working. Its strange because it still returns a ping though it doesn't work. heres my sketch--
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
192,168,1,177 };
// Enter the IP address of the server you're connecting to:
byte server[] = {
xxx,xxx,xx,xxx};
boolean open=false;
boolean oldOpen=false;
// Initialize the Ethernet client library
// with the IP address and port of the server
Client client(server, 25);
void setup() {
pinMode(3, INPUT);
pinMode(7, OUTPUT);
digitalWrite(7,HIGH);
// start the Ethernet connection:
Ethernet.begin(mac, ip);
// start the serial library:
Serial.begin(9600);
// give the Ethernet shield a second to initialize:
delay(1500);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect()) {
Serial.println("connected");
}
oldOpen=digitalRead(3);
}
void loop(){
// if the server's connected
if (client.connected()) {
//Serial.println("connected");
open=digitalRead(3);
digitalWrite(7,LOW);
if(open==oldOpen){
}else{
oldOpen=open;
if(open==true){
//open
Serial.println("open");
client.println("EHLO MYSERVER");
client.println("MAIL FROM:xxxx@xxxxx.net");
client.println("RCPT TO:xxxxxxxxxx@messaging.sprintpcs.com");
client.println("DATA");
client.println("SUBJECT: The garage door has been opened");
client.println();
client.println(".");
client.println(".");
}else{
//close
Serial.println("close");
client.println("EHLO MYSERVER");
client.println("MAIL FROM:xxxx@xxxxx.net");
client.println("RCPT TO:xxxxxxxxxx@messaging.sprintpcs.com");
client.println("DATA");
client.println("SUBJECT: The garage door has been closed");
client.println();
client.println(".");
client.println(".");
}
}
delay(1000);
}else{
digitalWrite(7,HIGH);
client.connect();
}
}
I have it set up using a reed switch to monitor my garage door. The switch works great and the code is fine without the Ethernet part (I just got the Ethernet shield after my Wifi shield bit the dust). I have the shield connected to an old router which I loaded gargoyle custom firmware on to use as an access point. I know that this works great with my computer, I used if for weeks without a problem so I don't think this would affect the arduino but I'm not really sure. Any ideas?