Go Down

Topic: Ethernet sheild(W5100) not working with Uno (Read 15898 times) previous topic - next topic

Veeru

Hello,
I am using the W5100 Ethernet shield with the Arduino Uno. I have uploaded the DHCP Address printer code which comes pre installed in the examples. I seem to have a problem connecting to the network.

None of the lights other than the FULLLD led on the shield blink after connecting the ethernet cable. However if I connect the sheild to my PC through a LAN cable and monitoring it using Wireshark I see that all lights blink and there is some communication happening between the PC and the shield.

I tried to debug this issue by placing some Serial.print statements in the ethernet library and i found out that the arduino reads back 0xFF when it tries to search for a socket(value of SnSR register in W5100). Since it does not get a socket it cannot start the DHCP communication.

On further investigation I found that this is the case with the other registers as well. Always the value read back is 0xFF even though a different value is written to the register just before reading.

Since i do not have a SPI protocol sniffer i am unable to determine if this is some SPI issue. I have disabled the SPI for the SD card on the ethernet sheild but still this problem persists. Is this a HW issue with my Uno or with the Ethernet shield. It is difficult to determine physical connections to the chips since they are SMD packages.

Has anyone else faced this problem? and if you have a solution please let me know.

zoomkat

Client test code you can try unmodified to see if you can get a response from the server. If this works, then your hardware and network setup are probably ok.

Code: [Select]

//zoomkat 11-04-13
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test client GET
//for use with W5100 based ethernet shields
//remove SD card if inserted
//data from weather server captured in readString

#include <SPI.h>
#include <Ethernet.h>
String readString;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "api.openweathermap.org"; // myIP server test web page server
EthernetClient client;

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

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600);
  Serial.println("client readString test 11/04/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
  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 /data/2.5/weather?zip=46526,us HTTP/1.1"); //download text
    client.println("Host: api.openweathermap.org");
    client.println("Connection: close");  //close 1.1 persistent connection 
    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
    readString += c; //places captured byte in readString
  }

  //Serial.println();
  client.stop(); //stop client
  Serial.println("client disconnected.");
  Serial.println("Data from server captured in readString:");
  Serial.println();
  Serial.print(readString); //prints readString to serial monitor
  Serial.println(); 
  Serial.println();
  Serial.println("End of readString");
  Serial.println("=======e===========");
  Serial.println();
  readString=""; //clear readString variable

}

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

keithsw1111

Assuming there is not a bug in the code you are using:

There are 3 common problems with cheap chinese clones of these shields ...

1. No ip address and no matter how often you reset it it never sticks ... this seems to be a SPI connection issue. Ensure your shield is correctly seated.
2. No ip address or a random one on start. If you press the reset button and it restarts it works.
3. IP address sticks and when directly connected to a PC it works but through a switch you cannot communicate.

I believe both relate to a widespread issue impacting cheap chinese clones of the arduino ethernet modules which incorrectly include a 510 Ohm resistor network (labelled 511) on the network cable connection instead of the specified 49.9 Ohm resistor network.

In a few days I hope to prove this when some replacement resistor networks arrive and i replace mine.

Veeru

@zoomkat - i found and already tried your code based on previous posts about Ethernet shield problems but it doesn't work since the issue is not with the code but probably with the shield.

@keithsw1111 - thanks for the info. could you pls keep me posted in case you find any solution or if you find out the root issue with the board? i will also try replacing the resistor and see if that works.

SurferTim

Do you have a SD card in the shield's slot?

zoomkat

Quote
I believe both relate to a widespread issue impacting cheap chinese clones of the arduino ethernet modules which incorrectly include a 510 Ohm resistor network (labelled 511) on the network cable connection instead of the specified 49.9 Ohm resistor network.
I've got a couple of clone w5100 based ethernet shields and they all work. Do you have any technical links to board layouts or schematics showing the suspect 510 Ohm resistor so I might be able to check my shields to see if that particular resistor is installed?
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Veeru

I've got a couple of clone w5100 based ethernet shields and they all work. Do you have any technical links to board layouts or schematics showing the suspect 510 Ohm resistor so I might be able to check my shields to see if that particular resistor is installed?

i do not have link to the schematic but i found this pic online. https://www.arduino.cc/en/uploads/Main/ArduinoEthernetShield_R3_Front.jpg
If you see the value of the resistor(the one with 4 legs) just opposite to the ethernet RJ45 connector its 49.9 ohms. The one in my shield has a value 510 ohms.

Veeru

Do you have a SD card in the shield's slot?
no i dont. anyway i disable the sd card slave select in my code.

zoomkat

#8
Oct 07, 2015, 06:07 am Last Edit: Oct 07, 2015, 06:29 am by zoomkat
Quote
If you see the value of the resistor(the one with 4 legs) just opposite to the ethernet RJ45 connector its 49.9 ohms. The one in my shield has a value 510 ohms.
The layout on my clone is somewhat different than the shield in the pix. The resistor (it seems to be four resistors),  on two of my clones has 511 on it, and these shields don't have any issues so far.

edit:

Per the below chart, 510 would be 51 ohms and 511 would be 510 ohms.

http://www.marsport.org.uk/smd/res.htm
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Veeru

The layout on my clone is somewhat different than the shield in the pix. The resistor (it seems to be four resistors),  on two of my clones has 511 on it, and these shields don't have any issues so far.

edit:

Per the below chart, 510 would be 51 ohms and 511 would be 510 ohms.

http://www.marsport.org.uk/smd/res.htm

then i dont know what could be the problem. i guess i will buy a spi sniffer and check the communication between arduino uno and the ethernet shield. its a useful toy to have :)

zoomkat

Quote
then i dont know what could be the problem.
Make sure the ethernet shields are in the proper holes on the arduino. I've had misaligned pins in the past.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Veeru

i got the shield working now. but i dont know what exactly i did to get it working. i just checked the hw connections. and then re inserted the shield into the arduino uno. i am able to get the DHCP discover message on wireshark. but it is not able to connect to my router. i have enabled DHCP on my router. my  pc is able to connect. any ideas about how to resolve this problem?

SurferTim

You see a DISCOVER packet? Do you see an OFFER packet from the DHCP server?

Veeru

i cannot see the OFFER packet from the router.

i shared the wifi connection of my pc over the ethernet port and then connect arduino and monitor using wireshark but no OFFER packet is sent to the arduino by the PC. i can see a bunch of other protocol messages being sent(ARP etc). will this work?

directly connecting the arduino to the router through a LAN cable also does not work. in that case i will not be able to monitor the LAN bus so i bought a LAN splitter(http://www.ebay.in/itm/171919472189?aff_source=Sok-Goog&aff_source=Sok-Goog) but i do not have a test result with the splitter since i need an additonal cable and i am waiting for it to arrive. i tried to connect router with my pc over lan but nothing happens. so i am guessing that i cannot monitor the LAN bus like you can monitor CAN, SPI etc.

as you can see my knowledge about ethernet is limited so pls help me out. if you have any other way of debugging do let me know. tia!




SurferTim

Then that is a network problem. I don't know anything about how you shared your PC connection.

Go Up