Go Down

Topic: Ethernet Shield troubles (Read 5018 times) previous topic - next topic

3d0g

Dec 11, 2011, 07:35 pm Last Edit: Dec 11, 2011, 07:42 pm by 3d0g Reason: 1
I use BoArduino for my Arduino work because I prefer breadboards. I do however have a WickedProto Shield adapter for the odd occasion I want to play with "standard" Arduino shields, and it has always worked great in the past. Last weekend I picked up an Ethernet Shield from Radio Shack (want to support their new Arduino efforts) and I'm having zero luck getting it going.

Running the DHCP Chat Server example sketch in Arduino 1.0, the serial monitor shows it waiting indefinitely for a DHCP address (network is tested and valid). If I comment out the DHCP initialization and use static parameters, Ethernet.localIP() always returns 0.0.0.0.

Any ideas?


zoomkat

Below is some ethernet test code that you can try. Youmay need to change the assigned lan ip to match your setup.

Code: [Select]

//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

#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
//Client client(myserver, 80);  // connect to web server using port 80
EthernetClient client;
//////////////////////

void setup(){

  Ethernet.begin(mac, ip);
  //Ethernet.begin(mac, ip, gateway, subnet);
  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

}

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

3d0g

Better client test 12/01/11
Send an e in serial monitor to test
connection failed


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


Which is as expected as Ethernet.begin is failing to initiate the shield. This is why Ethernet.localIP is returning 0.0.0.0 in my code. Now the question is, is this because the Ethernet Shield is somehow incompatible with BoArduino or is this shield defective...

3d0g

Don't know if this is significant but the W5100 chip gets pretty warm on my Ethernet Shield.

zoomkat

The w5100 does run on the hot side, apparently normal.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

3d0g

No other ideas, I take it...

I've now tested this thing on multiple networks and even tried crossover cables direct to my laptop. Even sniffed the traffic and absolutely nothing comes out of the Ethernet Shield when attempting DHCP so I'm thinking its a bum unit. Guess I'll swap it out at RS.

zoomkat

Quote
Even sniffed the traffic and absolutely nothing comes out of the Ethernet Shield when attempting DHCP so I'm thinking its a bum unit.


Is your UNO recognized when it is plugged into a router?  When I run the code my netgear router provides the IP and I can see the wiznet in the connected devices.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

3d0g

I'm not using an UNO, but no the Ethernet Shield is never seen by the network and does not appear in the ARP table. Using code which would initiate a DHCP request hangs at Ethernet.begin(mac) indefinitely. Statically assigned IP via Ethernet.begin(mac, ip, gateway, subnet) does complete but Ethernet.localIP() always returns 0.0.0.0 and the Shield still never appears in ARP.

zoomkat

Quote
I use BoArduino for my Arduino work because I prefer breadboards. I do however have a WickedProto Shield adapter for the odd occasion I want to play with "standard" Arduino shields, and it has always worked great in the past.


After rereading the above, I suspect that is where your problem is and not the ethernet shield from RS.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

3d0g

As Arduino is Open Source Hardware, that would be unfortunate, if true.

PaulS

Quote
As Arduino is Open Source Hardware, that would be unfortunate, if true.

If it is true, and I would tend to agree that it possibly is, all that it means is that the problem is with your "Arduino", not with the Rat Shack shield.

You would then need to look more closely at your hardware.

3d0g

While I'm new to this forum, and it's easy to assume the newbie doesn't know much, I can assure you this isn't my first time around the workbench. Even won some design awards many moons ago in Nuts and Volts...

I was hoping someone had some advice on validating proper Ethernet Shield operation at the SPI level as the Arduino Ethernet library, even in 1.0, does a very poor job of providing feedback on what's happening inside the w5100. This may be beyond the scope of the regulars here though, I'm guessing. I'll pop over to adafruit's board and see if anyone there has messed with the 'duino Ethernet Shield.

Thanks for trying.

PaulS

Quote
This may be beyond the scope of the regulars here though, I'm guessing.

Actually not. SurferTim has delved into the mysteries of the ethernet shield as much as anyone, and uncovered and corrected a few insidious bugs.

3d0g

#13
Dec 19, 2011, 05:42 pm Last Edit: Dec 20, 2011, 02:54 am by 3d0g Reason: 1
Just to close out this thread - SurferTim did indeed point out the key fact I kept overlooking:
Quote
Arduino communicates with both the W5100 and SD card using the SPI bus (through the ICSP header).

Running jumpers from pin 11 on the protoboard to ICSP pin 4, 12 to ICSP 1 and pin 13 to ICSP 3 has the board working as expected.

So, anyone using arduino clones that don't have an ICSP header should note the Ethernet Shield does not have the standard SPI pins (11-13) wired.

SurferTim

...and the Mega owners should take note also. Since pins 11-13 are not wired, they are available for general use without interfering with the ethernet shield. The Mega does not use those pins for SPI. :)

Go Up