W5200 Ethernet Shield Not Connecting?

Hi guys,

I recently bought a new W5200 ethernet shield. I plugged it into my mega 2560 and ethernet cable to the router but the Linkled light is red, and I'm not sure what this means.

Anyways I tried running the WebServer example from the Ethernet library, my ip from ipconfig was 100.64.70.215, so I tried 210 and a few others but I always get "server is at 0.0.0.0" from the console (my laptop is connected wirelessly if that matters.)

I tried adding the gateway and subnet to the ethernet.begin thing, but that did not help either.

I went into command prompt and also tried to ping 100.64.70.210 and the other ones I tried but it always says host unreachable.

I tried to check directly my router settings, but I cannot connect to the default gateway which is supposed to be 100.64.64.1 (I keep getting "unable to connect".)

The only problem I could think of is that I'm trying to connect to a school network which might have some security things blocking it. I will try a different network when I get a chance but otherwise what else could be the problem?

The only problem I could think of is that I'm trying to connect to a school network which might have some security things blocking it. I will try a different network when I get a chance but otherwise what else could be the problem?

Your code. Post it.

Are you using a library written for the w5200? The standard Arduino ethernet library is for the w5100.

PaulS:
Your code. Post it.

Sorry for the late reply, I was gone for the weekend. This is it:

/*
  Web Server

 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe

 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(100, 64, 70, 210);

// 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() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // 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("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("
");
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // 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();
    Serial.println("client disconnected");
  }
}

SurferTim:
Are you using a library written for the w5200? The standard Arduino ethernet library is for the w5100.

Hmm that could be the problem too, I am using the one that came with the program.

That is the problem. Last I checked, this library works well with the w5200 IC.

You must download and import this library, then change the include to this:

#include <EthernetV2_0.h>

Thanks, I no longer get the "server is at 0.0.0.0" problem, but when I try to go to the address I put, I get the "connection times out" thing in my browser.

So I'm using the webserver example from the library that you linked.

/*
  Web Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 
 */

#include <SPI.h>
#include <EthernetV2_0.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xFF };
IPAddress ip(100,64,69, 34);

byte subnet[] = {255, 255, 240, 0};
byte gateway[] = {100, 64, 64, 1};

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

void setup() {
 // Open serial communications and wait for port to open:
 Serial.begin(9600);
 pinMode(SDCARD_CS,OUTPUT);
 digitalWrite(SDCARD_CS,HIGH);//Deselect the SD card
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // 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("Connnection: close");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
                    // add a meta refresh tag, so the browser pulls again every 5 seconds:
          client.println("<meta http-equiv=\"refresh\" content=\"5\">");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("
");       
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // 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();
    Serial.println("client disonnected");
  }
}

Using ipconfig my ip I get is 100.64.69.29 (last week it was different) so i changed 29 to 34 in arduino (I also tried a few other numbers as well.)

Putting 100.64.69.34 into my browser gets connection timed out.

If I try pinging it in command prompt I get destination host unreachable.

What subnet mask does ipconfig show for the PC? Is it 255.255.240.0?

SurferTim:
What subnet mask does ipconfig show for the PC? Is it 255.255.240.0?

Yeah, thats what it shows. The gateway I posted is also taken from ipconfig

Does your PC get its IP by dhcp? Have you tried using dhcp on the Arduino to get the network settings? Can you ping it then?