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...
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>
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.
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!
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.
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?
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.
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.
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:
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?
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
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.
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.
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.
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...
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