Official Ethernet Shield crashes

Hi to all, i'm experiencing with Arduino UNO R2 and the official Ethernet shield R2. When I upload a sketch that uses the ethernet shield, this shield crashes and the LED at pin 13 emits a faint light. I've tried to use the Arduino IDE v1.0, 0023, 0022, 0021 on both windows and linux but without any result.

Maybe this shield hardware is corrupted, and i should buy another shield?

When I upload a sketch that uses the ethernet shield, this shield crashes and the LED at pin 13 emits a faint light.

Maybe this shield hardware is corrupted

That or the code is bad. I'd vote for a code problem. Much cheaper to fix.

and the LED at pin 13 emits a faint light

That is the on/off timing signal that is used by the shield on pin 13.

That or the code is bad. I'd vote for a code problem. Much cheaper to fix.

Well, all the sketches i've uploaded are examples where i've changed only the MAC address to suit with the MAC printed in the WizNet, and them crashes. So i don't think that the problem is the code.

That is the on/off timing signal that is used by the shield on pin 13.

I can't understand this. Can you explain me this more in detail?

I can't understand this. Can you explain me this more in detail?

It means that pin 13 is used by the ethernet shield. Any attempt to use pin 13 for anything else will screw up the communications with the ethernet shield.

Regardless of where you got the code, post it. We don't want to guess what you are doing.

Below is some simple client test code you can try. Don't change the mac address. "and them crashes" doesn't indicate much hope of getting more technical detail of your setup.

//zoomkat 12-08-11
//simple client test
//for use with IDE 1.0
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605 

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan assigned to arduino
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 208, 104, 2, 86 }; // zoomkat web page server IP address
EthernetClient client;
//////////////////////

void setup(){

  Ethernet.begin(mac, ip);
  //Ethernet.begin(mac, ip, subnet, gateway);
  Serial.begin(9600); 
  Serial.println("Better client test 12/01/11"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(myserver, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

Now i'm at school, so I'll test this code this afternoon.

"and them crashes" doesn't indicate much hope of getting more technical detail of your setup

If you are referring to the few technical details that i've provided, i'm sorry but i can't understand the problem because the same sketches were ok two months ago. I've also tryed with another ethernet shield and i get the same results.

Did you try zoomkat's code? Did you see the note in the code about the bug fix? That will cause the Arduino to stay in a "while(client.available())" loop forever.
http://code.google.com/p/arduino/issues/detail?id=605

Well, i've tryed the zoomkat code and it is ok, the output is regular. So i've tryed first to change the MAC address whit my Ethernet Shield address and there isn't any issue. Then i've tryed to start the DHCP procedure by sobstituting

Ethernet.begin(mac, ip);

with

Ethernet.begin(mac);

and the shield crashes. So i think that the problem is the DHCP library.

I've also experienced a loop in receiving data, because i use the linux compiler (i use lubuntu) for avr. But the ethernet shield begins correctly, that was my problem.

So how can I fix this DHCP issue? Maybe i sould review the DHCP library code, or there is an updated version?

Is there a dhcp server on the localnet? If the dhcp part is failing, it is not getting an ip from a dhcp server. It may take around a minute to timeout.

if(Ethernet.begin(mac) == 0)
{
   Serial.println("No dhcp");
}

More test code similar to the first I posted.

//zoomkat 2-13-12
//DNS and DHCP-based web client test code
//for use with IDE 1.0
//open serial monitor and send an e to test
//and to see test result
//for use with W5100 based ethernet shields
//browser equivelant URL: 
//http://web.comporium.net/~shb/arduino.txt
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605 

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;

//////////////////////

void setup(){
  Serial.begin(9600); 
  Serial.println("DNS and DHCP-based web client test 2/13/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  // print your local IP address:
  Serial.print("Arduino IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print("."); 
  }
  Serial.println();
  Serial.println();
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

Well, i think that this image will explain what i meen for "faint light"


By elquero93 at 2012-02-26

In this photo you can see the led at pin13 light emitted when i try to run the last zoomkat sketch. This light is emitted all times that I try to call the DHCP procedure, and is continously emitted up to I unplug the Arduino, so I think that the problem is the DHCP library.

And what did the serial monitor say?
Failed to configure Ethernet using DHCP
or
Arduino IP address: 192.168.0.22

Ohw, I forgot to say that the serial monitor doesn't say nothing, i can only see serial output before

Ethernet.begin(mac);

And how long do you wait for the response? I usually do not quote myself, but...

Is there a dhcp server on the localnet? If the dhcp part is failing, it is not getting an ip from a dhcp server. It may take around a minute to timeout.

I know that the DHCP can take up to some minutes to respond (fortunately i've done the cisco ccna course around networks bases) and each time I try the sketch I wait 5 minutes. I've also seen that with "ipconfig /renew" new leases are released in a very short time, something like 10 - 15 seconds.

fortunately i've done the cisco ccna course around networks bases

Good. Then it should not be difficult for you to assign a static ip to the Arduino. You should know all about ips, subnets, gateways, and dns. Once you assign a static ip to the shield, can you ping the Arduino ip from a localnet computer?

Yes...

OK! Now we are communicating!

It may be a bug in the dhcp routine. Remember, it is brand new.

Does everything you need to work do ok if you use the static ip assignment?

Yes, this is why i think that the problem is the DHCP library!

I think that the only test i could do is to set up a wireshark listener and then check the Arduino DHCP Request packet content, if the arduino sends it. Otherwise the problem isn't the packet but something in preliminar code.