Wiznet makers

bruno

Published October 16, 2025 ©

115 UCC

14 WCC

28 VAR

0 Contests

0 Followers

0 Following

Original Link

Ethernet Controller: Implement TCP Client–Server using W5500 & STM32 MCU.

Rewatch our session with IoT expert Umesh Lokhande to learn how to implement TCP client–server communication using WIZnet W5500 and STM32 MCU.

COMPONENTS
PROJECT DESCRIPTION

This content was written by DevHeads on the  Youtube.
Original link:  https://www.youtube.com/watch?v=_19ZBA86IGc 

 

 

TL;DR
Using an STM32 Nucleo-32 (low-cost MCU) and a WIZnet W5500 module, you can add wired Ethernet over SPI and implement a TCP server in minutes. The video walks through static IP setup, link (auto-negotiation) handling, socket APIs, and the WIZnet IO Library porting points—ending with a live demo that toggles an LED via TCP messages "on" / "off".


Who should watch

Makers who want Ethernet on MCUs without a built-in MAC

Embedded developers needing simple TCP/UDP connectivity

Anyone curious how Arduino Ethernet Shield 2 (W5500) works under the hood


What you’ll learn

1) Hardware & Live Demo

MCU: STM32 Nucleo-32 (no internal Ethernet MAC)

Ethernet: WIZnet W5500 (MAC + PHY + hardware TCP/IP, 10/100 Mbps)

Interface: SPI (Mode 0) + RESET/INT lines

Demo flow: MCU runs a TCP server on port 5000 → PC (Hercules TCP Client) sends "on" / "off" → board LED toggles and server responds with "LED is on/off"

Link handling: Cable unplug shows waiting for link...; replug triggers automatic recovery (Auto-Negotiation)

2) Minimal Network Setup (small local subnet)

PC example: 192.168.2.2/24, gateway 192.168.2.1

W5500 (static): 192.168.2.99/24, port 5000

Static IP is used in the demo for easy debugging and reproducibility (DHCP also supported)

3) IO Library (Internet Offload Library) & Porting

Why it’s nice: TCP/IP runs in hardware on W5500 → lower MCU load

Files:

Device-specific: w5500.c/.h

Common: socket.c/.h, wizchip_conf.c/.h

Your MCU glue (6 small functions)

Chip select: wizchip_select() / wizchip_unselect()

SPI I/O: wizchip_read(byte/burst), wizchip_write(byte/burst)

Init: wizchip_init() → set RX/TX buffers, verify link status

Buffers/Sockets: 32 KB on-chip (16 KB RX / 16 KB TX), up to 8 sockets

4) Two SPI wiring modes

VDM (Variable Length Data Mode)recommended: CS to a GPIO so you can share the SPI bus with other devices

FDM (Fixed Length Data Mode): CS tied to GND (saves a pin, but single-purpose bus)

5) Creating a TCP server with socket API

Example: socket(0, SN_MR_TCP, 5000, 0);

Loop: accept client → parse "on"/"off" → toggle LED → send reply

Continuous link/session monitoring keeps the server robust through cable events


Why choose W5500?

Hardware TCP/IP: no heavy stack on the MCU → less code, less RAM/flash

10/100 Mbps + Auto-Negotiation: adapts to the network automatically

MCU-agnostic: any SPI-capable MCU works (even 8-bit)

Great cost/complexity balance vs. high-end MAC-integrated MCUs

Quick comparison

ENC28J60: very low cost, but 10 Mbps and software stack on MCU (more resources)

MCU with built-in MAC: best throughput/latency for multimedia or heavy traffic, but BOM and complexity increase


Try it yourself – quick checklist

Wire it: SPI (MISO/MOSI/SCK/CS) + RESET/INT, LED to a GPIO

Firmware: add IO Library → implement the 6 SPI/CS callbacks → wizchip_init() → set static IP in netinfo

Open socket: socket() TCP on port 5000, listen

PC client: use Hercules; enter server IP/port and Connect

Test: send "on" / "off" → confirm LED and reply messages

Link test: unplug/replug Ethernet and watch logs auto-recover


Where to take it next

Switch to UDP (SN_MR_UDP) for lightweight messaging

Use multiple sockets (status vs. control)

Add RTOS and higher-level protocols (HTTP/MQTT)

Next session teaser: implementing Modbus TCP on STM32 with W5500 for industrial use cases


Q&A highlights from the video

High bandwidth / streaming: for audio/video or very high throughput, consider an MCU with built-in MAC, adequate SRAM/flash, DMA, and an RTOS TCP/IP stack (e.g., ThreadX/lwIP).

Automotive: Automotive Ethernet is its own ecosystem; high speed and low latency needs drive Ethernet adoption there.


Resources

Example code and project structure are shown in the video (author’s GitHub referenced in the video description).

Join the community mentioned in the video for upcoming sessions and deeper dives.

Share your W5500 Ethernet builds on maker.wiznet.io—projects, tips, and lessons learned are all welcome! 🚀

 

 

Korean Ver

한 줄 요약(TL;DR)
STM32 Nucleo-32(저가 MCU) + WIZnet W5500 모듈만으로 하드웨어 TCP/IP 스택을 활용해 SPI로 간단히 TCP 서버를 구현하고, PC의 TCP 클라이언트(Hercules)에서 "on" / "off" 메시지를 보내 LED 제어까지 시연합니다. 네트워크 링크 분리/재연결 감지(오토 네고시에이션), 정적 IP 설정, 소켓 API 사용법, 드라이버(IO Library) 포팅 포인트까지 한 번에 정리한 실전형 콘텐츠예요.


이런 분께 추천

이더넷 PHY 내장되지 않은 MCU에 유선 이더넷을 추가하고 싶은 분

작고 간단한 네트워킹 기능(TCP/UDP)을 프로젝트에 넣어야 하는 메이커/임베디드 개발자

Arduino Ethernet Shield 2(W5500 기반)의 원리펌웨어 통합 흐름이 궁금한 분


영상 핵심 포인트

1) 하드웨어 구성 & 데모 개요

MCU: STM32 Nucleo-32 (저가형, 내장 MAC 없음)

이더넷 모듈: WIZnet W5500 (MAC + PHY + 하드웨어 TCP/IP 스택, 10/100Mbps)

연결: MCU ↔ W5500 SPI (Mode 0), 추가로 RESET/INT 라인 사용

데모: MCU에 TCP 서버(포트 5000) 실행 → PC의 Hercules TCP Client에서

"on" 전송 → 보드 LED 점등, 서버가 "LED is on" 응답

"off" 전송 → 보드 LED 소등, 서버가 "LED is off" 응답

링크 감지: LAN 케이블 분리 시 waiting for link... 출력, 다시 연결하면 자동 복구(Auto-Negotiation)

2) 네트워크 설정(소규모 로컬망)

예시: PC를 192.168.2.2, 게이트웨이를 192.168.2.1로 수동 설정

보드(W5500)는 정적 IP 예: 192.168.2.99/24 사용

포트: 5000(임의 지정)

DHCP도 가능하지만, 본 데모는 정적 IP로 구성해 디버깅과 재현성을 높였습니다.

3) IO Library(Internet Offload Library) 구조 & 포팅 포인트

장점: TCP/IP가 W5500 하드웨어에 구현 → MCU는 저부하로 네트워킹 가능

구성:

w5500.c/.h (디바이스 전용)

socket.c/.h, wizchip_conf.c/.h (공용)

포팅 시 핵심 6개 함수

CS 제어: wizchip_select() / wizchip_unselect()

SPI 전송: wizchip_read(byte/burst), wizchip_write(byte/burst)

초기화: wizchip_init()RX/TX 버퍼 크기 설정 및 링크 상태 확인

버퍼/소켓: 32KB 내장 메모리(16KB RX / 16KB TX), 최대 8소켓. 예제에선 소켓0을 TCP로 사용

4) SPI 두 가지 연결 모드

VDM(Variable Length Data Mode): 권장. CS를 GPIO에 연결해 다른 SPI 디바이스와 공용 가능

FDM(Fixed Length Data Mode): CS를 GND 고정(핀 절약), 단일 용도 버스에 적합

5) 소켓 API로 TCP 서버 만들기

socket(sock=0, type=SN_MR_TCP, port=5000, flag=0);

연결 수립 후 루프에서 수신 데이터 파싱 → LED 제어 → 응답 전송

링크/세션 모니터링 로직으로 케이블 분리·복귀 상황에도 안정적


왜 W5500인가?

하드웨어 TCP/IP: MCU가 스택을 직접 돌리지 않아도 됨 → 코드/메모리 부담↓

10/100Mbps, 오토 네고시에이션: 다양한 네트워크 환경에 자동 적응

SPI만 있으면 OK: 8bit MCU부터 다양한 MCU에 손쉽게 이더넷 추가

원가·복잡도 밸런스: 고가의 MAC 내장 MCU 대비 간단/경제적 솔루션

참고 비교

ENC28J60: 저가, 10Mbps, 소프트웨어 스택 필요( MCU 자원 사용↑ )

MAC 내장 MCU: 대역폭/지연 특성 우수(멀티미디어/고속 처리에 유리) but 복잡도·원가↑


따라해보기 체크리스트

배선: SPI(MISO/MOSI/SCK/CS) + RESET/INT, LED(GPIO)

펌웨어: IO Library 편입 → SPI 콜백 6개 구현 → wizchip_init()netinfo정적 IP 설정

소켓 오픈: socket()으로 TCP(포트 5000) 리슨

PC 클라이언트 준비: Hercules TCP Client에서 서버 IP/포트 입력 후 connect

테스트: "on"/"off" 전송 → LED 동작 & 응답 메시지 확인

링크 테스트: 케이블 분리/연결 시 로그와 자동 복구 동작 확인


확장 아이디어

UDP 모드 전환 테스트: SN_MR_UDP

멀티소켓 활용(예: 상태 모니터링 + 제어 분리)

외부 메모리/RTOS로 더 복잡한 프로토콜(HTTP/MQTT) 시도

다음 편 예고: Modbus TCP 서버 구현으로 산업용 활용까지 확장


영상 속 Q&A 한 줄 정리

고대역폭/스트리밍: 오디오·비디오 등 대용량은 MAC 내장 MCU(+ DMA, 충분한 SRAM)와 RTOS 스택(예: ThreadX, lwIP) 고려

자동차 분야: Automotive Ethernet은 별도 규격/생태계. 고속·저지연 요구에 이더넷 채택 사례 다수


참고/자료

영상에서 소개된 DevHeads Discord/사이트에서 후속 세션 및 자료 확인 가능

예제 코드는 발표자의 GitHub에 공개(영상 설명 참조)


메이커 여러분의 W5500 이더넷 프로젝트를 maker.wiznet.io에서 소개해 주세요!
질문/피드백/성공기 공유는 언제나 환영합니다 🙌

Documents
Comments Write