FIXED IT. There were a couple problems. I tried the sample UDP sketch that was in the ethernet v2 library, and it worked. Examining the code more closely, I found that the following line was different from my sketch. I had this:
…but had to change it to this:
But this was only half the problem. For some reason, we have to mess with the SD card enable/detect pins. Pin 4 must be set to HIGH on setup. To summarize, I had to have the following lines…note that I already had the W5200 line, just not the SDCARD line:
#define W5200_CS 10 // (this is presumably not necessary since it doesn’t get called in my sketch)
#define SDCARD_CS 4
Then in my setup function, I had to have this:
digitalWrite(SDCARD_CS,HIGH);//Deselect the SD card
One thing that was messing me up is that I saw a sketch somewhere that had the above two lines, but referenced W5200 instead of SDCARD. I should have known that documentation was suspect, because the comment didn’t make sense either (“deselect W5200”…whaaa?)…but it was from a Seeedstudio official page or example, as I recall. I’m also a bit puzzled as to why the sketch compiled OK with just “#include <EthernetUdp.h>” when EthernetUdp.h doesn’t even exist anymore (like I said, I removed my old ethernet library).
Sure wish they had a “barebones” version of the ethernet shield that did just…ethernet. But it’s fine now that I am aware of the SD card issue. Perhaps I will use the card for logging flight data or something…
The AWESOME news is that my instrument is communicating flawlessly now! As far as I can tell, my entire original problem was caused by this junk ebay no-name ethernet shield. The Seeedstudio v2 looks as though it will perform as fast and rock-solid as the v1 I used on an altimeter last year (100% perfect performance, zero maintenance/tweaking, throughout many “flight” hours). I plan to use only the Seeedstudio ethernet shields from now on.
And fortunately my local RadioShack has more of these bad boys at $12.49 a pop…off I go to RS again after work tomorrow!
Previous post follows**
And another puzzling twist: today I took advantage of the smokin’ deals my local (soon to close) RadioShack has going, and cleaned out a bunch of their Arduino goodies. I got the Seeedstudio version 2 ethernet shield and decided to try it with my troubled arrangement discussed previously.
I changed the following line:
I also found I had to remove my old Ethernet library and just have EthernetV2_0 in my libraries directory. I did not touch any other part of my code, as the Seeedstudio wiki indicated the new shield should work with old sketches, except for the change above to reference the new library.
The shield responds to ping, but I am unable to communicate via UDP. Specifically, Udp.parsePacket() never returns anything. I have been scouring the web for examples, but so far I see no differences in usage of the v2 shield vs the old one. Has anyone run into this with the latest Seeedstudio ethernet shield?
On the plus side, the shield seems to respond to ping faster, and it has also resolved an annoying issue I was having where the Arduino would frequently drop its USB connection and I would have to unplug/replug it to get my USB/serial debugging back. (No more junk Chinese ebay ethernet shields for me.) I am very hopeful that my original issue will also be resolved, if I could just get the crazy thing to talk!