Wiznet makers

TheoIm

Published May 14, 2025 ©

34 UCC

25 WCC

5 VAR

0 Contests

0 Followers

0 Following

Original Link

ESP32 + W5500 Ethernet Quick Start Guide

Step-by-step flow: Network Test → Speed Test → Time Sync

COMPONENTS Hardware components

WIZnet - W5500

x 1


Espressif - ESP32

x 1


PROJECT DESCRIPTION


Welcome, fellow makers.
You're about to unlock a rock-solid combo: ESP32 + WIZnet W5500, an Ethernet-capable setup that’s lightweight, deterministic, and ideal for industrial or DIY networked projects.

This post is your armory — not just theory, but curated, field-tested code insights with all the “guns and swords” ready for action.


🔧 The Common Foundation: How ESP32 Talks to WIZnet W5500

All three examples below share a core initialization sequence.
Understand this flow, and you can build anything on top of it.

⚙️ Step 1 – SPI Ethernet Driver Init

 
example_eth_init(&eth_handles, &eth_port_cnt);

Internally configures the SPI bus and W5500 driver

Returns esp_eth_handle_t for use throughout the stack


🌐 Step 2 – Attach to the TCP/IP Stack

esp_netif_new(&cfg);
esp_eth_new_netif_glue(eth_handles[i]);
esp_netif_attach(...);

This “glue” attaches the Ethernet driver to the esp-netif TCP/IP stack

Essential for IP addressing, DHCP, DNS, and more


🚀 Step 3 – Start Ethernet

 
esp_eth_start(eth_handles[i]);

Starts the driver state machine

At this point, DHCP or Static IP kicks in

You're now online


✨ Highlighted Use Cases: Three Scenarios, Three Purposes


1️⃣ Basic DHCP + IP Logging (Minimal Setup)

Plug in and get online — verify that Ethernet is alive and working

🔑 Key Code

 
esp_event_handler_register(... eth_event_handler);
esp_event_handler_register(... got_ip_event_handler);

Registers handlers for Link Up/Down and IP Assigned

Optional: Multiple ports supported with esp_netif_config tweaks

🎯 Purpose

Confirm W5500 is wired correctly

Get an IP via DHCP

Print your network status via logs


2️⃣ Interactive Console + iperf Testing

Bring in the console, type commands, measure performance in real time

🔑 Key Code

 
esp_console_new_repl_uart(...);
app_register_iperf_commands();
esp_console_start_repl(repl);

Launches a UART REPL console

Lets you run commands like iperf -u -s and ethernet info

Great for network benchmarking

🎯 Purpose

Real-world UDP/TCP speed test with iperf

CLI-style UX for debugging or dev boards

Scriptable interface for advanced users


3️⃣ PTP (Precision Time Protocol) + Pulse Output

Use W5500 to generate nanosecond-accurate GPIO pulses — yes, really

🔑 Key Code

 
ptpd_start("ETH_0");
esp_eth_clock_register_target_cb(..., ts_callback);
gpio_set_level(...);

Starts PTPD (Precision Time Daemon)

Waits for clock sync

Then toggles a GPIO at precisely defined intervals (e.g. every X ns)

🎯 Purpose

Industrial-grade timing sync

PTP master/slave logic handled internally

GPIO output in perfect sync with network time


🧭 Summary: Choose Your Weapon

ScenarioUse When You Want To...
① BasicJust get IP and check status
② ConsoleBenchmark speeds & test over UART
③ PTPGenerate precisely timed signals

If you're building a system with W5500 at the core, this is your foundation.

Whether you're writing a driver, building a logger, or syncing real-time events — you now have the full toolkit.

Documents
Comments Write