Overview
W5500 Ethernet chip (via WIZ850io) enables SPI-based Ethernet communication on the SP2302, creating a second Ethernet interface (eth1
). This interface can fully support TCP server, TCP client, and UDP socket communication, allowing you to develop embedded applications like device controllers, IoT gateways, or data relays.
Setup Prerequisites
- WIZ850io properly wired via SPI to SP2302
- Dual-port firmware flashed to SP2302 with support for
eth1
- Network check:
bash ip addr show eth1
- Assign a static IP or use DHCP:
Example netplan:
yaml network: version: 2 ethernets: eth1: dhcp4: yes
Apply:
bash sudo netplan apply
Testing TCP & UDP on W5500 (eth1)
All examples below useeth1
(W5500) for communication. Replace IPs with your actualeth1
IP when needed.
1. TCP Server on W5500
Python TCP Server Code
python # tcp_server_w5500.py import socket HOST = '192.168.2.50' # eth1 IP PORT = 5000 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) s.listen() print(f"[+] Listening on {HOST}:{PORT}") conn, addr = s.accept() with conn: print(f"[✓] Connected by {addr}") while True: data = conn.recv(1024) if not data: break print(f"[<] Received: {data.decode()}") conn.sendall(b"ACK: " + data)
Run:
bash python3 tcp_server_w5500.py
2. TCP Client on W5500
Python TCP Client Code
python # tcp_client_w5500.py import socket SERVER_IP = '192.168.2.100' # Remote server IP PORT = 5000 LOCAL_IP = '192.168.2.50' # eth1 IP with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((LOCAL_IP, 0)) # Bind to eth1 s.connect((SERVER_IP, PORT)) s.sendall(b"Hello from W5500 client!") data = s.recv(1024) print(f"[<] Received: {data.decode()}")
3. UDP Communication on W5500
Python UDP Echo Server
python # udp_server_w5500.py import socket HOST = '192.168.2.50' # eth1 IP PORT = 6000 with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: s.bind((HOST, PORT)) print(f"[+] UDP Server listening on {HOST}:{PORT}") while True: data, addr = s.recvfrom(1024) print(f"[<] Received from {addr}: {data.decode()}") s.sendto(b"ACK: " + data, addr)
Python UDP Client
python # udp_client_w5500.py import socket SERVER_IP = '192.168.2.100' PORT = 6000 LOCAL_IP = '192.168.2.50' with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: s.bind((LOCAL_IP, 0)) # Bind to W5500 s.sendto(b"Hello UDP", (SERVER_IP, PORT)) data, addr = s.recvfrom(1024) print(f"[<] Reply: {data.decode()}")
Testing Tools
- Hercules on a PC to test server/client interactions.
Results:
TCP Server

TCP Client

UDP

Debugging Tips
- Use
dmesg | grep eth1
to confirm driver is loaded - Confirm route to target IP using
ip route
- Monitor traffic with
Applications for W5500 Socket Usage
Use Case | Description |
---|---|
Local Device Controller | Accept commands over TCP |
Sensor Gateway | Send UDP packets to edge/cloud |
Secure Proxy | Use TCP to bridge isolated and trusted networks |
Logging Stream Server | UDP-based fire-and-forget telemetry |
Summary
Role | Script | Binds to Interface |
---|---|---|
TCP Server | tcp_server_w5500.py | eth1 |
TCP Client | tcp_client_w5500.py | eth1 |
UDP Server | udp_server_w5500.py | eth1 |
UDP Client | udp_client_w5500.py | eth1 |
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.