Arduino Uno + Wiznet 5100 Ethernet Shield Connection Failed

Hi there,

I need some assistance in troubleshooting issues I am having with the Ethernet Shield. I basically loaded the example the IDE provided. For the server, I change the ip address to one that I know is available and not taken. But When I point the browser to that IP address it won't load. Ping it also failed. I don't know what I am doing wrong. I also tried the Client example as well and connection always failed with latest google.com ip address.

Any idea or suggestion on what I should try to troubleshoot what the problem is?

Thanks in advance,
Jason

hi!

if you use linux as hostsystem for your IDE you may have the same problem like me...

http://arduino.cc/forum/index.php/topic,70700.0.html

...if so, please let me know.

lg oxyl

lg oxyl,

I am using Macbook Pro. I also tried it on Windows 7 and still with the same results. For the Web Server example, it should be as simple as changing the IP address to an available one, right? Is there any steps I might of missed? At this point, I don't know if it's software or hardware problem. I am completely lost and drained. I searched pretty much everywhere.

Any suggestions as to what else to try to track down the problem?

Thanks,
Jason

Are you using a public or private ip? I usually test on a private localnet behind a router.

Here is an example. This is an edited version of the example in the server library.
The localnet is 192.168.2.0/24
The ip I assigned the device 192.168.2.2
The subnet is 255.255.255.0
The gateway is 192.168.2.1

This is a telnet connection, not web. Port 23 is what is used in the library code, so I stuck with that. To connect from a computer on the localnet, I used
telnet 192.168.2.2

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

// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  
//the IP address for the shield:
byte ip[] = { 192, 168, 2, 2 };    
// the router's gateway address:
byte gateway[] = { 192, 168, 2, 1 };
// the subnet:
byte subnet[] = { 255, 255, 255, 0 };

// telnet defaults to port 23
Server server = Server(23);

void setup()
{
  // initialize the ethernet device
  Ethernet.begin(mac, ip, gateway, subnet);

  // start listening for clients
  server.begin();
}

void loop()
{
  // if an incoming client connects, there will be bytes available to read:
  Client client = server.available();
  if (client == true) {
    // read bytes from the incoming client and write them back
    // to any clients connected to the server:
    server.write(client.read());
  }
}

It connects and echos. Not well, but it does.
And it responds to a ping.

SurferTim,

I am doing this all locally.
I just tried your example by modifying the ip address and gateway address. Still no response from telnet nor ping. Both my Arduino Uno and Ethernet Shield are official ones.

All lights are on and blinking. I don't think this could be a hardware defect because this is the second ethernet shield I have tried. Unless I have the worst luck of getting both defective shield.

Anyone else ever seen this problem before or have any other suggestions, please help.

Thanks,
Jason

Finally I got it working!!!!

So the problem is the mac address. Apparently the example ones doesn't work.

I tried one of the mac address from this site and everything works beautifully.

http://itp.nyu.edu/physcomp/Notes/MACAddressesForWiznet

Thanks again!!!

I had some problems with the shield too and tried the above example but for some reason i cant get it to connect. here is my code:
i was wondering if anyone has any ideas. The mac address is from the sticker underneath the arduino.

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

byte mac[] = {0x90, 0xA2, 0xDA, 0x00, 0x6E, 0xFD};
byte ip[] = {192,168,0,14}; // Arduino IP address
byte gateway[] = { 192, 168, 0, 1 };
// the subnet:
byte subnet[] = { 255, 255, 255, 0 };
byte server[] = { 208, 104, 2, 86 }; // zoomkat's web site

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    Serial.println("==================================");
    Serial.println("");
    client.stop();
    for(;;);
  }
}

ive noticed i forgot to include the subnet and gateway for the Ethernet.begin(mac, ip, gateway, subnet) function so i put that in my code, but it still doesn't work.

This worked for me. I had to change the ip address and gateway for my setup.

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

byte mac[] = {0x90, 0xA2, 0xDA, 0x00, 0x6E, 0xFD};
byte ip[] = {192,168,0,14}; // Arduino IP address
byte gateway[] = { 192, 168, 0, 1 };
// the subnet:
byte subnet[] = { 255, 255, 255, 0 };
byte server[] = { 208, 104, 2, 86 }; // zoomkat's web site

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip, gateway, subnet);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    Serial.println("==================================");
    Serial.println("");
    client.stop();
    for(;;);
  }
}

Woohoo! You should recognize that!

dedshaw1612,

Before we go any further. We should first test your Web Server Example.
I wouldn't trust the MAC address from the sticker because it didn't even work for me.

Try this code,

But you need to change the ip address within your router's range.

/*
  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 4 Sep 2010
 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[] = { 0x02, 0xAA, 0xBB, 0xCC, 0x00, 0x01 };
byte ip[] = { 192,168,1, 177 };

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

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // 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();

          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("
");
          }
          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();
  }
}

Then point your browser to 192.168.1.177 Let me know if it loads.

-Jason

When you said point my browser to that ip address, you mean the one i assigned it correct not the one you listed? It wont work for me though. I cannot connect my browser to the ip address i assigned. I wanted to point out one thing though. I jack the shield to an ethernet port in the wall on my campus, but my computer is using wireless. There are 2 different ip addresses when i use ipconfig in command prompt depending if i have my computer use wireless or the ethernet cord. because of that i have tried both addresses in the arduino but with no success. I am hoping this doesnt mean its defective b/c that would be a major pain =(

when i use the ip assigned to the wall port, and then try to connect to that one my browser really tries for like 20secs or so, as opposed to the usual 1 second try and comes back as it couldnt connect me to it. is there anything i have to do on the software side to get this to work or should it start working automatically when i upload the code to the board?

If your wireless IP and Ethernet IP are completely different and not within range, then this is most likely the problem. Try connecting the computer to a Ethernet Port as well that way your IP are in same domain. Also, be sure the IP address you assigned to your Ethernet Shield is not already taken. Try pinging it first, if it doesn't respond, it means its open for use. It's alot easier to test this is in controlled environment like your home where you have full access and control to your router.

I have the similar problem, I can't get it to work, at least not the webserver demo.

Now I tested with this code:

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

byte mac[] = {0x90, 0xA2, 0xDA, 0x00, 0x6E, 0xFD};
byte ip[] = {192,168,5,110}; // Arduino IP address
byte gateway[] = { 192, 168, 5, 1 };
// the subnet:
byte subnet[] = { 255, 255, 255, 0 };
byte server[] = { 208, 104, 2, 86 }; // zoomkat's web site

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip, gateway, subnet);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    Serial.println("==================================");
    Serial.println("");
    client.stop();
    for(;;);
  }
}

My router does detect it, but the serial monitor tells me that it can't connect:

starting simple arduino client test

connecting...
connection failed

disconnecting.
==================================

Any ideas?

resnik,

Try this Webserver example, I also modified IP address to fit Network Configuration. Now point your browser to 192.168.5.110

My main problem was that the Mac address provided in the IDE Example didn't worked on my network. So try that out and let me know what happens.

/*
  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 4 Sep 2010
 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[] = { 0x02, 0xAA, 0xBB, 0xCC, 0x00, 0x01 };
byte ip[] = { 192,168,5,110 };

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

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // 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();

          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("
");
          }
          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();
  }
}

strange, I can't see a webpage, my router does not detect it, yet, I can ping it :roll_eyes:

Yea my router doesn't show the device either. Try resetting it and reprogramming it, I seen this before.

I Reseted Arduino and re-uploaded sketches mutliple times, with no sucess to get webserver working...
TX/RX lights also blink from time to time.

Now I'm runnig out of ideas :roll_eyes:

I have one more thing for you to try. I found this problem with the ethernet shield after getting a new avr-gcc version running last month.
http://arduino.cc/forum/index.php/topic,68624.0.html

This affected all 16 bit register communications with the ethernet shield. Same symptoms as you. Pings ok, but no web client/server response.

The web services count on that for the client.read() function. Those registers contain the counters and buffer pointers for the inbound data from the network/web to the Arduino device.

Well I'm using windows 7 64bit, not linux
Arduino mega 1280 and wiznet w5100 shield

And I doubt that ethernet board is dead ... :roll_eyes: