How to Build MicroPython Ethernet with WIZnet W5500 on ESP32?
This Maker project explains how to build a wired Ethernet system by combining an ESP32 with the WIZnet W5500 and MicroPython.
How to Build MicroPython Ethernet with WIZnet W5500 on ESP32?
Summary
This Maker project explains how to build a wired Ethernet system by combining an ESP32 with the WIZnet W5500 and MicroPython. The ESP32 provides the scripting runtime and application logic, while W5500 provides the SPI-connected Ethernet MAC/PHY, hardwired TCP/IP stack, socket resources, and packet buffers. The project focuses on hardware wiring, power integrity, SPI timing, register-level access, and the practical limits that affect MicroPython network performance.
What the Project Does
The project describes an ESP32 + W5500 wired Ethernet design rather than a single finished application. It covers the physical SPI wiring between ESP32 and W5500, RJ45 and isolation-transformer requirements, power-domain separation, PCB layout constraints, and low-level MicroPython driver considerations for register access. The source article frames W5500 as the Ethernet extension chip for ESP32 and emphasizes that SPI stability, power isolation, and PCB layout affect the final system reliability.
The hardware interface uses ESP32 SPI pins mapped to W5500 signals: SCLK to GPIO18, MOSI to GPIO23, MISO to GPIO19, chip select to GPIO5, interrupt to GPIO4, and reset to GPIO16. The article also notes that the interrupt pin should be handled as a falling-edge input so the ESP32 can react when W5500 reports events such as received data or connection changes.
The network side is a standard wired Ethernet path. W5500 connects to the RJ45 interface through Ethernet magnetics, while the ESP32 communicates with W5500 through SPI. For a Maker build, this gives a useful division of labor: ESP32 runs MicroPython scripts and application code, while W5500 handles Ethernet transport, TCP/IP offload, sockets, and buffering.
Where WIZnet Fits
The exact WIZnet product is W5500. In this architecture, W5500 is the network controller between ESP32 and the wired LAN. It provides a hardwired TCP/IP stack, SPI access up to 80 MHz, 10/100 Ethernet MAC/PHY, 8 independent sockets, and 32 KB internal memory for Tx/Rx buffers. WIZnet also lists support for TCP, UDP, ICMP, IPv4, ARP, IGMP, and PPPoE.
W5500 is important because ESP32 already has Wi-Fi, but this project chooses a wired Ethernet path for better physical link predictability and reduced RF dependency. The source article explicitly positions the ESP32 + W5500 combination as useful where Wi-Fi is less desirable, such as environments with interference or where deterministic latency matters.
From the MicroPython side, there are two possible implementation paths. A custom driver can access W5500 registers directly over SPI, as the article discusses. Current MicroPython documentation also describes Ethernet support through network.LAN, and its ESP32 documentation points users to the ESP32-specific constructor for Ethernet interfaces. That means the implementation must match the selected firmware version, board support, and build configuration.
Implementation Notes
The CSDN article is visible as a technical write-up, but it does not provide a public repository with verifiable source file paths. Therefore, the following is an architecture-level explanation, not copied project code.
Conceptual integration example based on MicroPython ESP32 LAN usage
import network
from machine import Pin, SPI
spi = SPI(1, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
lan = network.LAN(
spi=spi,
phy_type=network.PHY_W5500,
phy_addr=0,
cs=Pin(5),
int=Pin(4),
)
lan.active(True)
print(lan.ifconfig())This example shows the expected high-level shape of an ESP32 + W5500 MicroPython interface: define the SPI bus, select the W5500 PHY type, assign chip-select and interrupt pins, enable the LAN interface, then inspect the IP configuration. The exact constructor arguments and availability depend on the MicroPython ESP32 build, so the firmware configuration should be verified before debugging wiring. MicroPython’s LAN documentation states that the ESP32 port uses different constructor arguments and refers users to the ESP32 port reference.
At the lower driver layer, the source article describes direct register access through W5500’s address-based SPI protocol. It lists common network registers such as MR, GAR, SUBR, SHAR, SIPR, IR, and IMR, which are used for mode control, gateway, subnet, source MAC, source IP, and interrupt control.
For performance, the SPI clock should not be treated as a headline number only. W5500 supports fast SPI, but the source article recommends balancing speed and stability, and it highlights signal integrity, interrupt handling, power-domain separation, and PCB layout as practical bottlenecks. WIZnet lists W5500 network performance up to 55 Mbps, but real MicroPython throughput will also depend on SPI clock, driver overhead, buffer copying, interrupt latency, and how often the Python application services sockets.
Practical Tips / Pitfalls
- Keep SPI wiring short and stable. The article maps SCLK, MOSI, MISO, SS, INT, and RST explicitly, and treats SPI stability as central to system reliability.
- Do not ignore the interrupt pin. If
INTis not configured correctly, received data or socket events may not be handled promptly. - Use reset control from the ESP32. A dedicated reset pin gives firmware a deterministic way to recover W5500 during bring-up or after abnormal network states.
- Treat RJ45 magnetics and differential routing as part of the design, not as a connector detail. The article calls out transformer use, differential-pair routing, and impedance control.
- Separate or carefully filter power domains. The source article reports that ESP32 Wi-Fi or Bluetooth activity can couple noise into the W5500 PHY if power isolation is weak.
- Verify firmware support before hardware debugging. If the MicroPython build does not include the needed W5500/LAN support, correct wiring alone will not make
network.LANwork. - Start with link and IP verification before HTTP, MQTT, or cloud traffic. Confirm PHY link, IP address, gateway, and DNS before adding application protocols.
FAQ
Q: Why use WIZnet W5500 with ESP32 MicroPython?
A: W5500 gives ESP32 a wired Ethernet interface with hardware TCP/IP offload, 8 sockets, and internal packet buffers. This lets Maker projects use MicroPython for application logic while W5500 handles the Ethernet MAC/PHY path and socket-level network transport.
Q: How does W5500 connect to the ESP32 platform?
A: The project uses SPI wiring: SCLK, MOSI, MISO, chip select, interrupt, and reset. The source article maps these to ESP32 GPIO18, GPIO23, GPIO19, GPIO5, GPIO4, and GPIO16 respectively, while the Ethernet side uses RJ45 plus isolation magnetics.
Q: What role does W5500 play in this project?
A: W5500 is the Ethernet transport engine. ESP32 runs MicroPython and user scripts, while W5500 provides the wired Ethernet interface, hardwired TCP/IP stack, socket state, and internal packet buffering.
Q: Can beginners follow this Maker project?
A: Yes, but it is best for learners who already understand ESP32 flashing, SPI wiring, basic IP configuration, and MicroPython modules. The project is lower-level than a normal Python socket demo because it also discusses power, PCB layout, interrupts, and register access.
Q: How does W5500 compare with Wi-Fi on ESP32?
A: Wi-Fi is simpler when the goal is wireless connectivity using the ESP32’s built-in radio. W5500 is better when the lesson or project needs a wired LAN path, predictable physical connection, visible SPI/Ethernet boundaries, and reduced dependence on RF conditions. Both can expose sockets to MicroPython, but they teach different system architectures.
Source
Original article: CSDN, “ESP32+W5500以太网硬件设计与MicroPython驱动实现,” marked CC 4.0 BY-SA.
WIZnet Maker project summary: “ESP32+W5500以太网硬件设计与MicroPython驱动实现.”
WIZnet product reference: W5500 Ethernet Controller documentation.
MicroPython reference: network.LAN documentation.
Tags
#W5500 #WIZnet #ESP32 #MicroPython #SPIEthernet #Maker #HardwareWiring #NetworkStack #Registers #Firmware #Performance #Ethernet #WiFi
ESP32에서 WIZnet W5500으로 MicroPython 이더넷을 구축하는 방법은?
요약
이 메이커 프로젝트는 ESP32와 WIZnet W5500, MicroPython을 결합해 유선 이더넷 시스템을 구축하는 방법을 설명합니다. ESP32는 스크립팅 런타임과 애플리케이션 로직을 담당하고, W5500은 SPI로 연결되는 Ethernet MAC/PHY, 하드웨어 TCP/IP 스택, 소켓 자원, 패킷 버퍼를 제공합니다. 이 프로젝트는 하드웨어 배선, 전원 안정성, SPI 타이밍, 레지스터 접근, MicroPython 네트워크 성능에 영향을 주는 실제 제약을 다룹니다.
프로젝트가 하는 일
이 프로젝트는 단일 완성 애플리케이션이 아니라 ESP32 + W5500 기반 유선 이더넷 설계를 설명합니다. ESP32와 W5500 사이의 물리적 SPI 배선, RJ45 및 절연 트랜스포머 요구 사항, 전원 도메인 분리, PCB 레이아웃 제약, 레지스터 접근을 위한 저수준 MicroPython 드라이버 고려 사항을 다룹니다. 원문은 W5500을 ESP32용 이더넷 확장 칩으로 설명하며, SPI 안정성, 전원 분리, PCB 레이아웃이 최종 시스템 신뢰성에 영향을 준다고 강조합니다.
하드웨어 인터페이스는 ESP32 SPI 핀을 W5500 신호에 매핑합니다. SCLK는 GPIO18, MOSI는 GPIO23, MISO는 GPIO19, chip select는 GPIO5, interrupt는 GPIO4, reset은 GPIO16에 연결됩니다. 원문은 W5500이 수신 데이터나 연결 상태 변화 같은 이벤트를 보고할 때 ESP32가 반응할 수 있도록 interrupt 핀을 falling-edge 입력으로 처리해야 한다고 설명합니다.
네트워크 측면에서는 표준 유선 Ethernet 구조입니다. W5500은 Ethernet magnetics를 통해 RJ45 인터페이스에 연결되고, ESP32는 SPI로 W5500과 통신합니다. 메이커 프로젝트 관점에서는 역할 분리가 명확합니다. ESP32는 MicroPython 스크립트와 애플리케이션 코드를 실행하고, W5500은 Ethernet 전송, TCP/IP 오프로딩, 소켓, 버퍼링을 담당합니다.
WIZnet이 들어가는 위치
이 프로젝트에서 사용되는 WIZnet 제품은 W5500입니다. 이 구조에서 W5500은 ESP32와 유선 LAN 사이에 위치하는 네트워크 컨트롤러입니다. W5500은 하드웨어 TCP/IP 스택, 최대 80 MHz SPI 접근, 10/100 Ethernet MAC/PHY, 8개 독립 소켓, 32 KB 내부 Tx/Rx 버퍼 메모리를 제공합니다. 또한 TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE를 지원합니다.
W5500이 중요한 이유는 ESP32가 이미 Wi-Fi를 내장하고 있음에도 이 프로젝트가 더 예측 가능한 물리 링크와 RF 의존성 감소를 위해 유선 Ethernet 경로를 선택하기 때문입니다. 원문은 ESP32 + W5500 조합이 간섭이 있거나 결정적인 지연 시간이 중요한 환경에서 유용하다고 설명합니다.
MicroPython 측면에서는 두 가지 구현 경로가 가능합니다. 하나는 원문이 설명하는 것처럼 SPI를 통해 W5500 레지스터에 직접 접근하는 커스텀 드라이버 방식입니다. 다른 하나는 현재 MicroPython 문서에서 설명하는 network.LAN 기반 Ethernet 인터페이스를 사용하는 방식입니다. 따라서 실제 구현은 선택한 MicroPython 펌웨어 버전, 보드 지원, 빌드 설정과 일치해야 합니다.
구현 참고 사항
CSDN 원문은 기술 설명으로 접근 가능하지만, 검증 가능한 공개 소스 저장소나 파일 경로를 제공하지 않습니다. 따라서 아래 코드는 원문 프로젝트에서 복사한 코드가 아니라 구조 설명용 예제입니다.
MicroPython ESP32 LAN 사용 방식을 기반으로 한 개념적 통합 예제
import network
from machine import Pin, SPI
spi = SPI(1, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
lan = network.LAN(
spi=spi,
phy_type=network.PHY_W5500,
phy_addr=0,
cs=Pin(5),
int=Pin(4),
)
lan.active(True)
print(lan.ifconfig())이 예제는 ESP32 + W5500 MicroPython 인터페이스의 기본 구조를 보여줍니다. SPI 버스를 정의하고, W5500 PHY 타입을 선택하며, chip select와 interrupt 핀을 지정한 뒤 LAN 인터페이스를 활성화하고 IP 설정을 확인합니다. 실제 생성자 인자와 사용 가능 여부는 MicroPython ESP32 빌드에 따라 달라지므로, 배선을 디버깅하기 전에 펌웨어 설정을 먼저 확인해야 합니다.
저수준 드라이버 계층에서는 W5500의 주소 기반 SPI 프로토콜을 통해 레지스터에 접근합니다. 원문은 MR, GAR, SUBR, SHAR, SIPR, IR, IMR 같은 공통 네트워크 레지스터를 언급합니다. 이 레지스터들은 mode control, gateway, subnet, source MAC, source IP, interrupt control에 사용됩니다.
성능 측면에서 SPI 클록은 숫자만 보고 판단하면 안 됩니다. W5500은 고속 SPI를 지원하지만, 원문은 속도와 안정성의 균형을 강조하며 signal integrity, interrupt handling, power-domain separation, PCB layout을 실제 병목으로 지적합니다. W5500의 네트워크 성능은 조건에 따라 높게 나올 수 있지만, 실제 MicroPython 처리량은 SPI 클록, 드라이버 오버헤드, 버퍼 복사, interrupt latency, Python 애플리케이션이 소켓을 얼마나 자주 처리하는지에 따라 달라집니다.
실무 팁 / 주의점
- SPI 배선은 짧고 안정적으로 유지해야 합니다. 원문은 SCLK, MOSI, MISO, SS, INT, RST를 명확히 매핑하고, SPI 안정성을 시스템 신뢰성의 핵심으로 봅니다.
- Interrupt 핀을 무시하면 안 됩니다.
INT가 제대로 설정되지 않으면 수신 데이터나 소켓 이벤트를 제때 처리하지 못할 수 있습니다. - ESP32에서 reset을 제어할 수 있어야 합니다. 전용 reset 핀은 bring-up 중이나 비정상 네트워크 상태 이후 W5500을 확실하게 복구하는 데 필요합니다.
- RJ45 magnetics와 differential routing은 단순 커넥터 문제가 아니라 설계의 일부입니다. 원문은 트랜스포머 사용, 차동 pair routing, impedance control을 강조합니다.
- 전원 도메인은 분리하거나 충분히 필터링해야 합니다. 원문은 ESP32의 Wi-Fi 또는 Bluetooth 동작이 전원 분리가 약할 경우 W5500 PHY 쪽에 노이즈를 줄 수 있다고 설명합니다.
- 하드웨어를 디버깅하기 전에 펌웨어 지원 여부를 확인해야 합니다. MicroPython 빌드에 필요한 W5500 또는 LAN 지원이 없으면 배선이 맞아도
network.LAN은 동작하지 않습니다. - HTTP, MQTT, 클라우드 트래픽으로 넘어가기 전에 link와 IP부터 검증해야 합니다. PHY link, IP 주소, gateway, DNS를 먼저 확인하는 것이 좋습니다.
FAQ
Q: ESP32 MicroPython에서 왜 WIZnet W5500을 사용하나요?
A: W5500은 ESP32에 하드웨어 TCP/IP 오프로딩, 8개 소켓, 내부 패킷 버퍼를 갖춘 유선 Ethernet 인터페이스를 제공합니다. 이를 통해 메이커 프로젝트는 MicroPython으로 애플리케이션 로직을 작성하면서, Ethernet MAC/PHY 경로와 소켓 수준 네트워크 전송은 W5500에 맡길 수 있습니다.
Q: W5500은 ESP32 플랫폼에 어떻게 연결되나요?
A: 이 프로젝트는 SPI 배선을 사용합니다. SCLK, MOSI, MISO, chip select, interrupt, reset이 필요합니다. 원문은 이를 각각 ESP32 GPIO18, GPIO23, GPIO19, GPIO5, GPIO4, GPIO16에 매핑하며, Ethernet 쪽은 RJ45와 절연 magnetics를 사용합니다.
Q: 이 프로젝트에서 W5500은 어떤 역할을 하나요?
A: W5500은 Ethernet 전송 엔진입니다. ESP32는 MicroPython과 사용자 스크립트를 실행하고, W5500은 유선 Ethernet 인터페이스, 하드웨어 TCP/IP 스택, 소켓 상태, 내부 패킷 버퍼링을 제공합니다.
Q: 초보자도 이 메이커 프로젝트를 따라갈 수 있나요?
A: 가능합니다. 다만 ESP32 플래시, SPI 배선, 기본 IP 설정, MicroPython 모듈 사용을 이해하고 있는 학습자에게 더 적합합니다. 이 프로젝트는 일반 Python 소켓 데모보다 낮은 계층을 다루며, 전원, PCB 레이아웃, interrupt, 레지스터 접근까지 함께 설명합니다.
Q: ESP32에서 W5500은 Wi-Fi와 어떻게 다른가요?
A: Wi-Fi는 ESP32 내장 무선을 사용해 간단히 무선 연결을 구현할 때 적합합니다. W5500은 유선 LAN 경로, 예측 가능한 물리 연결, 명확한 SPI/Ethernet 경계, RF 환경 의존성 감소가 필요할 때 더 적합합니다. 두 방식 모두 MicroPython에서 소켓을 제공할 수 있지만, 학습하는 시스템 아키텍처는 서로 다릅니다.
출처
Original article: CSDN, “ESP32+W5500以太网硬件设计与MicroPython驱动实现,” CC 4.0 BY-SA로 표시됨.
https://blog.csdn.net/weixin_42355400/article/details/158409678
WIZnet Maker project summary: “ESP32+W5500以太网硬件设计与MicroPython驱动实现.”
https://maker.wiznet.io/gunn/projects/esp32-w5500micropython/
WIZnet product reference: W5500 Ethernet Controller documentation.
https://wiznet.io/products/ethernet-chips/w5500
MicroPython reference: network.LAN documentation.
https://docs.micropython.org/en/latest/library/network.LAN.html
태그
#W5500 #WIZnet #ESP32 #MicroPython #SPIEthernet #Maker #HardwareWiring #NetworkStack #Registers #Firmware #Performance #Ethernet #WiFi
