loading
Picture of Arduino Ethernet Shield Tutorial
The Arduino Ethernet Shield allows you to easily connect your Arduino to the internet. This shield enables your Arduino to send and receive data from anywhere in the world with an internet connection. You can use it to do fun stuff like control robots remotely from a website, or ring a bell every time you get a new twitter message. This shield opens up endless amounts of possibility by allowing you to connect your project to the internet in no-time flat.
 
Remove these adsRemove these ads by Signing Up

Step 1: Setup

Picture of Setup
Setting it up is as simple as plugging the header pins from the shield into your Arduino.

Note that the Ethernet Shield sold at Radioshack is online compatible with Arduino Uno Rev. 3 boards (or later). It has too many pins to plug into earlier version Arduino boards.

Step 2: Shield Features

Picture of Shield Features
The Ethernet Shield is based upon the W51000 chip, which has an internal 16K buffer. It has a connection speed of up to 10/100Mb. This is not the fastest connection around, but is also nothing to turn your nose up at.

It relies on the Arduino Ethernet library, which comes bundled with the development environment.

There is also an on-board micro SD slot which enables you to store a heck-of-a-lot of data, and serve up entire websites using just your Arduino. This requires the use of an external SD library, which does not come bundled with the software. Using the SD card is not covered in this Instructable. However, it is covered in the Step 8 of the Wireless SD card instructable.

The board also has space for the addition of a Power over Ethernet (PoE) module, which allows you to power your Arduino over an Ethernet connection.

For a full technical overview, see the official Ethernet Shield page.

Step 3: Get started

Picture of Get started
3.jpg
Plug the Arduino into your computer's USB port, and the Ethernet shield into your router (or direct internet connection).

Next, open the Arduino development environment. I highly recommend upgrading to Arduino 1.0 or later (if you have not done so already). This version of the software has built in DHCP support, and does not require manually configuring an IP address.

To figure out what IP address has been assigned to your board, open the DhcpAddressPrinter sketch. This can be found at:

File --> Examples --> Ethernet --> DhcpAddressPrinter

Once open, you may need to change the Mac address. On newer versions of the Ethernet shield, you should see this address on a sticker attached to the board. If you are missing a sticker, simply making up a unique mac address should work. If you are using multiple shields, make sure each has a unique mac address.

Once the mac address is properly configured, upload the sketch to your Arduino, and open the serial monitor. It should print out the IP address in use.

Step 4: Server

Picture of Server
5B.jpg
5C.jpg
5D.jpg
You can use the Arduino Ethernet shield as a web server to load an HTML page or function as a chat server. You can also parse requests sent by a client, such as a web browser. The following two examples show how to use it to serve HTML pages, and parse URL strings.

One important thing to keep in mind is that you will have to enter your Arduino's IP address in both of the examples below in order for them to work.

The following code changes the web page served based on a button press:
To make this example code work, simply attach a button between pin D2 and 5V,  a 10K resistor between pin D2 and ground, and then load the IP address of your Arduino into your web browser. The page should load with a black background. Press and hold the button, and then refresh the browser page. The site should now load with a white background.


The following code lights up an LED depending on the URL that is sent to the Arduino:

To make this work connect the positive lead an LED to pin D2, and the negative lead in series with a 220 ohm resistor to ground.

To turn on the LED enter this into your browser:
http://[YOUR IP ADDRESS HERE]/$1

To turn off the LED enter this into your browser:
http://[YOUR IP ADDRESS HERE]/$2

Note: You should obviously replace [YOUR IP ADDRESS HERE] with your IP address.

Step 5: Client

Picture of Client
You can also use the Ethernet Shield as a client. In other words, you can use it to read websites like a web browser.

Websites have a lot of text both visible and hidden, which makes programming on the client side very tricky. Reading information from websites typically involves parsing a lot of strings. This is maddening, but worth it, if that is what you intend to do.

I was going to write some code to read Twitter messages, but such a code already exists as an example within the Arduino programmer. Instead, I simply modified it slightly to turn on an LED if a special message is read.

To make this work connect the positive lead an LED to pin D2, and the negative lead in series with a 220 ohm resistor to ground.

Don't forget to enter your own IP address into the code below, or it will not work.

Here is the code:

Presumably you are going to want to read something other than the recent post on the RandyMcTester Twitter feed.

To read other Twitter feeds, change the following bit of text:
client.println("GET /1/statuses/user_timeline.xml?screen_name=[NEW TWITTER NAME HERE]&count=1 HTTP/1.1");
1-40 of 95Next »
hiker_alan7 days ago

looks like photo is not correct. Looks like the black wire of switch is connected to ground, not 5V. Hooked up to 5V instead and it seems to be working. Get DARK/LIGHT on website [firefox]

makeosaurus21 days ago

can you use this shield connected to your computers ethranet port

KaushalK1 month ago

I get this message :
Failed to configure Ethernet using DHCP
any idea how to fix this thx ?

ipconfig /all gives me the physical address that i put in mac[].
it also says dhcp enabled : no
even if code is for DHCPaddressPrinter.

in case of ethernet server code :
i cant open my ip address in web browser.
when i ping it says "destination host unreachable".

MalikA51 month ago

please help me, serial monitor can't be open....
it says "Board at COM49 is not available"

animeguard1 month ago

thanks for sharing nice idea

gcharai2 months ago

I get this message :
Failed to configure Ethernet using DHCP
any idea how to fix this thx ?

summervin2 months ago

Hi, thanks for the wonderful walk-through! However, the twitter client doesn't seems to work.. Any idea?

GodoC3 months ago

Thanks ! it worked for me. Just a little reminder : to get the info on your monitor, don't forget to set it to the same baud rate as the one set by the program (ie DhcpAddressePrinter) for the serial connection (check the number XXX in Serial.begin(XXX)). To change the baud rate, you can use the "check list button" at bottom right of the monitor

嘉瑜陳4 months ago

Thanks for the tutorial, but i have a question to the server work example.
If i would like to use other strings other than "$1" and "$2", like "$ledon" for switching on the led connected, what adjustment need to do to the codes.
I find it difficult to solve this problem.

voltman4 months ago

Didn't work with 1.0, but first time with 1.6.1

oregondunerz5 months ago

Let me first start by saying that I am a complete noob when it comes to anything Arduino. My kit hasn't even arrived in the mail yet so please go easy on me. :)

However, I have a question regarding this project. Specifically the RJ45 Ethernet Shield. In your example you are using the RJ45 to interact with the Arduino via a website/internet, is it possible to use the Arduino + Shield to interact with a series of rocker switches via a 8 channel relay board? If so, I was thinking that it would make the installation of my project really clean being able to use the RJ45 cable between my Arduino and the switches that will be located perhaps 10-15 feet away.

Any and all help is appreciated.

cool.honny.55 months ago

This Tutorial is Fantastic and very very very very clear everything.Got this tutorial after 4 days searching on my related topic.

Many Many Thanks Dear.

Excuse me, does anyone know how to access the ethernet shield from the outside of the local network - that is from the internet? I guess the local dynamic IP has to be changed, right..? Where to get that IP?

how to access the ethernet shield from the outside of the local network - that is from the internet?

You need to port forward the IP and port you are using of the ethernet shield to the internet

This website may help: http://portforward.com/

I guess the local dynamic IP has to be changed, right..?

Yes if you are port forwarding the ethernet shield should have a static local IP. You can define the ethernet shield IP in the code.

http://arduino.cc/en/Reference/EthernetIPAddress

you can find your DNS servers, gateway, and subnet by typing ipconfig /all in a windows command line.

Make the ip of the ethernet shield any ip not currently used on you network. An easy way do do this is to take IP address listed in ipconfig /all and change the numbers after the last dot to 254 and put that in the arduino code as its IP.

Where to get that IP?

If you mean your public IP you can find that by visiting

http://www.whatismyip.com/

Sarmadalabbad5 months ago
Nice thank u
nur.rohmat16 months ago

thanks for your information,

secretfood.net

IdeS8 months ago

It's useful thank

midnightcow8 months ago

Nice Tutorial!!

I'm a engineer in WIZnet providing W5100 to the official Arduino Ethernet Shield.

WIZnet made W5500 and WIZ550io/ioShield-A. If you are interested in W5500 and make a tutorial of W5500, I will give a WIZ550io to you free. If you want, feel freely to contact me.

Thank you.

parth_bhat2 years ago
my ethernet shields ic gets hot will u plsplspls help me for that
am using arduino leonardo board
pls help me

regards
pyt
I have one of the Non-POE (power Over Ethernet) 5100's, and it does the same to me.. I think it's the 3.3V regulator trying to run the single chip, which is chewing-up massive wattage.. (even if it is being powered from the +5V regulator from the Arduino.) I've often wondered, if I could repower this off the 3.3V off an external power supply, but someone said that's a bad idea, as the back-feed could burn-out the regulator, and other chips switching between the 9 down to 5, and 5 down to 3.3, or even the USB to serial chip.

You need to supply the arduino and the shield with 7 or 7.5 v, you can use a dc-dc power regulator. I use a 12v power suply and a dc to dc regulator, who give me 7.5v and everything is fine.

randofo (author)  parth_bhat2 years ago
Did you do anything to change it, and/or did you plug it in correctly? It sounds like you are shorting something.
Gelfling6 randofo12 months ago

Wow! a whole year later? No, It's something about the 3.3 regulator, that is handling a lot of amperage from the 5100.. I thought I saw somewhere on another instructable, someone solved the problem (slightly) by DOUBLING the regulator. (stacking another one on top of the original, so you had 2 in parallel.) http://www.instructables.com/id/Beef-up-your-Arduino-power/

That happens with my wiznet W5100 too. It just happens I think.
antoniol111 months ago

Thanks a lot work at the first run.No problem with me here.

hzv83 years ago
'and open the serial monitor. It should print out the IP address in use.'

This dosen't work...........WTF
randofo (author)  hzv83 years ago
Are you using Arduino 1.0?

i have the same problem, i'm using Arduino 1.0.5 and the serial monitor don't print the IP address

yeagerxp Rayan_ADR11 months ago

check the baud rate of serial monitor

samething happened to me, had the baud set to 115200, changed it to 9600, and it works

Use DHCPAddressPrint it should work...

rstott21 year ago

This instructable answered questions I couldn't resolve after hours of work! Thanks for taking the time to do it!

AmpOwl1 year ago

Could you make it send emails? I'm thinking of hooking one up to a 3D printer to email you when it finishes a print.

waterlubber2 years ago
What if you don't have access to a router? (e.g apartment building, hotel rooms...) Can I use the ethernet port on my win7 computer?

I have the same problem, I've tried connecting the shield to the router directly and it worked, but I can't do it in my computer. I use Windows Vista, and the cable I'm using is crossed over (with just 4 wires). Do I need to configure something in Windows or what could I do?

Port should handle the cross over internally if its a newer computer if it doesn't you will need a cross over cable.
What is a crossover cable, and do I need one? (If so, why) I have an Atheros AR8132 PCI-E Fast Ethernet Controller and and Atheros AR5B95 Wireless Network Controller.
Well communicating from pc to pc via the rj45 port in the past you would need a cross over cable. Alot of ports on newer computers usually handle this internally. You may need to check the specs for your computer. Please read up on cross over cables. Just look up pc to pc networking via rj45 port. Basically pc to pc networking. The arduino and ethernet shield is basically a computer.
OK, my memory just gave me the memory of hooking up mine with another (it worked) so a Windows 7 computer seems to be compatible. ;P Is it like the serial cables when you have to "cross over" the TX and RX wires? Anyhows, its working. Thanks for the help.
Simsso1 year ago
Hi all!
Does anyone know, how to give people, who are not in the local network, access to the Arduino Server?
1-40 of 95Next »