Ethernet shield connection problem

NOTE: I have to remove the URLS in the code because this server thinks it’s spam, so don’t mind the funky ethernet println that seems strange, it’s not where it crashes anyway.

Hi,

I’m just starting out, i’m a seasonned senior programmer but definitely not an electronician, thats why arduino seduced me at first.

I just got an DFRobots Ethernet Shield and LCD Shield, LCD works fine, but i can’t seem to make the ethernet work correctly. It is a problem of connecting, so the most basic one out there.

My home gateway/router/switch info is:
ip: 192.168.1.1
subnet: 255.255.255.0
brand/model: linksys/wrt54g

And i’m sure there are no devices with the mac address or ip address like configured in the script.

#include <Ethernet.h>

byte mac[] = {0x2E, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[] = {192, 168, 1, 177};
byte gateway[] = {192, 168, 1, 1};
byte netmask[] = {255, 255, 255, 0};

byte server[] = {174, 120, 8, 130}; // CrazyCoders

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip, gateway, netmask);
  Serial.begin(9600);

  delay(1000);

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

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET  HTTP/1.1"); 
    client.println("Host: ");
    client.println("Content-length: 0");
    client.println("User-Agent: Arduino/1.1");
    client.println();
  } else {
    Serial.println("connection failed");
    Serial.println(client.status(),DEC);
  }
}

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

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

This is pretty much the example taken from the website adapted to my own website. I have nothing in my server logs.

My setup is simple, a wire coming out of the 10/100/1000 dlink switch going straigth into the arduino like all other devices in my house that are on wire. No funky internet connection sharing, just the plain basic router before the arduino (and a physical 10/100/1000 switch).

Wire is tested, it works on other machines, namely this machine i’m typing from wireless instead right now.

What i get returned by the serial monitor is the following:

connecting...
connection failed
0

disconnecting.

Thanks for wathever help you can provide

I think i’m going to ask DFRobots a reason for this.

I found out after digging through countless websites that someone had the same problem when stacking both the LCD and Ethernet shields on the same arduino.

Surprise, i tested it and without the LCD shield, everything works fine. I just had to follow that other guys recommendation and rip off some of the connectors on the LCD shield namely PINS 13, 12, 11 and 10. Why? I don’t know… Have i ripped off more than i’m supposed, i don’t think so, both the LCD and ethernet are now working.

Strange… I’ll keep this post up to date so you know what is happening with this issue.

namely PINS 13, 12, 11 and 10. Why? I don't know...

Pins 13, 12, and 11 are used by the hardware SPI module of the AVR (clock, datain, dataout), and pin 10 is used as the "chip select" for Wiznet ethernet chip. Trying to use these simultaneously with some non-spi peripheral would be ... very unlikely to work. I also recall that there are some issues getting the SPI pins that SHOULD be sharable with other SPI devices to work correctly, due to some bug in (some versions of?) the Wiznet chip (this is why the SD card is not populated on the official Ethernet board.)

Oh well, i claimed victory too soon it seems, it was probably something else althought it never seemed to work when the LCD was on it…

Now it seems that from time to time it will stop connecting to anything outside, but if i stimulate it with a local address connection, it seems to always make it work…

Seems DFRobot is only japanese, at least their site is unless i didn'T look at the right place.

It really seems, after playing a lot with it, that the shield results in completly random successes...

I'm going to make a connection counter and let it run all night with a delay between connections to see how many times i'll be able to connect and when it will fail...

All right, after almost 10h of automatic connection testing, it seems pretty good.

12 megs of data transfered in 762 tries, 1 failure total. Pretty stable :)

We can mark this topic closed!