New network setup, same program, now won't work

I have either a memory or network settings issue.

This code worked fine on these network settings at let’s say location “A”:
ip: 10.0.202.75
subnet: 255.255.252.0
gateway: 10.0.200.1

location “B” is simply a different network of which I also know and control the gateway, now it is just
ip: 192.168.1.
subnet: 255.255.255.0
gateway: 192.168.1.1

Now it won’t work. It has worked at location “B” before, however I had to give back the long ethernet cable I was using to connect to my wireless router. In location “B” I now connect to the switch with a shorter cable versus direct to the wireless router. Cable works otherwise (tried with laptop).

The other difference is I had to migrate my IDE to a new laptop and migrate over my program library files. That must have worked because it doesn’t moan at me about compile errors for the custom X10 library stuff (or any other commands).

Since it worked with no changes other than network setup and this laptop, I’m inclined to believe it has to do with it being hooked up to the switch versus directly to the wireless router.

The only other hint I have seen searching online is that the program might be too large for the Uno R3 memory. It says it sits at 17.5kb out of like 34kb available. Which seems fine, but also seems large one way or another.

I hope somebody can find a stray character or something. Code is below.

/*
  Web Server 
 */

#include <SPI.h>
#include <Ethernet.h>
#include <X10Firecracker.h>
#define RTS_PIN     2                   // RTS line for C17A - DB9 pin 7
#define DTR_PIN     3                   // DTR line for C17A - DB9 pin 4
#define BIT_DELAY   1                   // mS delay between bits (1 mS OK)

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x7B, 0xD4 };
IPAddress ip(192,168,1,75);
byte gateway[] = {192,168,1,1};
byte subnet[] = {255,255,255,0};
byte fireplace = 0;
int indoortempraw = 0;
float indoortempval = 0;
char indoortempvalstr;
int outputpin7 = 7;
int outputpin6 = 6;
int outputpin5 = 5;
int outputpin4 = 4;
byte heaton = 0;
byte acon = 0;
float tempstpt = 0;


// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup()
{
  X10.init(RTS_PIN, DTR_PIN, BIT_DELAY);  //
  Serial.begin(9600);    //  open up serial port connection to PC
  // start the Ethernet connection and the server:
  Ethernet.begin(mac,ip,gateway,subnet);
  server.begin();
  digitalWrite(outputpin7,HIGH);
  digitalWrite(outputpin6,HIGH);
  digitalWrite(outputpin5,HIGH);
  digitalWrite(outputpin4,HIGH);
  pinMode(outputpin7, OUTPUT);
  pinMode(outputpin6, OUTPUT);
  pinMode(outputpin5, OUTPUT);
  pinMode(outputpin4, OUTPUT);
  }
void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    String buffer = "";  //  Declare the buffer variable

    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.print(c);  //  Send every character read to serial port 
        buffer+=c;        //  Assign to the buffer

        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<body background=\"http://i111.photobucket.com/albums/n130/sflemon/ClearBlueBackground.jpg\">");
          client.println("<font color=white><h1 align=center>8204 Shadowstone Ct. Home Command Page</font></h1>");
          client.println("<hr />");
          client.println("<hr />");

          if (digitalRead(8)){  //  1<-- Display LED status
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-green_zps8552e624.png\" width=20 height=20 />");
          }else{
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-red_zps75caf320.png\" width=20 height=20 />");
          }
          client.println("
");
     
          // 2<-- Create a form, control output 8
          client.print("<FORM action=\"http://192.168.1.75/\" >");
          client.print("<P> <div align=left><INPUT type=\"radio\" name=\"status\" value=\"1\">ON" "<INPUT type=\"radio\" name=\"status\" value=\"0\">OFF" "<INPUT type=\"submit\" value=\"  Yellow LED \"></div>" "</FORM>");
          
          if (fireplace==1){  //  1<-- Display LED status
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-green_zps8552e624.png\" width=20 height=20 />");
          }else{
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-red_zps75caf320.png\" width=20 height=20 />");
          }
          client.println("
");
          
          // 2<-- Create a form, control output 7
          client.print("<FORM action=\"http://192.168.1.75/\" >");
          client.print("<P> <div align=left><INPUT type=\"radio\" name=\"status2\" value=\"1\">ON" "<INPUT type=\"radio\" name=\"status2\" value=\"0\">OFF" "<INPUT type=\"submit\" value=\"  Red LED \"></div>" "</FORM>");
          client.println("
");
          //client.println("Indoor Temperature: ");
          //client.println(indoortempval,4);
          client.println("
");
          client.println("<P> <div align=left><img src=\"http://wwwcache.wral.com/asset/weather/doppler5000/2006/08/07/1001059/ice_2011_dd5k_wake-640x480.jpg\" width=480 height=360 />" "<img src=\"http://wwwcache.wral.com/asset/weather/2008/04/22/2774561/ice_2011_forecast_7day_wral_raleigh-600x450.jpg\" width=480 height=360 />");
          client.println("
");
          
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
          buffer="";       //  Clear the buffer at end of line
        } else if (c == '\r') {            
          if(buffer.indexOf("GET /?status=1")>=0)
            digitalWrite(8,HIGH);  // Catch ON status and set  Yellow LED
          
          if(buffer.indexOf("GET /?status=0")>=0)
            digitalWrite(8,LOW);  // Catch OFF status and set Yellow LED
            
           if(buffer.indexOf("GET /?status2=1")>=0){
          X10.sendCmd( hcA, 2, cmdOn );
          fireplace=1;
           }
    
          if(buffer.indexOf("GET /?status2=0")>=0){
          X10.sendCmd( hcA, 2, cmdOff );
         fireplace=0;
          }
             
          indoortempraw = analogRead(A0);
          indoortempval = (float(indoortempraw)/1023.0*257.0);
          if(indoortempval>(tempstpt+3)){
            acon = 1;
          }
          if(indoortempval<(tempstpt-3)){
            heaton = 1;
          }
          if(acon == 1){
            digitalWrite(outputpin7,LOW);
            digitalWrite(outputpin6,LOW);
          }
          if(heaton == 1){
            digitalWrite(outputpin7,LOW);
            digitalWrite(outputpin5,LOW);
          }
        }
        else {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    
  }
}

If you are running out of memory, try using the F() macro like below on the static text strings.

          client.println(F("HTTP/1.1 200 OK")); //send new page
          client.println(F("Content-Type: text/html"));
          client.println();

          client.println(F("<HTML>"));
          client.println(F("<HEAD>"));
          client.println(F("<TITLE>Arduino GET test page</TITLE>"));
          client.println(F("</HEAD>"));
          client.println(F("<BODY>"));

          client.println(F("<H1>Zoomkat's simple Arduino button</H1>"));
          
          client.println(F("<a href='/?on'>ON</a>")); 
          client.println(F("<a href='/?off'>OFF</a>")); 

          client.println(F("</BODY>"));
          client.println(F("</HTML>"));

I have mentioned this once already today. The other user said "this works", and now you say it used to work and now doesn't. He just hasn't moved his Arduino to another network yet. ;)

// this is incorrect for V1.0 and later
Ethernet.begin(mac,ip,gateway,subnet);
// it should be
Ethernet.begin(mac,ip,gateway,gateway,subnet);

If the netmask is used for the gateway, the Arduino will not be able to route packets out that gateway, so would only be available on it's localnet, and no others.

I hooked my laptop up to the switch that lies between the wireless router and the project. I was not able to have connectivity with the laptop. Looking at this now, and how the wireless router is designed, I would have to have an extra cable between the wireless router ports and the switch which I do not have.

Instead I took the time to move the project and plug it into the wireless router, works now.

Otherwise, yes, I have had issues running out of memory, and have not tried F() yet. Just today, I noticed it got very buggy or totally non-responsive to webpage input if I added my field for "Indoor Temperate: somefloat". I will work with the F() functionality and see if that helps me.

If I want a 'larger' or 'nicer' webpage to interface with, should I consider going to the SDcard based webserver or something else altogether?

I feel I'm already at the end of the rope here with just a few radio buttons.

Will the F() functionality save me a ton of memory?

I want the webpage to have: -20 radio buttons -about 5 float pt number displays -several user text and float input fields

Also, when viewing html tutorials I notice the syntax here is very different. What gives with the vast amount of quotes " " and \/ forward or backslashes present in the arduino client.print commands?

for print control.. Embedded C and C++ print statements use different syntax than non embedded code does. Among other things.