Ethernet shield connection refused by arduino

I just bought myself a ethernetshield from dealextreme with a 5100 chip on it. I managed to put some code on it (the example code for a webserver from within the arduino in the IDE).

/*
  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(178, 116, 1, 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);

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");
  }
}

I adjusted the ip to match my local network. So my pc and the arduino are only connected trough a switch. I tried connecting the arduino directly to my pc and then surfing to the ip which worked fine.

But everytime i try to connect my arduino with the ethernet shield to the switch and try to surf to the ip i get an error that my shield refused the connection.

I also want to note that i can ping the arduino shield from multiple devices (running linux and windows) so i know its online...
Anyone that can help me out?

Does the switch have a router connected to one of the ports?

no only laptops and pc's

IPAddress ip(178, 116, 1, 1);

You have rather special IPs on your local network...
Are you sure this is an IP on the local network? I'm asking because the IP is a public IP used by a Belgian provider. It might be your provider but even in that case it might interfere with other users.

yeah i did some research and found out i was using their network and also the ip i had for my arduino was already in use by them :slight_smile:

but i tried everything on a local network (10.42.0.*) and even then it didnt work out for me

Disconnect everything from the switch except the Ethernet Shield and the PC you're trying to connect with.

As you're using a very common MAC value there might be an address collision.

If that doesn't help, post the output of

arp -an

you execute on the linux machine in your network.

Dumb questions if you've played with networks but worth a 2nd look, I've not done all of them.

Things to check with your board as sometimes they default to un-required settings:

You've set a local IP, is it in same range as PC etc on your network, ie only the last number is different? Not strictly necessary, but it can help.

Do you need disable DHCP? This generates address for devices on network, normally your internet gateway does this, so you need ensure no other device is.

Do you need configure for multiple connections?

Do you need to turn the server on? On port 80?

pylon:
Disconnect everything from the switch except the Ethernet Shield and the PC you're trying to connect with.

As you're using a very common MAC value there might be an address collision.

If that doesn't help, post the output of

arp -an

you execute on the linux machine in your network.

im pretty sure there is no adress collision bc i did an nmap scan on my linux machine... i will try the command you gave me on my linux machine. I already tried only hooking up the linux machine and the server but that didnt help.

I will try to use another mac later today.

AmphenolSensors:
Dumb questions if you've played with networks but worth a 2nd look, I've not done all of them.

Things to check with your board as sometimes they default to un-required settings:

You've set a local IP, is it in same range as PC etc on your network, ie only the last number is different? Not strictly necessary, but it can help.

Do you need disable DHCP? This generates address for devices on network, normally your internet gateway does this, so you need ensure no other device is.

Do you need configure for multiple connections?

Do you need to turn the server on? On port 80?

as for your questions:

  1. yes i did set the local ip with only the last digit being changed
  2. how can i disable the DHCP?
  3. why would i need to configure for multiple connections?
  4. in the code i open the server on port 80 so thats not an issue, it runs perfectly when directly connected to my device

Post the results of your nmap scan. Does you PC have another network interface, like maybe wifi?