(solved) Arduino Uno Rev. 3 + Ethernet shield W5200

Hello!

I have a question that might appear already solved in the forum but in fact for me it's not...

I purchased an Arduino Uno Rev. 3 original board and an Ethernet Shield W5200 (this model DFRduino_Ethernet_Shield-DFRobot).

I tried my IDE 1.6.1, and also upgraded to 1.6.3, with same results.

I tried updating the library, here:

Then this:
http://www.seeedstudio.com/wiki/images/d/d3/W5200_Ethernet_Shield_Library.zip
(which seems to be the same, but probably the one on GIT is more updated)
Then this:

And also this:

Everything with the proper examples and guidelines, modifications to Ethernet.h files, etc. As suggested by these libraries readme.

I tried both with a direct cable (Category 5) and through a router.

The problem is simply that nothing works! I'm unable to run any example, simply the Arduino is not able to get the IP address from DHCP nor to use an address I specify manually.

I'd like to know if there is something stupid that I'm doing or something I'm overlooking, or if I should assume the board has something wrong...

Thanks for any suggestions in this,
Marco

PS: I'm very new to Arduino

This is the correct library for the w5200. you should unpack it and import it into the IDE. You shouldn't need to change any files in your original w5100 ethernet library.

Import it by selecting "Sketch - Import Library - Add library" and navigate to the folder where you unpacked the library.

Then in any ethernet examples, you must change the include file

// change this
#include <Ethernet.h>
// to this
#include <EthernetV2_0.h>

Hello!

Thanks for your kind reply!

I already tried what you are proposing, but to be sure I doublechecked...

This was the output on the serial monitor when I tried the WebClient example in the ethernet:

Failed to configure Ethernet using DHCP
connecting...
connection failed

disconnecting.

Then try this code. It checks the SPI side of the w5200. If the serial monitor shows 192.168.0.2, then the SPI side is working. If it shows anything else, the SPI side has failed.

#include <SPI.h>
#include <EthernetV2_0.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,2);

void setup() {
  Serial.begin(9600);

  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.println("Starting w5200");
  Ethernet.begin(mac,ip);

  Serial.println(Ethernet.localIP());
}

void loop() {
}

Once again Tim, thank you for your time and kind support.

This is the output:

Starting w5200
255.255.255.255

I'm assuming then that the SPI is failing. I must admit I'm not that expert to understand and correct the problem, but I will investigate in this direction.

If you think that this is a hardware problem, please let me know and I'll contact the vendor. If it is software, any additional test or suggestion is more than welcome!

Thanks,
Marco

It may be hardware. Check the w5200 IC for solder bridges between pins. That has been an occasional problem.

No other devices connected to the Arduino?

Thank you again Tim, I'll try with other Arduino o orther ethernet boards, I should be able to do this within a week...

I don't see any visible melt between pins, once I'll have another board I'll make sure it is this specific sample and not a library problem...

Thanks again!
Marco

More than one user here has verified that Seeed Studio library works with the w5200.

Hello again!

I had no chance to test it yet, but this is a reply from the vendor, when I made the same question. I post it here so it might be of use for other users...

I will also post again to confirm whether this works or not and eventually mark this post as solved...

Marco

Thank you for your inquiry.

It is not your fault. I will write a note on the product page.

It seems that the integrated SPI library in 1.6.X is a little different to 1.0.X one. So the Ethernet shield can‘t work with Arduino IDE 1.6.X.

Please download the newest V1.0.6 and try again. And it is better to check the wiki first. The SPI drive pins should be redefined like what sample code did.

#define

SS    10  //Gadgeteer PIN 6

#define
nRST  8  //Gadgeteer PIN 4

#define
nPWDN 9  //Gadgeteer PIN 5

#define
nINT 3  //Gadgeteer PIN 3​

The only difference in the SPI library is the addition of SPI.beginTransaction() and SPI.endTransaction() functions. They are used to prevent devices using the SPI bus during an interrupt from using the SPI bus while another device is using it outside an interrupt. edit: It also allows devices to have separate SPI settings like bit order and mode.

edit: If you redefine SS as above and use a Mega2560, your code will fail. SS on a Mega 2560 is D53. I checked pins_arduino.h for an Uno and a Mega, and both are defined correctly for each device in IDE v1.6.3. Besides, the SS define is NOT USED to set or clear the w5200 slave select. This is from w5200.h. Where do you see SS used to set or reset the w5200 slave select?

private:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  inline static void initSS()    { DDRB  |=  _BV(4); };
  inline static void setSS()     { PORTB &= ~_BV(4); };
  inline static void resetSS()   { PORTB |=  _BV(4); };
#elif defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
  inline static void initSS()    { DDRB  |=  _BV(0); };
  inline static void setSS()     { PORTB &= ~_BV(0); };
  inline static void resetSS()   { PORTB |=  _BV(0); }; 
#else
  inline static void initSS()    { DDRB  |=  _BV(2); };
  inline static void setSS()     { PORTB &= ~_BV(2); };
  inline static void resetSS()   { PORTB |=  _BV(2); };
#endif

Where did you get that advice? Was that Seeed Studio tech support?

edit2: I imported the EthernetV2_0 library and commented out the "define w5200" in w5200.h, and it compiled and ran fine on my Mega 2560 and w5100 using IDE v1.6.3. No problem at all with the SPI bus.

I am using an Arduino Uno Rev3.

This reply was provided by the vendor of the shield (DFRduino_Ethernet_Shield-DFRobot), but I'm not sure on how to answer to your other questions...

I'll study a bit what you wrote as soon as I have some time and try to answer coherently!

Thanks again!
Marco

PS: The WebServer example in the vendor's wiki seems to work, but I'm trying another example and it doesn't... So I'll follow your indications and see if I have more luck!

I used my server code from the playground because it uses both the wiznet IC and a SD card so I could test the SPI bus. I didn't suggest that for you because it is a little larger than is practical for an Uno.

edit: You can try it though if you wish. It is a good test of the SPI bus. I used the new server code.
http://playground.arduino.cc/Code/WebServerST

Change to these includes.

#include <SPI.h>
#include <EthernetV2_0.h>
#include <SD.h>
#include <utility/w5200.h>
#include <utility/socketV2_0.h>

I still have the same issue, and as I don't have support from the vendor I try again here. The vendor suggested to use version 1.0.6 of the IDE, but I tried version 1.6.3.

I downloaded the SeeeStudio library and I got compilation errors. By changing this:

W5100.setIPAddress(local_ip._address);
W5100.setGatewayIp(gateway._address);
W5100.setSubnetMask(subnet._address);

With this:

W5100.setIPAddress(local_ip.raw_address());
W5100.setGatewayIp(gateway.raw_address());
W5100.setSubnetMask(subnet.raw_address());

In the file EthernetV2_0.cpp

I was able to compile it, but I still got an address that sounds odd... I tried the code that SurferTim suggested to test SPI on Apr 18, 2015, 04:28 pm.

This is the result:
Starting w5200
165.122.87.215

The class of addresses is strange, as the network should be something like 192.168.1.XXX

Any suggestion on where to look or what to change?

Thanks,
Marco

I apologize for the double post... Finally I did it... I used also the indications from the vendor and finally I got the expected reply... This is the code:

#include <SPI.h>
#include <EthernetV2_0.h>

//define the interface: Dreamer MEGA X2 PORT
#define SS    10   //Gadgeteer PIN 6
#define nRST  8  //Gadgeteer PIN 4
#define nPWDN 9  //Gadgeteer PIN 5
#define nINT 3  //Gadgeteer PIN 3

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,2);

void setup() {
  Serial.begin(9600);

  pinMode(SS,OUTPUT);  //Define the interfave :Dreamer MEGA X2 PORT  Gadgeteer PIN 6 use SS
  pinMode(nRST,OUTPUT);
  pinMode(nPWDN,OUTPUT);
  pinMode(nINT,INPUT);  
  digitalWrite(nPWDN,LOW);  //enable power
  
  digitalWrite(nRST,LOW);  //Reset W5200
  delay(10);
  digitalWrite(nRST,HIGH);  
 delay(200);       // wait W5200 work
 
  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.println("Starting w5200");
  Ethernet.begin(mac,ip);

  Serial.println(Ethernet.localIP());
}

void loop() {
}

Thank you SurferTim for your very kind support and the time you dedicated!
Now the output is:
Starting w5200
192.168.1.2

If you downloaded an EthernetV2_0 library and it had these in it, you downloaded an old library.

W5100.setIPAddress(local_ip._address);
W5100.setGatewayIp(gateway._address);
W5100.setSubnetMask(subnet._address);

The new EthernetV2_0 library has these changes already. I supplied the link to the new library in reply#1. Here it is again.

W5100.setIPAddress(local_ip.raw_address());
W5100.setGatewayIp(gateway.raw_address());
W5100.setSubnetMask(subnet.raw_address());

edit: I just checked the library, and it does not do anything about the reset and power down pins.

However, on the Seeed Studio Ethernet Shield V2, the reset and power down pins are not connected to an Arduino digital pin. PWDN (Power Down) is connected to ground, and RESET is connected to 3.3v.

If you use the DFRobot Ethernet shield with the w5200, you must set the RESET (D8 HIGH) and PWDN (D9 LOW) pins.

Check your shield's schematic carefully.

Thanks again for your advices...

This is the very first Arduino project for me, so everything is new. As usual, I'll study what you proposed and see what happens!

Thanks,
Marco

PS: I didn't notice the difference in version of the library, I was sure I was using the library from SeeedStudio, but that was the one linked in the product Wiki... Anyway I tried also the version in Git but for some reason it was not working... Maybe some other steps were missing, like the SPI correct PIN setting.

Hello,

First of all, sorry for refloating this old post but I was looking for exactly the same problem, helped me a lot and just wanted to add my two cents.

I also have the original Arduino UNO and bought a ethernet shield with the new w5200 ethernet IC, like the one in the image:

edit: I just checked the library, and it does not do anything about the reset and power down pins.

However, on the Seeed Studio Ethernet Shield V2, the reset and power down pins are not connected to an Arduino digital pin. PWDN (Power Down) is connected to ground, and RESET is connected to 3.3v.

If you use the DFRobot Ethernet shield with the w5200, you must set the RESET (D8 HIGH) and PWDN (D9 LOW) pins.

Check your shield's schematic carefully.

Indeed, that shield I posted has connected digital pins in the arduino to the w5200 IC as Corben80 posted.
Finally the thing to make it works you need to do is a reset to the w5200 IC as pointed.

  #define PWDN  9  // Connected to GND through a 10k resistor (R13)
  #define nINT  3  // Connected to 3V3 through a 10k resistor (R6)
  #define nRST  8  // Connected to 3V3 through a 10k resistor (R4)
  pinMode(nRST,OUTPUT);
  //the others two pins are not necessary, just there to rememeber how they are connected.
  digitalWrite(nRST,LOW);  //Reset W5200
  delay(10);
  digitalWrite(nRST,HIGH);  
  delay(200);       // wait W5200 work

Somehow the EthernetV2_0 library from seeed studio does not cover this reset action needed for this shield.

Thanks both for the information,

S.

Hi Solano,

sorry to arrive so late, but now it seems that the DFRobots shields are working, but when I use the SeeedStudio original ethernet shields (with or without these additional settings) it doesn't... I was curious about which shield are you using...

Thanks!

I've tried the SeeedStudio v2.2 with no success as well. I have two of these dated Feb 2014

I'm trying with a Leonardo tho.

Since I ONLY have two Leonardo to try, is there an SS pin conflict that I'm not aware of?

I have tried SurferTim's SPI test with no results. Can it be possible that two separate cards (SPI specifically) are bad?

Thanks!

Is it possible you are using a library that doesn't support the w5200? The IDE ethernet library does not support the w5200. This one does with a mod to the w5100.h file.

You must modify the defines in the /utility/w5100.h file.

Change this
//#define W5100_ETHERNET_SHIELD // Arduino Ethenret Shield and Compatibles ...
//#define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield 
#define W5500_ETHERNET_SHIELD // WIZ550io, ioShield series of WIZnet

// to this
//#define W5100_ETHERNET_SHIELD // Arduino Ethenret Shield and Compatibles ...
#define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield 
//#define W5500_ETHERNET_SHIELD // WIZ550io, ioShield series of WIZnet