When reliability matters more than convenience, the ESP32 Ethernet W5500 module combination is one of the best choices for industrial and home IoT applications. While WiFi is fine for consumer gadgets, many professional IoT deployments — factory automation, server room monitoring, building management systems — demand the rock-solid stability of a wired Ethernet connection. This tutorial shows you exactly how to wire up a W5500 Ethernet module to an ESP32, configure the libraries, and build reliable networked IoT applications.
Why Use Wired Ethernet Instead of WiFi for IoT?
WiFi is everywhere, but it comes with inherent limitations that make it unsuitable for certain IoT use cases. Radio interference from neighbouring networks, routers, and microwave ovens can cause packet loss and connection drops. WiFi channel congestion in apartment buildings and commercial spaces is a real problem. For devices that must stay connected 24/7 — industrial sensors, security cameras, environmental monitors — these interruptions are unacceptable.
Wired Ethernet solves all of these problems at once. Here is why Indian engineers and hobbyists are increasingly choosing Ethernet for serious IoT projects:
- Deterministic latency: No RF channel competition means consistent sub-1ms local network latency
- No interference: Twisted-pair cables are immune to the 2.4 GHz congestion that plagues WiFi
- No reconnection overhead: WiFi stacks spend significant time on association, DHCP, and reconnection cycles
- Security: Physical access required — no over-the-air eavesdropping
- Power: No WiFi radio means the ESP32’s RF circuitry can stay in a lower power state
For factory floors in Gujarat or Maharashtra, server rooms in Bangalore, and industrial plants across India where reliable communication is non-negotiable, the W5500 module paired with ESP32 is the right tool for the job.
The W5500 Chip: What Makes It Special?
The W5500 from WIZnet is a hardwired TCP/IP embedded Ethernet controller. Unlike some solutions that implement TCP/IP in software on the microcontroller, the W5500 has the entire TCP/IP stack embedded in silicon. This means:
- The ESP32 only needs to speak SPI to the W5500 — the chip handles all the Ethernet framing, ARP, ICMP, TCP, UDP, and DHCP internally
- Supports up to 8 simultaneous independent sockets
- 10/100 Mbps full-duplex Ethernet with auto-negotiation
- SPI interface up to 80 MHz (ESP32 can drive it at 20-26 MHz comfortably)
- 3.3V I/O — natively compatible with ESP32’s GPIO voltage levels
- Built-in PHY layer — just add an RJ45 jack with magnetics
The W5500 module (breakout board) includes the chip, RJ45 connector with integrated magnetics, and all required decoupling capacitors. It is widely available in India at very reasonable prices.
Ai Thinker NodeMCU-32S-ESP32 Development Board – IPEX Version
The NodeMCU-32S provides all the SPI pins needed to connect a W5500 Ethernet module. Its dual-core processor handles TCP/IP communication alongside sensor tasks simultaneously.
Wiring the W5500 Module to ESP32
The W5500 communicates via SPI. The ESP32 has multiple SPI buses (VSPI and HSPI) — we will use VSPI which has default pins that are convenient on most dev boards. Here is the pin mapping:
| W5500 Pin | ESP32 Pin | Description |
|---|---|---|
| VCC | 3.3V | Power (3.3V only!) |
| GND | GND | Common ground |
| MOSI | GPIO 23 | SPI Master Out Slave In |
| MISO | GPIO 19 | SPI Master In Slave Out |
| SCLK | GPIO 18 | SPI Clock |
| CS (SS) | GPIO 5 | Chip Select (active LOW) |
| RST | GPIO 26 | Hardware reset (optional) |
| INT | GPIO 35 | Interrupt (optional) |
Important: The W5500 operates at 3.3V logic. Never connect it to 5V — you will damage the chip. Use short wires (under 10 cm) for the SPI connections to maintain signal integrity at higher clock speeds. If you experience intermittent issues, slow down the SPI clock to 8 MHz.
Software Setup: Libraries and Configuration
The recommended library for W5500 on ESP32 is the Ethernet library included with the ESP32 Arduino core, or the dedicated Ethernet3 or Ethernet_Generic libraries. The most convenient and well-maintained option is using the built-in Ethernet library with W5500 configuration:
#include <SPI.h>
#include <Ethernet.h>
// Your W5500 MAC address (must be unique on your network)
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Use DHCP (or set a static IP)
IPAddress ip(192, 168, 1, 177);
IPAddress dns(8, 8, 8, 8);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
#define W5500_CS_PIN 5
#define W5500_RST_PIN 26
void setup() {
Serial.begin(115200);
// Reset W5500
pinMode(W5500_RST_PIN, OUTPUT);
digitalWrite(W5500_RST_PIN, LOW);
delay(100);
digitalWrite(W5500_RST_PIN, HIGH);
delay(250);
// Initialize SPI
SPI.begin(18, 19, 23, W5500_CS_PIN);
Ethernet.init(W5500_CS_PIN);
// Start Ethernet with DHCP
if (Ethernet.begin(mac) == 0) {
Serial.println("DHCP failed, using static IP");
Ethernet.begin(mac, ip, dns, gateway, subnet);
}
// Check hardware
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("W5500 not found!");
while (true);
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable not connected!");
}
Serial.print("IP Address: ");
Serial.println(Ethernet.localIP());
}
30Pin ESP32 Expansion Board with Type-C USB and Micro USB
This expansion board breaks out all ESP32 pins neatly, making it easy to connect a W5500 Ethernet module alongside other sensors without messy jumper wires.
Building a Simple HTTP Web Server over Ethernet
Once the Ethernet connection is established, you can create a web server that serves sensor data to any browser on your local network — no cloud dependency, no WiFi, just pure wired networking:
#include <SPI.h>
#include <Ethernet.h>
#include <DHT.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EthernetServer server(80);
DHT dht(4, DHT11);
void setup() {
SPI.begin(18, 19, 23, 5);
Ethernet.init(5);
Ethernet.begin(mac);
server.begin();
dht.begin();
}
void loop() {
EthernetClient client = server.available();
if (client) {
// Read request (skip headers)
while (client.available()) client.read();
float temp = dht.readTemperature();
float hum = dht.readHumidity();
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
client.println("<!DOCTYPE html><html><body>");
client.printf("<h1>Temperature: %.1f C | Humidity: %.1f%%</h1>", temp, hum);
client.println("</body></html>");
client.stop();
}
// Renew DHCP lease if needed
Ethernet.maintain();
}
Remember to call Ethernet.maintain() in your main loop — this renews the DHCP lease before it expires and keeps your IP address active. Without this call, DHCP-assigned IPs will eventually expire and your device will lose network connectivity.
MQTT over Ethernet: Stable IoT Data Publishing
For IoT telemetry, MQTT over Ethernet provides the most stable and reliable data pipeline. The PubSubClient library works seamlessly with the Ethernet library:
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress mqttBroker(192, 168, 1, 100); // Local Mosquitto broker IP
EthernetClient ethClient;
PubSubClient mqtt(ethClient);
void reconnect() {
while (!mqtt.connected()) {
if (mqtt.connect("ESP32-Ethernet-Client")) {
mqtt.subscribe("zbotic/commands");
} else {
delay(5000);
}
}
}
void loop() {
if (!mqtt.connected()) reconnect();
mqtt.loop();
static unsigned long lastPublish = 0;
if (millis() - lastPublish > 10000) {
mqtt.publish("zbotic/temperature", "27.5");
lastPublish = millis();
}
Ethernet.maintain();
}
Unlike WiFi-based MQTT setups that frequently reconnect due to signal drops, Ethernet MQTT connections stay rock-solid for days and weeks without interruption — making this setup ideal for production industrial deployments across India.
DHT20 SIP Packaged Temperature and Humidity Sensor
The DHT20 uses I2C instead of single-wire protocol, freeing up the SPI bus for your W5500 Ethernet module. A perfect sensor companion for ESP32 Ethernet IoT nodes.
Frequently Asked Questions
Can the ESP32 use WiFi and W5500 Ethernet at the same time?
Technically yes — the ESP32’s WiFi radio and the W5500 SPI interface are independent. However, running both simultaneously increases complexity and power consumption. For most use cases, choose one or the other. If you need redundancy, you can configure the ESP32 to fall back to WiFi if Ethernet is disconnected, using Ethernet.linkStatus() to monitor the cable connection state.
What SPI clock speed should I use for the W5500 with ESP32?
The W5500 supports SPI clocks up to 80 MHz, but for reliable operation with typical jumper wire connections, use 20-26 MHz. The ESP32’s SPI master defaults to 4 MHz — increase it by passing the clock frequency to SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)). If you see data corruption, reduce the clock.
Does the W5500 support static IP assignment?
Yes. Instead of calling Ethernet.begin(mac) for DHCP, call Ethernet.begin(mac, ip, dns, gateway, subnet) with your desired static IP configuration. Static IPs are recommended for server-role devices that other systems need to connect to reliably.
What power does the W5500 module draw?
The W5500 module typically draws 130-140 mA at 3.3V (about 430 mW) during active data transmission. This is significant — make sure your ESP32 development board’s 3.3V regulator can supply enough current. Some boards have weak regulators; power the W5500 directly from a dedicated 3.3V supply if you experience instability.
Get Your ESP32 and Accessories from Zbotic
Zbotic.in stocks ESP32 development boards, sensors, and expansion modules with fast delivery across India. Build stable, wired IoT solutions for your home, lab, or factory today.
Add comment