I have 6 Arduino Uno Rev 3 with 6 Ethernet Shields mounting chipset W5200: 3 shields are from DFRobot and 3 shields are from SeeedStudio.
I used for both shield the library from SeeedStudio.
Here the strange behavior: both shields (with the same code) are working properly in a network (my office), but in the network where I need to deploy them the behavior is the following:
DFRobot get correctly the IP within few minutes and they work properly.
SeeedStudio shields when doing "Ethernet.begin(mac)" never exit the loop... According to the manual it should stop at a certain point, and then you can attempt to manually set your IP, but that function never ends...
Another attempt was to buy an original Arduino ethernet shield with W5500 chipset and using the original Ethernet.h library, but in that network, the behavior is exactly the same of the SeeedStudio shields.
Again: these shields are working correctly in another network...
For this reason I started to believe that it is not a matter of code or pin configuration, but of the DHCP service which doesn't assign an IP for some reasons, or it replies with something unexpected which blocks the function.
As it is a router provided by my network provider (Fastweb) and we cannot change it, do anyone have any advices on what to test?
The last option is to purchase other three DFRobot shields and make 3 perfectly working shields completely useless...
Thanks for any advices and for your time in reading this post...
I already encountered this kind of issue, and the problem was coming from the sd-card....
Here's what I found on the web:
Important Note!
If an uninitialized SD card is left in the SD card socket of the shield, it can cause problems with code in the sketch that is accessing the Ethernet chip. This may cause symptoms such as the sketch running once or twice, then hanging up.
This is because both the Ethernet chip and the SD card are accessed by the Arduino using the same SPI bus.
If the SD card is not being used with an Ethernet application, either remove it from the socket or add the following code to disable the SD card:
void setup()
{
// disable the SD card by switching pin 4 high
// not using the SD card in this program, but if an SD card is left in the socket,
// it may cause a problem with accessing the Ethernet chip, unless disabled
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
Is the ethernet shield connected directly to the DHCP router, or is it connected to a switch? TP-Link switches have been notorious for causing this kind of problem.
your comment including the following code snippet fixed my issue - amazingly, even though you are referencing the W5200
void setup()
{
// disable the SD card by switching pin 4 high
// not using the SD card in this program, but if an SD card is left in the socket,
// it may cause a problem with accessing the Ethernet chip, unless disabled
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
// other initialization code goes here...
}
I already had the
pinMode(4, OUTPUT);
in my code, but had not set it to high.
I reran the webserver sketch and presto, got some analog output values returned to me.
analog input 0 is 528
analog input 1 is 504
analog input 2 is 526
analog input 3 is 528
analog input 4 is 550
analog input 5 is 549
So it is now working !!!!!
I have never ever had an SD card in the shield but I guess we all ( at least W5100 users) need to use this piece of pretty simple protective code in all our ethernet shield sketches ? It does not seem to matter whether there is an SD card present or not, at least in my case.
The PC dialoguing with the Arduino is also connected to the Switch, but even if I manage to auto-assign an IP to the Arduino, it doesn't communicate...
If this is the problem, what solutions do you suggest (unfortunately considering that I cannot change the network configuration)?
All routers can provide their own individual issues. many have "firewalls" built in, and often you need to check inputs and outputs they allow to pass thru. Most have a default set of "blocks" that could be influencing your throughput. ??
It is strange as it is only a switch, which doesn't do anything (at least in my knowledge)... But the strangest thing is that I tried to switch only the shield: same Arduino, same code, same library, same cable, same MAC address assigned to both boards, same everything... Just changed the Shield, with the DFRobots it works, with the SeeedStudio it doesn't...
Reading more through the Forum I'm afraid I might be in the same situation of this post...
If anyone has other suggestions or advices (rather than physically modifying the resistors of the shield which is out of my skills) he's very welcome...
An SD card in the shield's slot will prevent many UDP functions, including DHCP and NTP from working, and the results are unpredictable. Some times it works, and other times it doesn't.
Are you certain that both shields use a w5200? DFRobot's shield has the PWRDN and RST pins on D8 and D9. AFAIK, the Seeed Studio version does not.
When the DHCP startup fails, does it return fail or never return from the begin function? It takes about 2 minutes for the DHCP startup to return a fail.
In the shield I don't use PINs 0-1-3-8-9-10-11-12-13 (only 2, 5, 6, 7 and the analogic ones)
I'm very certain of the chipsets (see link in the first message and you can doublecheck)
No SD, never inserted, never configured one, never purchased one
Same code in two different shields and it doesn't work. Furthermore the Shiled that "doesn't work" in other two networks (without switch in between) works perfectly.
The Ethernet.begin(mac) function never ends (doesn't fail, simply never ends).
The Ethernet.begin(mac, ip) works, but the device doesn't communicate in the network (nor outside).
Should you need more information feel free to ask! Thank you very much for the time you are dedicating to understand the issue...
Try this test sketch. If the serial monitor shows 192.168.0.2, the SPI bus and the SPI side of the Wiznet IC is working. If it shows anything else, like 0.0.0.0, then you have a SPI bus or hardware problem.
#include <SPI.h>
// you may need to change this include depending on the library you are using
#include <Ethernet.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 Wiznet");
Ethernet.begin(mac,ip);
Serial.println(Ethernet.localIP());
}
void loop() {
}
edit: I use this library. It works with the w5100, w5200, and w5500 by changing a define in utility/w5100.h
I already tried this code, and indeed I see (in my case) 192.168.1.3 (auto assigned IP)...
However this Arduino is "not visible" in the network, meaning that it cannot connect outside with anyone nor anyone can connect with it.
I will try also the Wiznet library just to be sure, but I feel quite comfortable in anticipating that the problem is not with the library or the code, as the same shield + library works very well in a different network...
I'll keep you posted, meanwhile if you have further suggestions I would be pleased to hear them!
Sorry... Bad translation... In Italian "auto" can be used for "self"... I was meaning "self-assigned", i.e. manually assigned...
Let me explain once again in a more clear way everything...
PC and Arduino are ABLE to communicate (doesn't matter the addresses... in one network they are 192.168.1.64 the PC and 192.168.1.177 the shield, in another network 10.10.50.140 and 10.10.50.137, etc.) if I use the DFRobot shield.
The only case in which I'm not able to make them work is with the SeeedStudio shield in a specific network, which uses the Cisco switch... Same source code, same cables, mac address, ports in the switch, etc.
So let's call network 1 the network in which I want the Arduino to work, and network 2 the second network (any other network by the way: my office, my house, my brother's house), and let's call Shield 1 the DFRobot and Shield 2 the SeeedStudio shield:
Network 1 + Shield 1 -> OK
Network 1 + Shield 2 -> NO <-- This is what I don't understand...
Network 2 + Shield 1 -> OK
Network 2 + Shield 2 -> OK
This post seems to be solving the problem, however it requires to modify the ethernet shield physically (soldering resistors to pins), which I am not confident in doing... I was wondering if any other solution is possible...
This post is very old, but recently by "accident" I discovered its solution. Basically I was trusting network cables of the workplace I was working on, but they were improperly patched... In other words the person who created the cables used a random order in the internal wires within the RJ45 connector, making sure that the same order was kept in the other RJ45 at the other end of the cable...
This worked fine for PCs connecting to the router, but Arduino had severe issues in connecting properly in the network, most likely due to interferences...
My take away lesson is: double check cables if you didn't patch them, not only with a PC, but with a device taking precise measurements on interferences...
Hope this will save some time to someone in the future...
Well done indeed, I had givenupo on this project entriely, but will restart it now. Am I assuming that the RJ45 should be STRAIGHT THROUGH or shouldit have pins reversed (which pins n that case)
Thanks again for comingup witha sensiblesoultion, I feelsure it willwork if I can findthe rigbht RJ45 cable in my endless boxes full of old PC cables