The Arduino Ethernet Shield based on the W5100 chip is one of the most reliable ways to connect your Arduino project to a local network or the internet. Unlike WiFi shields that require complex association protocols, the W5100 provides wired Ethernet connectivity with hardware-accelerated TCP/IP — making it fast, stable, and easy to program. In this tutorial, we’ll walk through setting up the Ethernet Shield, building a simple web server, reading sensor data over HTTP, and integrating with IoT platforms — all using the standard Arduino Ethernet library.
- W5100 Ethernet Shield Overview
- Hardware Setup and Compatibility
- First Connection: Ping and DHCP
- Building an Arduino Web Server
- Sensor Monitoring Dashboard over HTTP
- HTTP Client: Sending Data to IoT Platforms
- UDP: Fetching Time from NTP Server
- Advanced Project Ideas
- Frequently Asked Questions
W5100 Ethernet Shield Overview
The WIZnet W5100 is a hardwired TCP/IP controller that offloads all networking stack processing from the Arduino’s ATmega chip. It handles ARP, IP, ICMP, TCP, and UDP entirely in hardware, leaving the Arduino free to focus on application logic. The shield provides four simultaneous socket connections — enough for most IoT and home automation use cases.
Key Specifications
- Ethernet controller: WIZnet W5100
- Interface: SPI (up to 14 Mbps)
- Supported protocols: TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE
- Simultaneous sockets: 4
- TX/RX buffer: 16 KB total (shared among 4 sockets)
- Operating voltage: 3.3V (level-shifted to 5V Arduino)
- SD card slot: Yes (separate SPI CS on pin 4)
- MAC address: Sticker on bottom of shield (use exactly this address)
Hardware Setup and Compatibility
The Ethernet Shield plugs directly onto the Arduino Uno’s headers and uses the SPI bus for communication with the W5100 chip:
- Pin 10: W5100 Chip Select (SS)
- Pin 11 (MOSI), Pin 12 (MISO), Pin 13 (SCK): SPI bus
- Pin 4: SD card Chip Select
Important compatibility notes:
- The shield stacks directly onto Uno R3 (1.0 pinout) and Mega 2560
- When using with a Mega 2560, the SPI is via the ICSP header — the shield’s ICSP pins must align correctly. Modern shields have this pass-through header.
- Always use a power supply capable of at least 500 mA when using the Ethernet Shield — the W5100 adds ~150 mA to the board’s current draw
- The SD card and Ethernet cannot both be active simultaneously on the same SPI bus without careful CS management (deassert one before using the other)
Installing the Ethernet Library
The Ethernet library comes bundled with the Arduino IDE. For the W5100-based shields (as opposed to the newer W5500-based ENC28J60 shields), use the standard Ethernet.h library. Go to Sketch → Include Library → Ethernet, or add #include <Ethernet.h> at the top of your sketch.
First Connection: Ping and DHCP
The simplest first test is to get a DHCP-assigned IP address and verify connectivity by pinging the shield from your router or computer.
#include <SPI.h>
#include <Ethernet.h>
// Replace with the MAC address printed on your shield's sticker
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
void setup() {
Serial.begin(9600);
Serial.println("Initializing Ethernet with DHCP...");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to get IP from DHCP");
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found.");
}
while (true); // Stop here
}
Serial.print("IP Address: ");
Serial.println(Ethernet.localIP());
}
void loop() {
Ethernet.maintain(); // Renew DHCP lease if needed
}
Upload this sketch, open the Serial Monitor at 9600 baud, and you should see the assigned IP address. Then from your PC: ping 192.168.x.x (the IP shown in serial) to verify network connectivity.
Building an Arduino Web Server
The most classic Ethernet Shield project is a simple HTTP web server that serves a status page in your browser. Here’s a complete, working example:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EthernetServer server(80); // HTTP on port 80
void setup() {
Serial.begin(9600);
Ethernet.begin(mac);
server.begin();
Serial.print("Server at: http://");
Serial.println(Ethernet.localIP());
}
void loop() {
EthernetClient client = server.available();
if (client) {
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == 'n' && currentLineIsBlank) {
// Send HTTP response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html><body>");
client.print("<h1>Arduino Web Server</h1>");
client.print("<p>Uptime: ");
client.print(millis() / 1000);
client.println(" seconds</p>");
client.print("<p>Analog A0: ");
client.print(analogRead(A0));
client.println("</p></body></html>");
break;
}
if (c == 'n') currentLineIsBlank = true;
else if (c != 'r') currentLineIsBlank = false;
}
}
delay(1);
client.stop();
}
}
Navigate to the IP address shown in the serial monitor from any browser on your local network. You’ll see a simple status page showing the Arduino’s uptime and the A0 analog reading.
Sensor Monitoring Dashboard over HTTP
Extend the basic web server to create a real-time sensor dashboard. The following example reads a temperature/humidity sensor and serves a formatted HTML page with auto-refresh:
// Add to your web server response:
client.println("<meta http-equiv='refresh' content='5'>"); // Auto-refresh every 5s
client.print("Temperature: ");
client.print(temperature); // Your sensor reading
client.println(" °C<br>");
client.print("Humidity: ");
client.print(humidity);
client.println(" %<br>");
For a more professional dashboard, serve a JavaScript-enhanced page that uses AJAX (XMLHttpRequest) to poll a JSON endpoint on the Arduino every few seconds — updating values without full page reloads. The Arduino can serve a simple /api/sensors endpoint returning: {"temp":25.3,"humidity":67}.
HTTP Client: Sending Data to IoT Platforms
The Ethernet Shield isn’t limited to serving data — it can also act as an HTTP client to push sensor readings to cloud IoT platforms like ThingSpeak, Adafruit IO, or your own server.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "api.thingspeak.com";
EthernetClient client;
String apiKey = "YOUR_API_KEY";
void sendData(float temperature) {
if (client.connect(server, 80)) {
String url = "/update?api_key=" + apiKey + "&field1=" + String(temperature);
client.print("GET " + url + " HTTP/1.1rn");
client.print("Host: api.thingspeak.comrn");
client.print("Connection: closernrn");
client.stop();
}
}
This pattern sends one data point per call. For ThingSpeak’s free tier, maintain at least 15-second intervals between updates. For more frequent updates, consider a self-hosted MQTT broker with the PubSubClient library — MQTT is far more efficient than HTTP for IoT telemetry.
UDP: Fetching Time from NTP Server
The W5100 supports UDP alongside TCP, enabling you to query NTP (Network Time Protocol) servers for accurate timestamps — useful for data logging, scheduling, or timestamped sensor readings.
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <TimeLib.h> // Install via Library Manager
EthernetUDP Udp;
IPAddress timeServer(129, 6, 15, 28); // time.nist.gov
const int NTP_PACKET_SIZE = 48;
byte packetBuffer[NTP_PACKET_SIZE];
// See full NTP example in Arduino IDE: File → Examples → Ethernet → UDPSendReceiveString
The EthernetUDP class provides beginPacket(), write(), endPacket(), and parsePacket() for full UDP communication. Combined with the TimeLib library, you can maintain accurate wall-clock time without any RTC hardware.
Advanced Project Ideas
Home Automation Controller
Build a browser-accessible dashboard controlling relays for lights, fans, and appliances. The Arduino serves a control panel page; clicking buttons sends GET requests (e.g., /relay/1/on) back to the Arduino, which toggles the corresponding output pin.
Network-Connected Weather Station
Combine a BME280 sensor (temperature, humidity, pressure) with the Ethernet Shield. Log readings to a local server every minute and push daily summaries to a cloud API. The SD card on the shield can buffer data if network connectivity is temporarily lost.
Industrial Modbus to Ethernet Gateway
Use the Mega’s Serial1 port for RS485/Modbus RTU communication to industrial sensors, while the Ethernet Shield makes the data accessible over TCP/IP on the local network. This bridges industrial equipment to modern monitoring systems without replacing existing field devices.
Multi-Zone Irrigation Controller
Schedule watering zones via a web interface, with the Arduino checking NTP time to trigger relays at programmed times. Soil moisture sensors on analog pins provide real-time data shown on the dashboard.
Frequently Asked Questions
What is the difference between the W5100 and W5500 Ethernet Shield?
The W5500 is a newer, improved chip with 8 simultaneous sockets (vs W5100’s 4), faster SPI (80 MHz vs 14 MHz), lower power consumption, and 32 KB TX/RX buffers (vs 16 KB). For new designs, prefer the W5500. The older W5100-based shields use the standard Ethernet.h library; W5500 shields use the Ethernet2 or Ethernet3 library.
Can I access my Arduino web server from the internet?
Yes, but requires port forwarding on your router (forward external port 80 to the Arduino’s local IP). For reliability, assign a static IP to the shield or use a DHCP reservation by MAC address. For remote access without a static public IP, services like ngrok or DuckDNS provide dynamic DNS solutions.
Why does my Ethernet Shield stop responding after a few hours?
This is a common issue with the W5100 caused by socket resource leaks. Always call client.stop() after every client interaction. In your main loop, call Ethernet.maintain() regularly to handle DHCP lease renewal. Consider adding a watchdog timer reset if the server becomes unresponsive.
Can I use the SD card and Ethernet at the same time?
Yes, both are on the same SPI bus and use different chip select pins (pin 4 for SD, pin 10 for W5100). The library handles CS automatically when using both libraries simultaneously. Just initialize both: Ethernet.begin(mac) and SD.begin(4).
Is the Arduino Ethernet Shield suitable for production IoT deployment?
For low-volume deployments (home automation, lab monitoring), yes. For high-reliability or commercial deployments, consider dedicated IoT hardware with proper watchdog circuits, OTA update capability, and industrial temperature ratings. The Arduino + Ethernet Shield combination is excellent for prototyping and small-scale deployments.
Ready to connect your Arduino to the network? Browse all Arduino boards and shields at Zbotic.in — India’s trusted electronics components store with fast shipping nationwide.
Add comment