A sensor hub in a metal distribution box, a Bluetooth proxy in the cellar or a gate controller at the far end of the garden often sit exactly where Wi-Fi is weakest. An ESP32 with an Ethernet port solves that with a cable, and with Power over Ethernet (PoE) the same cable also powers the board. The catch is that "ESP32 with Ethernet" covers two quite different hardware designs, and the wrong pin or clock setting gives you a board that either never gets a link or refuses to boot.
This guide explains the two designs, lists boards with known-good settings, covers what PoE does and doesn't give you, and shows working setups in the Arduino IDE and in ESPHome.
Two ways to get Ethernet: internal MAC or an SPI chip
Internal MAC plus an RMII PHY. The original ESP32 and the ESP32-P4 have a built-in Ethernet MAC (EMAC). It needs an external PHY chip, such as the LAN8720, IP101, RTL8201 or DP83848, connected over RMII. ESP-IDF supports only RMII here, not the older MII: RMII needs nine signals instead of up to 18, plus the MDC and MDIO management pins, and runs at 100 Mb/s. Most ready-made ESP32 Ethernet boards use this design.
An SPI Ethernet controller. Chips such as the WIZnet W5500, Davicom DM9051, WCH CH390, Microchip KSZ8851SNL and ENC28J60 contain their own MAC and PHY and talk to the microcontroller over SPI. This is the only option on chips without an EMAC: the ESP-IDF Ethernet guide for the ESP32-S3, for example, covers SPI modules only. It costs four SPI pins plus an interrupt and usually a reset line. The ENC28J60 is limited to 10 Mb/s, and ESPHome's documentation itself points to the W5500 as the faster choice.
A third case is new: ESPHome supports gigabit Ethernet over RGMII on the ESP32-S31, with a generic PHY driver and a dedicated type for the Motorcomm YT8531 on Espressif's own S31 board.
For a typical smart home device, speed doesn't decide anything. Both designs comfortably carry MQTT, the ESPHome API or a web page. What decides is the chip you want to use and whether a board already exists. If you need an ESP32-S3 (for its USB, PSRAM or camera interface), you will use SPI. If a classic ESP32 is fine, an RMII board is cheaper and better documented.
The clock is where RMII designs go wrong
RMII needs a 50 MHz reference clock (REF_CLK) shared by the PHY and the ESP32. According to the ESP-IDF documentation there are two ways to provide it, and each has a catch.
- External clock in (
EMAC_CLK_EXT_IN). The PHY or a separate 50 MHz oscillator supplies the clock. On the original ESP32 the only pin that can receive it is GPIO0, which is also a strapping pin: if GPIO0 reads low at power-up, the chip enters download mode and stays there until reset. Good board designs keep the oscillator or PHY disabled during boot and let the driver enable it later, usually through a "power" pin. - Internal clock out (
EMAC_CLK_OUT). The ESP32 generates 50 MHz from its audio PLL (APLL) and outputs it on GPIO0, GPIO16 or GPIO17. ESP-IDF warns that this can collide with I2S, because I2S uses the same APLL. GPIO16 and GPIO17 are free only if the module has no PSRAM, which is why WROVER versions of some boards move the clock to GPIO0.
In practice you don't choose the clock mode, the board designer did. Your job is to copy the right mode, pins, PHY address and power pin for your exact board revision. ESPHome's documentation adds one warning worth repeating: connecting a loose Ethernet module to an ESP32 with jumper wires is likely to fail, because the high-frequency clock doesn't travel reliably over them. For RMII, buy a board with the PHY already on it.
Boards with known settings
These settings come from the ESPHome Ethernet documentation and the board definitions in the Arduino-ESP32 core.
| Board | Chip | Clock | PHY address | Power pin |
|---|---|---|---|---|
| Olimex ESP32-POE / ESP32-POE-ISO | LAN8720 | GPIO17 out (GPIO0 on WROVER versions) | 0 | GPIO12 |
| Wireless Tag WT32-ETH01 | LAN8720 | GPIO0 in | 1 | GPIO16 |
| M5Stack PoESP32, ESP32-Ethernet-Kit | IP101 | GPIO0 in | 1 | GPIO5 |
| LILYGO T-ETH-Lite ESP32 | RTL8201 | GPIO0 in | 0 | GPIO12 |
| Silicognition wESP32 rev. 7 and newer | RTL8201 | GPIO0 in | 0 | none (MDC GPIO16, MDIO GPIO17) |
| Waveshare ESP32-S3-ETH | W5500 (SPI) | n/a | n/a | reset GPIO9 |
Unless noted, MDC is GPIO23 and MDIO is GPIO18. Two details from the table cause trouble often enough to mention. The wESP32 changed its PHY from LAN8720 to RTL8201 at revision 7 and needs an extra PHY register write, so check the revision printed on the board. The WT32-ETH01 has no USB port: you flash it through a 3.3 V USB-to-serial adapter (TX to RX0, RX to TX0, common ground), with IO0 connected to GND while it powers up, and you remove that jumper afterwards.
What PoE gives you
Standard PoE (IEEE 802.3af, Type 1) delivers up to 15.4 W from the switch port and guarantees 12.95 W at the powered device over 100 m of cable. The device receives 37-57 V DC. Before switching power on, the switch checks for a signature resistance of about 25 kΩ, so an ordinary device without PoE support is never powered. PoE+ (802.3at) raises the budget to 25.5 W at the device, far more than an ESP32 board normally draws.
The Olimex boards illustrate a point that is easy to miss. The ESP32-POE (17.95 EUR at Olimex) has no galvanic isolation between the PoE supply and the rest of the board. Olimex says that if the board is powered over Ethernet, you should unplug the network cable before you program it over micro USB, or use their USB-ISO isolator. The ESP32-POE-ISO (24.95 EUR) adds 3000 V DC isolation and an isolated 5 V converter rated at 2 W (400 mA). If the board will sit on a PoE switch while you develop on it, or if it connects to sensors that are grounded somewhere else, the isolated version is worth the extra money.
Two other practical points. An 802.3af board still needs a PoE switch or a standard injector at the other end. And on the ISO board, everything you power from the 5 V side, including relays or LEDs, has to fit within that 400 mA.
Arduino IDE: Ethernet in a few lines
Since Arduino-ESP32 3.0 the ETH library supports both RMII PHYs and SPI chips. If you select the right board in the Arduino IDE (for example "OLIMEX ESP32-POE" or "WT32-ETH01 Ethernet Module"), the board definition already contains the PHY type, address, pins and clock mode, and ETH.begin() needs no arguments:
#include <ETH.h>
static bool eth_connected = false;
// Called from a separate FreeRTOS task: keep it short
void onEvent(arduino_event_id_t event) {
switch (event) {
case ARDUINO_EVENT_ETH_START:
ETH.setHostname("esp32-eth"); // set after start, before DHCP
break;
case ARDUINO_EVENT_ETH_GOT_IP:
Serial.println(ETH); // interface details and IP address
eth_connected = true;
break;
case ARDUINO_EVENT_ETH_LOST_IP:
case ARDUINO_EVENT_ETH_DISCONNECTED:
case ARDUINO_EVENT_ETH_STOP:
eth_connected = false;
break;
default:
break;
}
}
void setup() {
Serial.begin(115200);
Network.onEvent(onEvent);
ETH.begin();
}
void loop() {
// use NetworkClient, an MQTT library or a web server once eth_connected is true
}
For a board without a predefined variant, pass the settings explicitly. For a LAN8720 board with an external clock on GPIO0:
ETH.begin(ETH_PHY_LAN8720, 1, 23, 18, 16, ETH_CLOCK_GPIO0_IN);
// type, PHY address, MDC, MDIO, power pin, clock mode
For a W5500 on SPI, start the SPI bus first and pass the chip select, interrupt and reset pins:
#include <ETH.h>
#include <SPI.h>
void setup() {
Serial.begin(115200);
Network.onEvent(onEvent);
SPI.begin(14, 12, 13); // SCK, MISO, MOSI
ETH.begin(ETH_PHY_W5500, 1, 15, 4, 5, SPI);
// type, address, CS, IRQ, RST, SPI bus
}
The pin numbers above come from Espressif's own examples. Replace them with your wiring.
ESPHome: the ethernet: block
In ESPHome, Ethernet replaces the wifi: block. For the Olimex ESP32-POE:
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk:
pin: GPIO17
mode: CLK_OUT
phy_addr: 0
power_pin: GPIO12
For SPI chips you give clk_pin, mosi_pin, miso_pin and cs_pin instead, plus interrupt_pin and reset_pin. With ESP-IDF 5.1.4 or newer the interrupt pin is optional and the driver polls the chip every 10 ms by default (polling_interval). The SPI clock defaults to 26.67 MHz. Some chips need less: ESPHome's example for the ETH01-Evo (DM9051) sets 8 MHz and warns that higher speeds, including the default, can cause receive errors and dropped packets.
Until recently ESPHome allowed only one network interface. Current releases let an ESP32 use Ethernet and Wi-Fi together, but only if you add a priority list:
network:
priority:
- ethernet
- wifi
The first interface is preferred, and if its cable is unplugged, outgoing traffic moves to the next connected interface and comes back later. The documentation warns that running both stacks uses a lot of memory. You can keep Wi-Fi off with enable_on_boot: false and turn it on from an automation, but then it doesn't take over automatically.
Mistakes that cost an afternoon
- Wrong PHY address. The same LAN8720 sits at address 0 on Olimex boards and 1 on the WT32-ETH01. If the log shows the driver can't find the PHY, try the other address before you suspect the hardware.
- The board boots into download mode. With an external clock on GPIO0, a PHY that starts its oscillator too early pulls the strapping pin at boot. Check that the power pin is configured, because that's what keeps the clock off until the driver is ready.
- WROVER modules and pins 16/17. These pins are used for PSRAM, so the clock moves to GPIO0. Olimex notes that the WROVER versions may also need I2C changes.
- I2S audio plus internal clock. Both need the APLL. If your project plays sound or uses an I2S microphone, choose a board with an external clock.
- Programming a non-isolated PoE board on a PoE switch. Unplug the network cable first, or use an isolated board.
- Expecting the ENC28J60 to keep up. It does 10 Mb/s. For anything that moves more than sensor readings, choose a W5500 or an RMII board.