Arduino Ethernet 2 shield Arduino UNOs can be connected to a LAN by adding an Ethernet 2 shield. This makes them able to communicate with other networked devices without the limitations of cable length and speed. The Ethernet shield is 10/100Mbps, has a slot for a micro-SD card and has all standard UNO pins brought through to helpfully labelled headers.

In any sketch that will use the Ethernet shield, you need to manually code its MAC address by copying the unique address from the self-adhesive label under the shield. The address provided is in hexadecimal so this needs to be retained in your sketch by prefixing each byte value with 0x, for example:

byte mac[]={0x90,0xA2,0xDA,0x10,0x1D,0x57};

Note that the variable name mac is not in capitals because capitals are, by convention, used for symbols defined with #define.

The Ethernet shield does not support DHCP so cannot obtain an IP address from your network. Instead, you will also need to assign a free IP address. Use decimal numbers for each part, for example:

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

Your LAN router will not usually try to assign this address to anything else while your Arduino is running but if you can set it in your DHCP configuration to be reserved or put it in an address pool or range that is not available for DHCP allocation, that is good practice.

You'll also need to specify which TCP port you want your server to listen on. Port 80 is the default used by all browsers so use that in preference to anything else:

EthernetServer server(80);

Then you start the server using:

Ethernet.begin(mac, ip);

At this point your Arduino should be listening for an incoming request. There are examples on the Internet of how to respond to requests, decode the URL, manage the connection, etc.

This example generates an SVG image showing the analogue port values in bar chart form. I tied A4 to 5V with a 10kΩ resistor to demonstrate the maximum 1023 value.

Arduino analogue values in bar chart form