I have recent bought an Ethernet Shield for the arduino for use in a renewable energy project. I have written a small test sketch which every 200 milliseconds sends a number which is incremented at the end of each loop. The problem I'm having is that sometimes (seeemly completely random) the packets will not send. I dont just mean missing a few i mean after one reset each one will send fine but then another time the USB cable is plugged in they wont send at all. I was wondering if some collisions or something is taking place. When theyre not sending a green LED marked 'L' on the shield comes on, but this can even happen when the ethernet cable is not plugged in. Is it a code error or a hardware error?
You'd better linked to a datasheet than to just a picture. From what I see on the picture I guess that the 'L' means link detected. This is not switched by software but by the chip itself. In my experience a failing link often means cabling problems. Replace your network cable (take a cat 5 to stay on the save side) and try again. What does the other side of the network cable (probably a switch) mean? Is the link going down there too?
'L' is not link on this board, thats at the other side of the RJ45 socket and that lights up fine. The problem even persists when theres no cable plugged in. I noticed on this board there is no collision LED and wondered if that's what the LED represented?
Yes, removing it will stop the fail, but I like to get stuff set up correctly the first time. Just disable it for now.
void setup()
{
// disable the microSD card SPI
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
// now do your ethernet setup stuff
}
edit: The 'L' led is connected to the SPI clock pin. When you have the microSD card in the slot, that is the SD card stepping all over your w5100/w5200 UDP send. Mine glows dim with the microSD card in the slot and not disabled.
The 'L' LED is still lit up bright green. I understand what you mean by it glowing dim because on the occasion that the packets are sent out, i get the same.
I used the command prompt and typed ping 192.168.1.126 and i got the following:
Pinging 192.168.1.126 with 32 bytes of data:
Reply from 192.168.1.126: bytes=32 time=11ms TTL=128
Reply from 192.168.1.126: bytes=32 time=7ms TTL=128
Request timed out.
Reply from 192.168.1.126: bytes=32 time=3ms TTL=128
Ping statistics for 192.168.1.126:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 11ms, Average = 7ms
Then the green LED went dim and it started working :S I got this ping response:
Pinging 192.168.1.126 with 32 bytes of data:
Reply from 192.168.1.126: bytes=32 time=3ms TTL=128
Reply from 192.168.1.126: bytes=32 time=4ms TTL=128
Reply from 192.168.1.126: bytes=32 time=4ms TTL=128
Reply from 192.168.1.126: bytes=32 time=6ms TTL=128
Ping statistics for 192.168.1.126:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 6ms, Average = 4ms
It can even send UDP data for about 10 minutes and then the 'L' LED comes on again and it will stop sending and vice versa. I wish i had a solution. It's very random when it works and i can't seem to change it. I wonder if its a problem with the shield?
Is it the time or the number of iterations that cause the fail? If you double the time between sends, does the time before fail double also? Or does it fail about the same time?