Wiznet makers

gavinchang

Published June 27, 2026 ©

101 UCC

25 WCC

68 VAR

0 Contests

4 Followers

0 Following

Original Link

How to Build Commercial Wired Ethernet with WIZnet W5500 on ESP32 MicroPython?

This commercial prototype architecture adds wired Ethernet to an ESP32 MicroPython device using WIZnet W5500 as the Ethernet controller.

COMPONENTS
PROJECT DESCRIPTION

How to Build Commercial Wired Ethernet with WIZnet W5500 on ESP32 MicroPython?

Summary

This commercial prototype architecture adds wired Ethernet to an ESP32 MicroPython device using WIZnet W5500 as the Ethernet controller. The ESP32 runs the product logic, configuration flow, diagnostics, and application protocols, while W5500 provides the Ethernet MAC/PHY, hardwired TCP/IP stack, socket engine, and internal packet buffering. The original CSDN Wenku answer page could not be directly fetched during verification, so the implementation notes use verified related W5500 MicroPython sources rather than claiming code from the exact Wenku page.

What the Project Does

The project target is a commercial wired-Ethernet prototype built around MicroPython. A typical device may be a service terminal, small gateway, diagnostic adapter, factory setup tool, data logger, sensor endpoint, or configuration appliance. The ESP32 handles product behavior and message formatting; W5500 handles the wired Ethernet transport path.

The data flow is:

ESP32 MicroPython application → W5500 driver/socket layer → SPI → W5500 → RJ45 Ethernet → router, local server, PC tool, gateway, or field-service laptop.

A verified public ESP32-W5500 MicroPython repository demonstrates this pattern by connecting an ESP32 to a W5500 module and using Python-style requests as an HTTP client. The repository lists ESP32 ESP-WROOM-32, W5500 or W5100 hardware, MicroPython firmware, ampy upload flow, W5500 driver files, and an HTTP fetch example.

For commercial work, the important point is not only “Ethernet works.” The product must expose enough state to support field debugging: chip version, MAC address, IP address, DNS result, link state, socket state, reconnect count, and last error. The reference example prints chip version, MAC address, IP address, DNS lookup result, and HTTP response text before closing the response object, which is the right kind of bring-up visibility for a commercial prototype.

Where WIZnet Fits

The exact WIZnet product is W5500. It sits between the ESP32 and the Ethernet connector. ESP32 communicates with W5500 through SPI plus chip-select and reset control, while W5500 manages the Ethernet MAC/PHY path, hardwired TCP/IP processing, socket states, and packet buffers.

WIZnet documents W5500 as a hardwired Internet controller with an integrated TCP/IP stack, SPI access up to 80 MHz, embedded 10/100 Ethernet MAC/PHY, 8 sockets, and 32 KB internal memory. It supports hardwired protocols including TCP, UDP, ICMP, IPv4, ARP, IGMP, and PPPoE.

This split is useful in commercial MicroPython systems because the Python application should focus on product behavior, not low-level TCP/IP internals. MicroPython’s WIZNET5K documentation describes WIZnet5x00 adapters as controlled through an SPI object, chip-select pin, and reset pin; after initialization, sockets can be used normally. The ESP32 port also supports W5500 through the network.LAN interface.

Implementation Notes

The exact Wenku page did not expose verified source files or a public repository. The snippets below are from a related public ESP32-W5500 MicroPython repository and should be treated as verified reference patterns, not code proven to come from the exact Wenku answer page. The repository states that it is licensed under the MIT License.

File: main.py
What it configures: W5500 driver import, SPI bus, chip-select pin, reset pin, W5500 network object, and request-layer socket binding.
Why it matters: this is the application boundary where MicroPython routes HTTP traffic through W5500 instead of treating networking as a hidden interface.

 
from wiznet5k import WIZNET5K
from machine import Pin, SPI
import wiznet5k_socket as socket
import time
import struct
import sma_esp32_w5500_requests as requests

# Initialize SPI and W5500
spi = SPI(2)
cs = Pin(5, Pin.OUT)
rst = Pin(34)
nic = WIZNET5K(spi, cs, rst)

# Initialize requests object with socket and Ethernet interface
requests.set_socket(socket, nic)
 

The same README maps ESP32 wiring to W5500 as 3V3 to V, GND to G, GPIO5 to CS, GPIO18 to SCK, GPIO23 to MOSI, GPIO19 to MISO, and GPIO34 to reset. It also requires uploading the W5500 driver, DHCP, DNS, socket, and request helper files before running the HTTP example.

File: wiznet5k.py
What it configures: W5500 common registers and socket registers for gateway, subnet, chip version, MAC address, local IP, PHY configuration, socket mode, socket command, socket status, RX size, and TX free size.
Why it matters: commercial firmware needs register-level observability during bring-up and field support. These constants expose the device state that separates wiring problems, IP configuration problems, link problems, and socket-state problems.

 
REG_MR = const(0x0000)              # Mode
REG_GAR = const(0x0001)             # Gateway IP Address
REG_SUBR = const(0x0005)            # Subnet Mask Address
REG_VERSIONR_W5500 = const(0x0039)  # W5500 Silicon Version
REG_SHAR = const(0x0009)            # Source Hardware Address
REG_SIPR = const(0x000F)            # Source IP Address
REG_PHYCFGR = const(0x002E)         # W5500 PHY Configuration

REG_SNMR = const(0x0000)            # Socket n Mode
REG_SNCR = const(0x0001)            # Socket n Command
REG_SNSR = const(0x0003)            # Socket n Status
REG_SNRX_RSR = const(0x0026)        # RX Free Size
REG_SNTX_FSR = const(0x0020)        # Socket n TX Free Size
 

The driver also writes IP address, subnet mask, and gateway into W5500 registers through its ifconfig setter, then validates the chip by resetting W5500, writing and reading the mode register, and checking that the W5500 version register returns the expected value.

Practical Tips / Pitfalls

  • Validate SPI access and W5500 chip detection before testing HTTP, MQTT, telemetry, or product protocol traffic.
  • Route reset to an ESP32 GPIO. Commercial prototypes need firmware-controlled Ethernet recovery.
  • Keep SCLK, MOSI, MISO, and chip-select wiring short, especially on jumper-wire prototypes.
  • Upload all required driver modules together; missing DHCP, DNS, socket, or request helper files can look like a network failure.
  • Log chip version, MAC address, IP address, link state, socket state, DNS result, reconnect count, and last error.
  • Treat W5500’s 8 sockets as a design resource. Reserve sockets for service access, telemetry, configuration, discovery, diagnostics, and future expansion.
  • Benchmark the complete MicroPython path. Python string handling, JSON parsing, filesystem writes, and logging can dominate latency even when Ethernet transport is stable.

FAQ

Q: Why use WIZnet W5500 for a commercial ESP32 MicroPython product?
A: W5500 gives the product wired Ethernet with hardwired TCP/IP, 8 sockets, and internal Tx/Rx buffering. That lets the MicroPython application work at the socket and payload level while W5500 handles Ethernet MAC/PHY operation, TCP/UDP behavior, socket state, and packet buffering.

Q: How does W5500 connect to the ESP32 platform?
A: W5500 connects through SPI using SCK, MOSI, MISO, chip select, reset, 3.3 V, and ground. The verified ESP32 reference maps GPIO5 to CS, GPIO18 to SCK, GPIO23 to MOSI, GPIO19 to MISO, and GPIO34 to reset.

Q: What role does W5500 play in this project?
A: W5500 is the wired Ethernet transport engine. ESP32 MicroPython builds product messages, handles configuration, and calls the driver/socket layer; W5500 manages the physical Ethernet link, hardwired TCP/IP processing, socket transitions, and RX/TX buffers.

Q: Can beginners follow this commercial prototype path?
A: Yes, if bring-up is staged. The practical order is wiring check, W5500 reset check, chip-version read, MAC/IP printout, DNS test, one HTTP request, then product-specific telemetry, configuration, or diagnostic protocol.

Q: How does W5500 compare with using ESP32 Wi-Fi?
A: ESP32 Wi-Fi is better when the device must be cable-free. W5500 adds SPI wiring and driver files, but it gives a repeatable wired path with explicit reset control, visible PHY state, fixed socket resources, and easier bench diagnostics. For commercial service ports, factory setup tools, and wired configuration appliances, that visibility is often more valuable than wireless convenience.

Source

Original source: CSDN Wenku answer page provided by the user. The page could not be directly fetched during verification, so its license and project-specific implementation details could not be confirmed.

Related implementation reference: Ayyoubzadeh/ESP32-Wiznet-W5500-Micropython, an MIT-licensed ESP32 + W5500 MicroPython HTTP client example with driver files, wiring notes, and W5500 socket binding.

WIZnet product reference: W5500 product documentation and feature list.

MicroPython reference: WIZNET5K documentation for WIZnet5x00 Ethernet modules.

Related MicroPython static-IP reference: CSDN W5500 MicroPython direct-cable static-IP test covering DHCP-disabled bring-up, IP byte conversion, socket interface binding, and UDP transmission.

Tags

#W5500 #WIZnet #ESP32 #MicroPython #CommercialPrototype #Ethernet #SPI #HardwareWiring #Registers #Firmware #Performance #NetworkStack #Socket #HTTPClient

 

요약 (Summary)

본 상용 프로토타입 아키텍처는 WIZnet W5500을 이더넷 컨트롤러로 사용하여 ESP32 MicroPython 장치에 유선 이더넷 기능을 추가합니다. ESP32는 제품 로직, 구성 흐름, 진단 및 애플리케이션 프로토콜을 실행하며, W5500은 이더넷 MAC/PHY, 하드웨어 TCP/IP 스택, 소켓 엔진 및 내부 패킷 버퍼링을 제공합니다. 원본 CSDN 문고(Wenku) 답변 페이지를 검증 과정에서 직접 가져올 수 없었으므로, 본 구현 노트는 해당 문고 페이지의 코드가 아닌 검증된 관련 W5500 MicroPython 소스를 기반으로 작성되었습니다.

프로젝트 개요 및 기능 (What the Project Does)

이 프로젝트의 목표는 MicroPython을 기반으로 한 상용 유선 이더넷 프로토타입을 구축하는 것입니다. 대표적인 적용 기기로는 서비스 터미널, 소형 게이트웨이, 진단 어댑터, 공장 설정 도구, 데이터 로거, 센서 엔드포인트 또는 설정 장치 등이 있습니다. ESP32는 제품의 동작과 메시지 포맷팅을 처리하고, W5500은 유선 이더넷 전송 경로를 담당합니다.

데이터 흐름:

ESP32 MicroPython 애플리케이션 → W5500 드라이버/소켓 계층 → SPI → W5500 → RJ45 이더넷 → 라우터, 로컬 서버, PC 도구, 게이트웨이 또는 현장 서비스용 노트북 

검증된 공개 ESP32-W5500 MicroPython 저장소(Repository)에 따르면, ESP32를 W5500 모듈에 연결하고 파이썬 스타일의 requests를 사용해 HTTP 클라이언트로 동작하는 패턴을 보여줍니다. 해당 저장소에는 ESP32 ESP-WROOM-32, W5500 또는 W5100 하드웨어, MicroPython 펌웨어, ampy 업로드 흐름, W5500 드라이버 파일 및 HTTP 패치(Fetch) 예제가 포함되어 있습니다.

상용 제품 개발에서 중요한 점은 단순히 "이더넷이 작동한다"는 것에 그치지 않고 , 현장 디버깅을 지원할 수 있도록 장치의 상태를 충분히 노출해야 한다는 점입니다. 즉, 칩 버전, MAC 주소, IP 주소, DNS 결과, 링크 상태, 소켓 상태, 재연결 횟수, 마지막 에러 등이 확인 가능해야 합니다. 레퍼런스 예제는 응답 객체를 닫기 전에 칩 버전, MAC 주소, IP 주소, DNS 조회 결과 및 HTTP 응답 텍스트를 출력하는데, 이는 상용 프로토타입의 초기 가동(Bring-up) 단계에서 필수적인 시각 확보 방법입니다.

WIZnet의 역할 (Where WIZnet Fits)

W5500 칩은 ESP32와 이더넷 커넥터 사이에 위치합니다. ESP32는 칩 선택(CS) 및 리셋(Reset) 제어와 함께 SPI를 통해 W5500과 통신하며, W5500은 이더넷 MAC/PHY 경로, 하드웨어 TCP/IP 처리, 소켓 상태 및 패킷 버퍼를 관리합니다.

WIZnet 문서에 따르면 W5500은 TCP/IP 스택이 내장된 하드웨어 인터넷 컨트롤러로, 최대 80MHz의 SPI 접근, 10/100 이더넷 MAC/PHY 내장, 8개의 소켓 및 32KB의 내부 메모리를 지원합니다. 또한 TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE 등의 하드웨어 프로토콜을 지원합니다.

이러한 역할 분담은 상용 MicroPython 시스템에서 매우 유용합니다. 파이썬 애플리케이션이 저수준의 TCP/IP 내부 동작에 신경 쓰지 않고 제품 본연의 기능과 동작에만 집중할 수 있기 때문입니다. MicroPython의 WIZNET5K 문서에서는 WIZnet5x00 어댑터가 SPI 객체, 칩 선택 핀, 리셋 핀을 통해 제어되며 , 초기화 플로우가 끝난 후에는 일반적인 소켓처럼 사용할 수 있다고 설명합니다. ESP32 포트 역시 network.LAN 인터페이스를 통해 W5500을 지원합니다.

구현 노트 (Implementation Notes)

 

원본 CSDN 문고 페이지의 소스 파일이나 공개 저장소는 검증되지 않았습니다. 아래의 코드 스니펫은 MIT 라이선스를 따르는 관련 공개 ESP32-W5500 MicroPython 저장소에서 가져온 검증된 레퍼런스 패턴입니다.

main.py

 

설정 내용: W5500 드라이버 임포트, SPI 버스, 칩 선택(CS) 핀, 리셋(RST) 핀, W5500 네트워크 객체 및 요청 계층(Request-layer) 소켓 바인딩 

 

중요성: MicroPython이 네트워킹을 숨겨진 인터페이스로 취급하는 대신, W5500을 통해 HTTP 트래픽을 라우팅하는 애플리케이션 경계 역할을 합니다.

Python
from wiznet5k import WIZNET5K
from machine import Pin, SPI
import wiznet5k_socket as socket
import time
import struct
import sma_esp32_w5500_requests as requests

# SPI 및 W5500 초기화
spi = SPI(2)
cs = Pin(5, Pin.OUT)
rst = Pin(34)
nic = WIZNET5K(spi, cs, rst)

# 소켓 및 이더넷 인터페이스로 requests 객체 초기화
requests.set_socket(socket, nic)

ESP32 - W5500 핀 매핑 (README 기준): * 3V3 → V / GND → G * GPIO5 → CS (Chip Select) * GPIO18 → SCK * GPIO23 → MOSI * GPIO19 → MISO * GPIO34 → Reset 

 

참고: HTTP 예제를 실행하기 전에 W5500 드라이버, DHCP, DNS, 소켓 및 requests 헬퍼 파일을 먼저 업로드해야 합니다.

wiznet5k.py

 

설정 내용: 게이트웨이, 서브넷, 칩 버전, MAC 주소, 로컬 IP, PHY 설정, 소켓 모드, 소켓 명령, 소켓 상태, RX 크기 및 TX 여유 크기를 위한 W5500 공통 레지스터 및 소켓 레지스터 정의.

 

중요성: 상용 펌웨어는 장치 구동 및 현장 지원 중에 레지스터 수준의 가시성(Observability)이 필요합니다. 이 상수들은 배선 문제, IP 설정 문제, 링크 문제, 소켓 상태 문제를 분리해 낼 수 있는 장치 상태를 노출해 줍니다.

Python
REG_MR = const(0x0000)              # Mode (모드)
REG_GAR = const(0x0001)             # Gateway IP Address (게이트웨이 IP 주소)
REG_SUBR = const(0x0005)            # Subnet Mask Address (서브넷 마스크 주소)
REG_VERSIONR_W5500 = const(0x0039)  # W5500 Silicon Version (W5500 실리콘 버전)
REG_SHAR = const(0x0009)            # Source Hardware Address (소스 MAC 주소)
REG_SIPR = const(0x000F)            # Source IP Address (소스 IP 주소)
REG_PHYCFGR = const(0x002E)         # W5500 PHY Configuration (PHY 설정)

REG_SNMR = const(0x0000)            # Socket n Mode (소켓 n 모드)
REG_SNCR = const(0x0001)            # Socket n Command (소켓 n 명령)
REG_SNSR = const(0x0003)            # Socket n Status (소켓 n 상태)
REG_SNRX_RSR = const(0x0026)        # RX Free Size (RX 잔여 크기)
REG_SNTX_FSR = const(0x0020)        # Socket n TX Free Size (소켓 n TX 여유 크기)

드라이버는 ifconfig 세터(Setter)를 통해 IP 주소, 서브넷 마스크, 게이트웨이를 W5500 레지스터에 기록합니다. 그 후 W5500을 리셋하고, 모드 레지스터를 읽고 쓰며 , W5500 버전 레지스터가 예상된 값을 반환하는지 확인하여 칩을 검증합니다.

실무 팁 및 주의사항 (Practical Tips / Pitfalls)

 

단계별 검증: HTTP, MQTT, 텔레메트리 등의 트래픽을 테스트하기 전에, SPI 접근과 W5500 칩 인식 여부를 먼저 검증하십시오.

 

하드웨어 리셋 연결: 리셋 핀을 ESP32 GPIO에 꼭 연결하십시오. 상용 프로토타입은 펌웨어 제어를 통한 이더넷 복구 기능이 필수적입니다.

 

배선 길이 최소화: 점퍼 와이어를 사용하는 프로토타입의 경우 SCLK, MOSI, MISO, CS 배선을 최대한 짧게 유지하십시오.

 

누락 없는 파일 업로드: 필요한 모든 드라이버 모듈을 함께 업로드해야 합니다. DHCP, DNS, 소켓, requests 헬퍼 파일이 하나라도 누락되면 네트워크 장애처럼 보일 수 있습니다.

 

철저한 로그 남기기: 칩 버전, MAC 주소, IP 주소, 링크 상태, 소켓 상태, DNS 결과, 재연결 횟수, 마지막 에러를 로그로 기록하십시오.

 

소켓 자원 관리: W5500이 제공하는 8개의 소켓을 디자인 리소스로 잘 분배하십시오. 서비스 접속, 텔레메트리, 구성 설정, 디바이스 탐색(Discovery), 진단 및 향후 확장을 위해 소켓을 미리 할당해 두는 것이 좋습니다.

 

전체 성능 벤치마크: MicroPython 경로 전체를 벤치마킹하십시오. 이더넷 전송 속도가 안정적이더라도 파이썬의 문자열 처리, JSON 파싱, 파일시스템 쓰기, 로그 기록 등이 지연 시간(Latency)의 대부분을 차지할 수 있습니다.

자주 묻는 질문 (FAQ)

 

Q: 상용 ESP32 MicroPython 제품에 WIZnet W5500을 사용하는 이유는 무엇인가요? 

 

A: W5500은 하드웨어 TCP/IP 스택, 8개의 독립 소켓, 내부 송수신(Tx/Rx) 버퍼링을 갖춘 유선 이더넷 환경을 제공합니다. 덕분에 MicroPython 애플리케이션은 소켓과 페이로드 레벨의 작업에만 집중할 수 있고, W5500이 이더넷 MAC/PHY 작동, TCP/UDP 동작, 소켓 상태 전환 및 패킷 버퍼링을 알아서 처리해 줍니다.

 

Q: W5500은 ESP32 플랫폼과 어떻게 연결되나요? 

 

A: SCK, MOSI, MISO, CS(칩 선택), Reset, 3.3V 및 GND를 사용하는 SPI 인터페이스를 통해 연결됩니다. 검증된 ESP32 레퍼런스 가이드에 따르면 GPIO5 -> CS, GPIO18 -> SCK, GPIO23 -> MOSI, GPIO19 -> MISO, GPIO34 -> Reset으로 매핑됩니다.

 

Q: 본 프로젝트에서 W5500은 정확히 어떤 역할을 수행하나요? 

 

A: W5500은 유선 이더넷 전송 엔진 역할을 합니다. ESP32 MicroPython은 제품 메시지를 생성하고 설정을 관리하며 드라이버/소켓 계층을 호출하는 상위 작업을 맡고 , W5500은 물리적인 이더넷 링크, 하드웨어 TCP/IP 처리, 소켓 상태 전환 및 RX/TX 버퍼를 관리하는 하위 작업을 맡습니다.

 

Q: 초보자도 이러한 상용 프로토타입 개발 방향을 따라 할 수 있나요? 

 

A: 네, 단계별로 차근차근 구동(Bring-up)한다면 가능합니다. 추천하는 진행 순서는 배선 확인 -> W5500 리셋 확인 -> 칩 버전 읽기 -> MAC/IP 주소 출력 -> DNS 테스트 -> 단일 HTTP 요청 수행 -> 제품 특화 텔레메트리/설정/진단 프로토콜 구현 순입니다.

 

Q: W5500을 사용하는 것이 ESP32 내장 Wi-Fi를 사용하는 것과 어떻게 다른가요? 

 

A: 케이블이 없는 무선 환경이 필수적이라면 ESP32 Wi-Fi가 좋습니다. 반면 W5500을 사용하면 SPI 배선이 추가되고 드라이버 파일을 직접 올려야 하는 번거로움이 있지만, 명확한 리셋 제어, 눈으로 확인 가능한 PHY 상태, 고정된 소켓 자원, 그리고 벤치 디버깅이 용이한 '반복 가능하고 안정적인 유선 경로'를 확보할 수 있습니다. 상용 서비스 포트, 공장 설정 도구, 유선 구성 장치 등에서는 이러한 가시성(Visibility)이 무선의 편리함보다 훨씬 더 가치 있습니다.

Documents
Comments Write