im working on a home automated system and the webserver is acting weird

ok heres my code

http://pastebin.com/u0ArQXCZ

when i connect to the 192.168.1.177 it shows something like this http://i49.tinypic.com/2pzffbd.jpg http://i45.tinypic.com/34qwqqf.jpg http://i50.tinypic.com/14trd4p.jpg

and chainges every time you refresh or sometimes it wont even load sometimes it will download a file called download with the contence of

http://pastebin.com/S6BBfEvi

the website is located here http://turnmylightson.no-ip.org/

im using arduino uno with the wizboy ethernet sheild connected through a tl-wr702n chinese router connected as a client to my home router

no serial communication seems to be going on through the arduino ide serial console andsome times it says it can not find the serial port

this code worked a few times before do you think there is a problem with my arduino uno that doing this?

it seems my old code works fine what went wrong with the new code?

http://pastebin.com/73qqMwwt

If this is an Uno, you should leave D10-D13 alone. I see you might have something connected (or plan on it) to D10. A relay maybe?

And this is not right.

Ethernet.begin(mac, ip, gateway, subnet);
// it should be
Ethernet.begin(mac, ip, gateway, gateway, subnet);

The first gateway parameter is actually for the dns server ip, but the gateway works ok if you do not plan on using dns.

thanks for pointing that out im trying it out now it still crashed

and pin 11,12,13,4 will eventually go to the sd card reader while pins 5,6,8,9 are relays and pin 3 is a ir led while pin 7 is a ir receiver i got

Oops! Google Chrome could not connect to turnmylightson.no-ip.org
Suggestions:
Go to no-­ip.­org
Try reloading the page
Search on Google:

it looks like its not connecting to the webserver or not sending the header or something

if i ping 192.168.1.177 it comes back

Pinging 192.168.1.177 with 32 bytes of data:

Reply from 192.168.1.177: bytes=32 time=4ms TTL=128
Reply from 192.168.1.177: bytes=32 time=2ms TTL=128
Reply from 192.168.1.177: bytes=32 time=1ms TTL=128
Reply from 192.168.1.177: bytes=32 time=1ms TTL=128

Ping statistics for 192.168.1.177:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 4ms, Average = 2ms

so its connecting to the arduino so it has to be something with sending the client.write commands to the server

Now I think I understand. Do you have your public ip registered with no-ip? Do you have your public ip interface sending port 80 requests to 192.168.1.177? Can you access the Arduino from the internet by ip address? Does your ISP block port 80 requests to non-commercial ip addresses? Mine does.

turnmylightson.no-ip.org>24.160.73.173>router>192.168.1.177>arduino

no-ip info>Host Type:DNS Host (A)
i can not access it through either turnmylightson.no-ip.org|24.160.73.173|192.168.1.177

i know the noip works because the other skitch i uploaded worked fine

and i tried to add 
byte dns[] = { 
  192, 168, 1, 1 }; // dns server

and

  Ethernet.begin(mac, ip, dns, gateway, subnet);

but i get the error

webserver_home_automation_with_status:35: error: 'byte dns []' redeclared as different kind of symbol
C:\Documents and Settings\Michael\My Documents\Arduino_instalation\arduino-1.0.1\libraries\Ethernet/Dhcp.h:64: error: previous declaration of '<anonymous enum> dns'

as stated before this is the origional one i had that worked fine

http://pastebin.com/73qqMwwt

I was not sure if you meant it worked on the localnet or with no-ip. I use my own server code, and it has proven to be reliable. Maybe looking at it will help you. http://playground.arduino.cc/Code/WebServerST

it looks very similar

So upload mine into your Arduino and check it. I guarantee no viruses or spyware. :D

edit: zoomkat is around somewhere. He has some good server code for stuff like this too.

i did a little bit debugging and this is what is messing up the server

          //start debug
if(readString.indexOf("GET /=0")>=0){
            Relay1status = LOW;
            digitalWrite(Relay1, Relay1status);    
            Serial.println("Lights are off");
          }//end if lightoff

          if(readString.indexOf("GET /?status=1")>=0){
            Relay1status = HIGH;
            digitalWrite(Relay1, Relay1status);  
            Serial.println("Lights are on");
          }//end if lighton


            //read for fan
          if(readString.indexOf("GET /?status=2")>=0){
            Relay2status = LOW;
            digitalWrite(Relay2, Relay2status);     
            Serial.println("Fans are off");
          }//end if fanoff

          if(readString.indexOf("GET /?status=3")>=0){
            Relay2status = HIGH;
            digitalWrite(Relay2, Relay2status);  
            Serial.println("Fans are on");
          }//end fanon


            //read for relay3
          if(readString.indexOf("GET /?status=4")>=0){
            Relay3status = LOW;
            digitalWrite(Relay3, Relay3status);  
            Serial.println("Relay3 iso ff");
          }//end if relay3off

          if(readString.indexOf("GET /?status=5")>=0){
            Relay3status = HIGH;
            digitalWrite(Relay3, Relay3status);      
            Serial.println("Relay3 is on");
          }//end relay3on


            //read for relay4
          if(readString.indexOf("GET /?status=6")>=0){
            Relay4status = LOW;
            digitalWrite(Relay4, Relay4status);  
            Serial.println("Relay4 is off");
          }//end if relay4off

          if(readString.indexOf("GET /?status=7")>=0){
            Relay4status = HIGH;
            digitalWrite(Relay4, Relay4status);  
            Serial.println("Relay4 is on");
          }//end relay4on


            //read for relay5
          if(readString.indexOf("GET /?status=8")>=0){
            Relay5status = LOW;
            digitalWrite(Relay5, Relay5status);  
            Serial.println("Relay5 is off");
          }//end if relay5off

          if(readString.indexOf("GET /?status=9")>=0){
            Relay5status = HIGH;
            digitalWrite(Relay5, Relay5status);   
            Serial.println("Relay5 is on");
          }//end relay5on
//end debug

idk why or how but without it it loads up fine

You do not want to be doing this. Last time I looked at your code, relay5 is D10. That is the slave select for the w5100.

            //read for relay5
          if(readString.indexOf("GET /?status=8")>=0){
            Relay5status = LOW;
            digitalWrite(Relay5, Relay5status);  
            Serial.println("Relay5 is off");
          }//end if relay5off

          if(readString.indexOf("GET /?status=9")>=0){
            Relay5status = HIGH;
            digitalWrite(Relay5, Relay5status);   
            Serial.println("Relay5 is on");
          }//end relay5on

i thought that was pin4

From your code

int Relay5 = 10;

D4 has its own purpose if there is a uSD memory card in the slot. That is the slave select for it. If you never plan on using the uSD slot, you can use D4 for other stuff.

once i have the main interface running and working the sd slot will be for customhtml and css websites but im not the far yet

heres what i have so far thats working i still dont know how to log the relay states with out crashing it i remember somewere that serial.write is faster then serial.println so i replaced the client.println with client.wite

/*
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4
 **relay1 - pin 6   //lights
 **relay2 - pin 5   //fan
 **relay3 - pin 8   //nc
 **relay4 - pin 9   //nc
  **IRled - pin 3 //pwm
 **IRrec - pin 7
  */

#include <SPI.h>
#include <Ethernet.h>
int Relay1 = 6;
int Relay2 = 5;
int Relay3 = 8;
int Relay4 = 9;

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 
  192, 168, 1, 177 }; // ip in lan
byte gateway[] = { 
  192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 
  255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port

String readString;


void setup(){//start void setup
  pinMode(Relay1, OUTPUT); //pin selected to control relay1
  pinMode(Relay2, OUTPUT); //pin selected to control relay2
  pinMode(Relay3, OUTPUT); //pin selected to control relay3
  pinMode(Relay4, OUTPUT); //pin selected to control relay4

  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();
  Serial.println("http://turnmylightson.no-ip.org/ server test 1.0"); // so I can keep track of what is loaded
  // Open serial communications and wait for port to open:
  Serial.begin(9200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }//end while not serial
}//end void setup

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string
          readString += c;

          Serial.print(c); //for debuging

        }//end readString.length
        if (c == '\n') {    //if HTTP request has ended
          //send html data to client
          Serial.println(readString); //print to serial monitor for debuging
              client.println("HTTP/1.1 200 OK"); //send new page
           client.println("Content-Type: text/html");
           client.println();
           client.write("<HTML><HEAD>");
           client.write("<HEAD>");
           client.write("<meta name='apple-mobile-web-app-capable' content='yes' />");
           client.write("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
           client.write("<link rel='stylesheet' type='text/css' href='http://homeautocss.net84.net/a.css' />");
           client.write("<TITLE>Home Automation</TITLE>");
           client.write("</HEAD>");
           client.write("<BODY>");
           client.write("<H1>Welcome To My Home Automation Website</H1>");
           client.write("<hr />");
           client.write("
");
           client.write("<a href=\"/?status=1\"\">Turn On Bed Room Light</a>");
           client.write("<a href=\"/?status=0\"\">Turn Off Bed Room Light</a>
");    
           client.write("
");
           client.write("<a href=\"/?status=3\"\">Turn On Bed Room Fan</a>");
           client.write("<a href=\"/?status=2\"\">Turn Off Bed Room Fan</a>
");       
           client.write("
");
           client.write("<a href=\"/?status=5\"\">Turn On relay3</a>");
           client.write("<a href=\"/?status=4\"\">Turn Off relay3</a>
");    
           client.write("
");
           client.write("<a href=\"/?status=7\"\">Turn On relay4</a>");
           client.write("<a href=\"/?status=6\"\">Turn Off relay4</a>
");    
           client.write("
");

           client.write("</BODY>");
          ("</HTML>");
        
          delay(1);
          //stopping client
          client.stop();

          //control arduino pin
          //read for Light          
          if(readString.indexOf("GET /?status=0")>=0){
            digitalWrite(Relay1, LOW);    
            Serial.println("Light is off");
          }//end if lightoff

          if(readString.indexOf("GET /?status=1")>=0){
            digitalWrite(Relay1, HIGH);    
            Serial.println("Light is on");
          }//end if lighton


            //read for fan
          if(readString.indexOf("GET /?status=2")>=0){
            digitalWrite(Relay2, LOW);    
            Serial.println("Fan is off");
          }//end if fanoff

          if(readString.indexOf("GET /?status=3")>=0){
            digitalWrite(Relay2, HIGH);    
            Serial.println("Fan is on");
          }//end fanon


            //read for relay3
          if(readString.indexOf("GET /?status=4")>=0){
            digitalWrite(Relay3, LOW);    
            Serial.println("Relay3 is off");
          }//end if relay3off

          if(readString.indexOf("GET /?status=5")>=0){
            digitalWrite(Relay3, HIGH);    
            Serial.println("Relay3 is on");
          }//end relay3on


            //read for relay4
          if(readString.indexOf("GET /?status=6")>=0){
            digitalWrite(Relay4, LOW);    
            Serial.println("Relay4 is off");
          }//end if relay4off

          if(readString.indexOf("GET /?status=7")>=0){
            digitalWrite(Relay4, HIGH);    
            Serial.println("Relay4 is on");
          }//end relay4on


            //clearing string for next read
          readString="";
        }//end if HTTP request has ended
      }// end client.avalible
    }//end while client.connected
  }//end if client
}//end void loop

That code does not access Relay5 (D10) like the original code you posted, so it should work ok.

You are not using the uSD card now, but you will be. I highly recommend avoiding D4 until you are ready to use the uSD. But you can't use D10 now. It is already used. It should be manipulated by the ethernet library low level read and write functions after the setup() function.

i think my arduino might just be dying im not getting any serial data at all

Power down the Arduino and remove the ethernet shield. Power it up minus the shield and see if the serial comes back.

i think my arduino is just dying its been giveing me so much trouble the serial data is sometimes glitched alot and now i receave no serial data at all that might be why the code works one minute then stops the next

sory for repost i didnt notice it posted to the 2ed page

no serial even without the ethernet