Go Down

Topic: (solved) Arduino Uno Rev. 3 + Ethernet shield W5200 (Read 7110 times) previous topic - next topic

corben80

Apr 18, 2015, 04:34 pm Last Edit: Apr 24, 2015, 12:25 am by corben80
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 http://www.dfrobot.com/wiki/index.php/DFRduino_Ethernet_Shield).

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

I tried updating the library, here:
https://github.com/Seeed-Studio/Ethernet_Shield_W5200
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:
https://github.com/Wiznet/WIZ_Ethernet_Library
And also this:
https://github.com/jbkim/W5200-Arduino-Ethernet-library

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


SurferTim

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.
https://github.com/Seeed-Studio/Ethernet_Shield_W5200

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
Code: [Select]
// change this
#include <Ethernet.h>
// to this
#include <EthernetV2_0.h>






corben80

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.

SurferTim

#3
Apr 18, 2015, 06:28 pm Last Edit: Apr 18, 2015, 06:28 pm by SurferTim
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.
Code: [Select]
#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() {
}

corben80

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

SurferTim

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?

corben80

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


SurferTim

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

corben80

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

Quote
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.


Code: [Select]

#define
 SS    10   //Gadgeteer PIN 6

#define
 nRST  8  //Gadgeteer PIN 4

#define
 nPWDN 9  //Gadgeteer PIN 5

#define
 nINT 3  //Gadgeteer PIN 3‚Äč


SurferTim

#9
Apr 20, 2015, 02:26 pm Last Edit: Apr 20, 2015, 10:09 pm by SurferTim
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?
Code: [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.

corben80

I am using an Arduino Uno Rev3.

This reply was provided by the vendor of the shield (http://www.dfrobot.com/wiki/index.php/DFRduino_Ethernet_Shield), 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!

SurferTim

#11
Apr 21, 2015, 01:58 pm Last Edit: Apr 21, 2015, 02:13 pm by SurferTim
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.
Code: [Select]
#include <SPI.h>
#include <EthernetV2_0.h>
#include <SD.h>
#include <utility/w5200.h>
#include <utility/socketV2_0.h>




corben80

#12
Apr 24, 2015, 12:19 am Last Edit: Apr 24, 2015, 12:33 am by corben80
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:
Code: [Select]

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


With this:
Code: [Select]

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

corben80

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:

Code: [Select]
#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

SurferTim

#14
Apr 24, 2015, 02:13 am Last Edit: Apr 24, 2015, 05:21 am by SurferTim
If you downloaded an EthernetV2_0 library and it had these in it, you downloaded an old library.
Code: [Select]
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.
https://github.com/Seeed-Studio/Ethernet_Shield_W5200
Code: [Select]
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.

Go Up