Jim Schrempp


Arduino Notes: Ethernet Shield

 

 

Other Rants and Raves

 

October 2009 -

I wanted to give my Arduino a connection to the internet. Again, what to buy? A shield is a board that is meant to plug directly on top of the Arduino board. A shield has pins on the underside to fit the connectors on the Arduino that sits below it. A shield also has female connectors on top of it so that another shield could plug into it. I guessed that I needed an Ethernet shield.

I bought one from AdaFruit. I had to solder it together, but it was easier than I expected. To complete the shield I also had to buy the Ethernet module itself. Adafruit and others talk about the XPort Module and the WIZnet 811MJ.

Two big differences stood out to me: XPort does DHCP but requires custom libraries; WIZnet requires a fixed IP but uses standard Arduino libraries. The references I found all said, "XPort is old, WIZnet is the way to go." But all these same sites then had tons of information on the XPort and none on the WIZnet !

I bought the WIZnet. Assembled it looks like this photo from AdaFruit.

Shields are made to plug into the Duemilanove board, but I have a BBB board. You can see how they don't look the same at all. My BBB doesn't have the connectors that the shield needs. See them below.

BBB from ModernDevice.com

Duemilanove from Arduino.cc

Blowing up a capacitor

There's no how-to for the shield. On to experimentation that didn't work. Eventually I found the schematic for the shield on the adafruit site in a section called "downloads." Silly me to not look there right away.

I read that shields can take some goodly amount of power so I switched my BBB jumper to put the external power supply directly to the bread board rails. BANG! Huh? A capacitor blew out. Oh, the BBB will take up to 12vdc. I found a wart from an old X10 camera and was using that. Unfortunately the shield only takes up to 6vdc. Crap.

Back to Fry's to buy an AC/DC adapter that outputs 6vdc and a new capacitor. Put them in place and still nothing. Using my old Radio Shack voltmeter I discovered that the output of the little voltage regulator was 0; I guess I blew that out too. Luckily LadyAda had a great parts list. Fry's didn't have the exact one, so I bought it on line from Digikey. I soldered that one in, hooked up a LAN cable and the lights, the lights! They started to blink!!

It Lives!

So with power working, I had to figure out which of these many pins on the shield are actually needed. Again, no documentation to give me any good idea. I really expected the shield site to document what was needed to make it run. No luck. Time to experiment.

I hooked up a LAN cable between my shield and my nearby network switch. I modified the sample WebServer program (sketch) to set the IP address to 10.10.10.177 (my home network is 10.10.10.x). I opened a DOS window on my laptop and started a continuous ping

     ping 10.10.10.177 -t

The ping kept coming back with a timeout.

The shield has pins labeled Txn and Rcv so I naturally thought those might be the ones I need. Wrong.

Eventually I re-read this on Arduino.cc and it stuck: "Arduino uses digital pins 10, 11, 12, and 13 (SPI) to communicate with the W5100 on the ethernet shield." I connected those 4 pins between the two boards. Still nothing.

There's a reset on the BBB and on the shield. What order do they need to be reset? One time, just by chance, I pressed them both at almost the same time. Bingo!!! My ping test window starting showing returns. I screamed for joy.

Twice For Good Luck

I opened a browser and went to http://10.10.10.177  The window went blank, showing that the shield did respond, but no content.

I opened Wireshark (another excellent tool) on my laptop to monitor what was going on. Once you start a Wireshark capture you can set a filter to see just the traffic involving your shield:

     ip.addr == 10.10.10.177

I could see that my PC opened a TCP connection with a SYN and the shield responded with SYN-ACK. Then the PC sends the HTTP GET, which ends with 0d 0a 0d 0a, which is \n \r \n \r, which is newline, carriage return, newline, carriage return. The WebServer code waits for a connection, then reads characters until it finds a blank line;  \n \r \n \r is just that. Still, nothing from my WebServer showing up in the browser.

Who knows why, but one time I clicked refresh in the browser twice in a row and the second time the browser got a page with some information in it. I haven't figured that out yet. Maybe next week I'll get to that.

 

I hope this helps you.

 


       

 


Jim Schrempp is a sometimes freelance writer (only Vanity Press will publish his work) living in Saratoga, California. His writings have appeared on numerous pages on his own web site. The opinions expressed in this piece are those of the writer and do not necessarily represent those of anyone else (although Jim wishes more people shared his opinions)