Wiznet makers

chen

Published June 19, 2026 ©

112 UCC

1 WCC

28 VAR

0 Contests

0 Followers

0 Following

Original Link

How to Build an HTTP Client with WIZnet W5500 on ESP32 MicroPython?

This education-focused project shows how to build a wired Ethernet HTTP client using WIZnet W5500 on an ESP32 running MicroPython.

COMPONENTS
PROJECT DESCRIPTION

How to Build an HTTP Client with WIZnet W5500 on ESP32 MicroPython?

Summary

This education-focused project shows how to build a wired Ethernet HTTP client using WIZnet W5500 on an ESP32 running MicroPython. The ESP32 controls W5500 over SPI, writes network and socket registers, configures a TCP client socket, and sends lightweight HTTP GET requests through W5500’s hardware TCP/IP engine. W5500’s role is to provide the Ethernet MAC/PHY, TCP/IP offload, socket state machine, and internal packet buffering so learners can study embedded Ethernet communication without implementing a full TCP/IP stack on the ESP32.

What the Project Does

The source article builds an ESP32 + W5500 Ethernet communication system and uses MicroPython as the runtime environment for a lightweight HTTP GET client. The project is framed around cases where wired Ethernet is preferred for stable data upload, especially when wireless coverage is weak, interference is high, or deterministic communication is useful for embedded IoT learning.

The data flow is direct. ESP32 executes the MicroPython application, controls W5500 over SPI, writes W5500 global registers for MAC address, gateway, subnet mask, and local IP, then configures Socket 0 as a TCP client for outbound HTTP communication. W5500 handles the lower network transport while ESP32 manages the application payload and register-level driver calls.

The project is useful for education because it exposes the boundary between application code, SPI register access, socket setup, and TCP connection behavior. Instead of treating Ethernet as a black-box network interface, the article walks through reset, chip-ID verification, network parameter configuration, socket mode selection, and low-level read/write operations.

Where WIZnet Fits

The exact WIZnet product is W5500. In this project, W5500 sits between the ESP32 and the Ethernet cable. ESP32 uses SPI to access W5500 registers and socket buffers; W5500 provides the Ethernet MAC/PHY, hardwired TCP/IP stack, socket engine, and internal Tx/Rx memory.

WIZnet documents W5500 as supporting TCP, UDP, ICMP, IPv4, ARP, IGMP, and PPPoE in hardware. It also supports 8 independent sockets, SPI mode 0 and mode 3, 32 KB internal Tx/Rx buffer memory, and an embedded 10Base-T/100Base-TX Ethernet PHY.

For an ESP32 MicroPython learning project, W5500 is a good fit because it makes the network-stack boundary visible. The learner can see which parts are handled by ESP32 firmware, such as SPI transactions and HTTP request construction, and which parts are handled by W5500 hardware, such as TCP connection state and Ethernet packet transport.

Implementation Notes

The source is a CSDN article, not a public source repository. It includes visible MicroPython driver snippets and register configuration details, but it does not provide a complete downloadable project tree. Therefore, the snippets below are quoted only from the visible source article, and file paths are not available.

File: MicroPython W5500 driver code shown in the article
What it configures: low-level W5500 register write and read access through SPI.
Why it matters: all higher-level W5500 behavior depends on correct register and buffer transactions. If the SPI framing, chip select, or returned data alignment is wrong, network initialization will fail before HTTP code is reached.

 
def write_reg(self, addr, data):
    cmd = bytearray([0x00, (addr >> 8) & 0xFF, addr & 0xFF])
    self.spi.write(cmd)
    self.spi.write(data)

def read_reg(self, addr, length=1):
    cmd = bytearray([0x01, (addr >> 8) & 0xFF, addr & 0xFF])
    self.spi.write(cmd)
    dummy = self.spi.read(2)
    return self.spi.read(length)
 

The article presents these functions as the core MicroPython SPI wrapper for W5500 register access. It also notes that register reads must discard dummy bytes before using the returned payload, because otherwise subsequent data can become misaligned.

File: register initialization flow described in the article
What it configures: W5500 identity, network parameters, and TCP client socket setup.
Why it matters: HTTP GET is an outbound client operation, so the socket must be configured as a TCP client after the W5500 global network registers have been initialized.

 
VERSIONR -> expected value 0x04
SHAR     -> source MAC address
GAR      -> gateway address
SUBR     -> subnet mask
SIPR     -> local IP address
Sn_MR    -> Socket 0 TCP mode
Sn_PORT  -> local port
Sn_DHAR  -> destination MAC placeholder before ARP resolution
 

This sequence exists because W5500 separates global network registers from per-socket registers. The article describes reset first, then VERSIONR checking, then network register writes, then Socket 0 configuration for TCP client mode.

For classroom use, this implementation is useful because each step maps to a concrete debugging question: Is SPI working? Does VERSIONR return the expected value? Are MAC/IP/subnet/gateway registers correct? Is the socket configured as TCP? Does the socket state move after a connection attempt?

Practical Tips / Pitfalls

  • Verify VERSIONR before debugging HTTP. A failed version read usually means SPI, chip select, power, or reset is wrong.
  • Keep SPI wiring short and stable. The article recommends using a conservative SPI clock such as 20 MHz in practical engineering even though W5500 supports higher SPI rates.
  • Configure network registers before opening sockets. SHAR, GAR, SUBR, and SIPR define the device’s identity on the network.
  • Treat Socket 0 as a state machine. Write the mode register, issue commands, then check socket status instead of assuming fixed delays are enough.
  • Use stable 3.3 V power and local decoupling near the W5500 module. Ethernet PHY instability can look like firmware failure.
  • Keep the first HTTP request simple. Test one HTTP GET path before adding headers, retries, JSON parsing, or sensor upload logic.

FAQ

Q: Why use WIZnet W5500 for an ESP32 MicroPython HTTP client?
A: W5500 lets ESP32 use wired Ethernet with a hardwired TCP/IP stack. For education, that is useful because students can focus on SPI transactions, register setup, socket state, and HTTP request flow without writing ARP, IP, and TCP logic in MicroPython.

Q: How does W5500 connect to the ESP32 platform?
A: W5500 connects to ESP32 through SPI using clock, MOSI, MISO, chip select, reset, 3.3 V, and ground. WIZnet specifies high-speed SPI support in mode 0 and mode 3, while the source article emphasizes reset timing, chip-select behavior, and signal-integrity checks during bring-up.

Q: What role does W5500 play in this project?
A: W5500 is the Ethernet network co-processor. ESP32 writes registers and builds the HTTP request, while W5500 handles the wired Ethernet path, hardware TCP/IP processing, socket state, ARP-related behavior, and packet buffering.

Q: Can beginners follow this project?
A: Yes, if they already understand basic ESP32 MicroPython, SPI wiring, IPv4 addressing, and the idea of TCP client connections. The best learning path is to read VERSIONR, configure static network parameters, open one TCP client socket, then send one minimal HTTP GET request.

Q: How is this different from using the ESP32’s built-in Wi-Fi for HTTP?
A: With ESP32 Wi-Fi, the network interface is integrated into the ESP32 environment and most learners work at a higher API level. With W5500, the learner sees the Ethernet controller boundary directly: SPI commands, global registers, socket registers, TX/RX buffers, and socket states. That makes it better for studying embedded wired Ethernet internals, even though it requires more wiring and driver work.

Source

Original article: CSDN, “ESP32+W5500以太网HTTP客户端实战.” The accessible page identifies the project as an ESP32 + W5500 Ethernet HTTP client using MicroPython and shows register setup plus low-level SPI driver snippets. License is not stated on the accessible page.

WIZnet product reference: W5500 documentation and feature list, including hardware protocols, 8 sockets, SPI mode support, 32 KB Tx/Rx buffer memory, and embedded 10/100 Ethernet PHY.

WIZnet software reference: ioLibrary Driver, described by WIZnet as an MCU-independent library for WIZnet W5x00 and W6x00 chips, with supported services including DHCP, DNS, MQTT, SNTP, TFTP, and HTTP Server.

Tags

#W5500 #WIZnet #ESP32 #MicroPython #HTTPClient #Education #SPI #Ethernet #NetworkStack #Registers #Socket #Firmware #EmbeddedNetworking

 

ESP32 MicroPython에서 WIZnet W5500으로 HTTP Client를 구현하는 방법은?

요약

이 교육용 프로젝트는 ESP32 MicroPython 환경에서 WIZnet W5500을 사용해 유선 Ethernet HTTP client를 구현하는 방법을 보여줍니다. ESP32는 SPI로 W5500을 제어하고, network 및 socket register를 설정하며, TCP client socket을 구성한 뒤 W5500의 하드웨어 TCP/IP 엔진을 통해 가벼운 HTTP GET 요청을 전송합니다. W5500의 역할은 Ethernet MAC/PHY, TCP/IP 오프로딩, socket state machine, 내부 packet buffering을 제공하는 것입니다. 이를 통해 학습자는 ESP32에서 전체 TCP/IP stack을 직접 구현하지 않고도 embedded Ethernet 통신 구조를 이해할 수 있습니다.

프로젝트가 하는 일

원문은 ESP32 + W5500 Ethernet 통신 시스템을 구성하고, MicroPython 런타임에서 lightweight HTTP GET client를 구현합니다. 이 프로젝트는 무선 커버리지가 약하거나 간섭이 크거나, embedded IoT 학습에서 더 안정적인 유선 통신이 필요한 상황을 중심으로 설명됩니다.

데이터 흐름은 명확합니다. ESP32는 MicroPython 애플리케이션을 실행하고, SPI로 W5500을 제어합니다. 이후 MAC address, gateway, subnet mask, local IP를 위한 W5500 global register를 설정하고, outbound HTTP 통신을 위해 Socket 0을 TCP client로 구성합니다. W5500은 하위 네트워크 전송을 처리하고, ESP32는 애플리케이션 payload와 register-level driver 호출을 관리합니다.

이 프로젝트는 교육용으로 유용합니다. Application code, SPI register access, socket setup, TCP connection behavior 사이의 경계를 직접 보여주기 때문입니다. Ethernet을 black-box network interface로만 사용하는 대신, reset, chip-ID verification, network parameter configuration, socket mode selection, low-level read/write operation을 단계적으로 다룹니다.

WIZnet이 들어가는 위치

이 프로젝트에서 사용되는 정확한 WIZnet 제품은 W5500입니다. W5500은 ESP32와 Ethernet cable 사이에 위치합니다. ESP32는 SPI를 통해 W5500 register와 socket buffer에 접근하고, W5500은 Ethernet MAC/PHY, hardwired TCP/IP stack, socket engine, 내부 Tx/Rx memory를 제공합니다.

WIZnet 문서 기준으로 W5500은 TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE를 하드웨어로 지원합니다. 또한 8개 independent socket, SPI mode 0 및 mode 3, 32 KB internal Tx/Rx buffer memory, embedded 10Base-T/100Base-TX Ethernet PHY를 지원합니다.

ESP32 MicroPython 학습 프로젝트에서 W5500은 네트워크 스택의 경계를 명확하게 보여주기 때문에 적합합니다. 학습자는 SPI transaction과 HTTP request construction처럼 ESP32 firmware가 처리하는 부분과, TCP connection state 및 Ethernet packet transport처럼 W5500 hardware가 처리하는 부분을 구분해서 볼 수 있습니다.

구현 참고 사항

소스는 CSDN 글이며 공개 소스 저장소는 아닙니다. 원문에는 MicroPython driver snippet과 register configuration detail이 보이지만, 완전한 다운로드 가능한 project tree는 제공되지 않습니다. 따라서 아래 snippet은 원문에서 보이는 부분만 인용한 것이며, file path는 제공되지 않습니다.

파일: 원문에 표시된 MicroPython W5500 driver code
설정 내용: SPI를 통한 low-level W5500 register write/read access
중요한 이유: 모든 상위 W5500 동작은 올바른 register 및 buffer transaction에 의존합니다. SPI framing, chip select, 반환 데이터 정렬이 잘못되면 HTTP code에 도달하기 전에 network initialization이 실패합니다.

 
def write_reg(self, addr, data):
    cmd = bytearray([0x00, (addr >> 8) & 0xFF, addr & 0xFF])
    self.spi.write(cmd)
    self.spi.write(data)

def read_reg(self, addr, length=1):
    cmd = bytearray([0x01, (addr >> 8) & 0xFF, addr & 0xFF])
    self.spi.write(cmd)
    dummy = self.spi.read(2)
    return self.spi.read(length)
 

원문은 이 함수들을 W5500 register access를 위한 핵심 MicroPython SPI wrapper로 제시합니다. 또한 register read 시 반환 payload를 사용하기 전에 dummy byte를 버려야 한다고 설명합니다. 그렇지 않으면 이후 데이터가 잘못 정렬될 수 있습니다.

파일: 원문에서 설명한 register initialization flow
설정 내용: W5500 identity, network parameter, TCP client socket setup
중요한 이유: HTTP GET은 outbound client operation이므로, W5500 global network register 초기화 이후 socket을 TCP client로 설정해야 합니다.

 
VERSIONR -> expected value 0x04
SHAR     -> source MAC address
GAR      -> gateway address
SUBR     -> subnet mask
SIPR     -> local IP address
Sn_MR    -> Socket 0 TCP mode
Sn_PORT  -> local port
Sn_DHAR  -> destination MAC placeholder before ARP resolution
 

이 순서는 W5500이 global network register와 per-socket register를 분리하기 때문에 필요합니다. 원문은 reset을 먼저 수행하고, VERSIONR 확인, network register write, Socket 0 TCP client mode 설정 순서로 설명합니다.

교육 현장에서는 이 구현이 유용합니다. 각 단계가 구체적인 디버깅 질문으로 이어지기 때문입니다. SPI가 동작하는가, VERSIONR이 기대값을 반환하는가, MAC/IP/subnet/gateway register가 올바른가, socket이 TCP로 설정되었는가, connection attempt 이후 socket state가 바뀌는가를 단계적으로 확인할 수 있습니다.

실무 팁 / 주의점

  • HTTP를 디버깅하기 전에 VERSIONR을 먼저 확인해야 합니다. Version read 실패는 대개 SPI, chip select, power, reset 문제입니다.
  • SPI 배선은 짧고 안정적으로 유지해야 합니다. W5500은 더 높은 SPI 속도를 지원하지만, 원문은 실제 엔지니어링에서는 20 MHz 같은 보수적인 SPI clock 사용을 권장합니다.
  • Socket을 열기 전에 network register를 설정해야 합니다. SHAR, GAR, SUBR, SIPR은 네트워크에서 장치가 어떤 identity를 갖는지 정의합니다.
  • Socket 0은 state machine으로 다뤄야 합니다. Mode register를 쓰고 command를 실행한 뒤, fixed delay에 의존하지 말고 socket status를 확인해야 합니다.
  • 안정적인 3.3 V 전원과 W5500 모듈 근처의 local decoupling을 사용해야 합니다. Ethernet PHY 불안정은 firmware failure처럼 보일 수 있습니다.
  • 첫 HTTP request는 단순하게 유지해야 합니다. Header, retry, JSON parsing, sensor upload logic을 추가하기 전에 하나의 HTTP GET 경로부터 테스트하는 것이 좋습니다.

FAQ

Q: ESP32 MicroPython HTTP client에 왜 WIZnet W5500을 사용하나요?
A: W5500은 ESP32가 hardwired TCP/IP stack을 갖춘 유선 Ethernet을 사용할 수 있게 합니다. 교육용으로는 학생들이 MicroPython에서 ARP, IP, TCP logic을 직접 작성하지 않고도 SPI transaction, register setup, socket state, HTTP request flow에 집중할 수 있어 유용합니다.

Q: W5500은 ESP32 플랫폼에 어떻게 연결되나요?
A: W5500은 clock, MOSI, MISO, chip select, reset, 3.3 V, ground를 사용하는 SPI로 ESP32에 연결됩니다. WIZnet은 W5500이 SPI mode 0 및 mode 3에서 고속 SPI를 지원한다고 명시하며, 원문은 bring-up 과정에서 reset timing, chip-select behavior, signal-integrity check를 강조합니다.

Q: 이 프로젝트에서 W5500은 어떤 역할을 하나요?
A: W5500은 Ethernet network co-processor입니다. ESP32는 register를 쓰고 HTTP request를 구성하며, W5500은 유선 Ethernet 경로, hardware TCP/IP processing, socket state, ARP 관련 동작, packet buffering을 처리합니다.

Q: 초보자도 이 프로젝트를 따라갈 수 있나요?
A: 기본 ESP32 MicroPython, SPI 배선, IPv4 주소 지정, TCP client connection 개념을 이해하고 있다면 가능합니다. 권장 학습 순서는 VERSIONR 읽기, static network parameter 설정, 하나의 TCP client socket 열기, minimal HTTP GET request 전송입니다.

Q: ESP32 내장 Wi-Fi로 HTTP를 사용하는 것과 어떻게 다른가요?
A: ESP32 Wi-Fi를 사용하면 network interface가 ESP32 환경에 통합되어 있어 대부분 더 높은 API 수준에서 작업합니다. W5500을 사용하면 SPI command, global register, socket register, TX/RX buffer, socket state처럼 Ethernet controller의 경계를 직접 볼 수 있습니다. 따라서 배선과 driver 작업은 더 필요하지만, embedded wired Ethernet 내부 구조 학습에는 더 적합합니다.

출처

Original article: CSDN, “ESP32+W5500以太网HTTP客户端实战.” 접근 가능한 페이지는 이 프로젝트가 ESP32 + W5500 Ethernet HTTP client이며 MicroPython을 사용하고, register setup 및 low-level SPI driver snippet을 보여줍니다. 접근 가능한 페이지에는 라이선스가 명시되어 있지 않습니다.
https://blog.csdn.net/weixin_32389853/article/details/158250760

WIZnet product reference: W5500 documentation and feature list, including hardware protocols, 8 sockets, SPI mode support, 32 KB Tx/Rx buffer memory, and embedded 10/100 Ethernet PHY.
https://docs.wiznet.io/Product/Chip/Ethernet/W5500

WIZnet software reference: ioLibrary Driver, described by WIZnet as an MCU-independent library for WIZnet W5x00 and W6x00 chips, with supported services including DHCP, DNS, MQTT, SNTP, TFTP, and HTTP Server.
https://github.com/Wiznet/ioLibrary_Driver

태그

#W5500 #WIZnet #ESP32 #MicroPython #HTTPClient #Education #SPI #Ethernet #NetworkStack #Registers #Socket #Firmware #EmbeddedNetworking

Documents
Comments Write