Plugging In and Testing the Arduino Ethernet Shield

Created on: 26 December 2012

This article shows you how to plug the Arduino Ethernet shield into an Arduino Uno, then connect it to an Ethernet cable and finally test that the Ethernet shield is working. These are the first things that you need to do after buying an Arduino Ethernet shield for the first time.

Plugging in the Ethernet Shield

This video shows how to plug the Ethernet shield into an Arduino Uno board. Power is then supplied to the two boards via a USB cable. Finally the Ethernet cable is plugged into the Ethernet connector on the board.

Can't see the video? View on YouTube →

Ethernet Cable Connection

The other end of the Ethernet cable is plugged into a router (e.g. a spare Ethernet port on a ADSL router that the PC that will be used to connect to the Ethernet shield is also plugged into).

Ethernet Cable Type

The Ethernet cable used to connect the Ethernet shield to the router is the straight through type, i.e. the two connectors are wired one-to-one (no wires in the cable are crossed over).

Amazon.com

Amazon.co.uk

Testing the Arduino Ethernet Shield

The video below shows how to load the built in WebServer example sketch to test the Ethernet shield. The WebServer sketch configures the Arduino / Ethernet shield as a tiny web server that serves up a web page containing the values of the Arduino analog pins.

First the IP address of the PC is found. The WebServer sketch is then modified to use a different IP address, but in the same range as the PC.

After loading the sketch to the Arduino, the IP address used in the sketch is entered into the URL field of the web browser. The web browser then connects to the Arduino web server, and the values of the Arduino analog pins are displayed. These values are updated every 5 seconds.

Can't see the video? View on YouTube →

Determining the IP Address Range

The address range that the PC is using must be determined. The Arduino will then be assigned an address within this range which will allow a web browser on the PC to connect to the Arduino web server.

Windows 7

In Windows 7, click the Internet Access icon on the bottom Windows bar. You may first need to click the small 'up arrow' for the network icon to be displayed (as shown in the video).

After clicking the Internet Access icon, click Open Network and Sharing Center in the box that pops up.

Now click Local Area Connection and then Details... in the dialog box that pops up.

In the Network Connection Details dialog box that pops up, the IP address of the PC can be found next to IPv4 Address.

Linux

To find the IP address of a Linux computer, enter the following at the command line:

ifconfig | grep "inet addr"




Connecting to the Arduino Web Server

In the video, the IP address of the PC is found to be 10.0.0.6 – this means that we must choose an IP address for the Arduino that has the value of 10.0.0.x, where x is a number that is not used on the network, e.g. 10.0.0.12 was used in the video.

In the Arduino IDE, open the WebServer example program found under File → Examples → Ethernet → WebServer

Now change the IP address in the sketch found at this line of code:

IPAddress ip(192,168,1, 177);

For example, change it to:

IPAddress ip(10,0,0, 12);

The MAC address should also be changed in the sketch to the numbers found on the sticker on the bottom side of the Ethernet shield. This can be changed in this line of code:

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

Now load the sketch to the Arduino. On Windows computers, it may be necessary to push the reset button on the Ethernet shield after loading the sketch.

Open up a web browser on the PC and type the IP address into the URL field that you entered into the WebServer sketch (10.0.0.12 in the video, if you have problems, then try the format http://10.0.0.12 using the IP address that you chose).

The web browser should now connect to the Arduino web server and you should see the values of the analog pins displayed in the browser.