Wiznet makers

Grace_Koo

Published May 13, 2026 ©

71 UCC

25 WCC

11 VAR

0 Contests

0 Followers

0 Following

Original Link

MWRouter

ESP32-S3 + W5500 open-source soft router firmware with multi-WAN failover across LTE, Wi-Fi, and wired Ethernet.

COMPONENTS Hardware components

WIZnet - W5500

x 1


PROJECT DESCRIPTION

Multi-WAN Soft Router Built with ESP32-S3 and W5500 — MWRouter

In One Sentence

"An open-source soft router firmware for ESP32-S3 that registers 4G LTE, Wi-Fi, and wired Ethernet as WAN candidates and automatically switches between them based on priority and failure detection."

A typical router has a single WAN port. If that connection goes down, so does the internet. MWRouter addresses this limitation on an ESP32-S3. It registers 4G LTE (USB PPP), Wi-Fi STA, and W5500 wired Ethernet as WAN candidates, then automatically switches the active WAN based on priority and link health. Downstream devices are served via SoftAP, wired LAN, and SPI bridge.

Currently at V0.0.1 (May 2026), this is an early-stage project with promising development ahead.


Key Concepts

What is Multi-WAN?
Multiple internet connections (WANs) are registered as candidates. One is kept active based on priority, and if it fails, the system automatically switches to the next one. This failover approach is commonly used in factories, retail stores, and remote sites where connectivity reliability is critical.

What is a Soft Router?
A soft router implements routing functions — NAT, DHCP, traffic forwarding — in software on a general-purpose MCU, without dedicated router hardware. MWRouter uses LwIP NAPT within ESP-IDF to achieve this.


Hardware Setup

ComponentDetailsNotes
MCUESP32-S3 (PSRAM module recommended)Primary target
Wired EthernetW5500 (SPI-connected)Dynamically switches between WAN and LAN
Cellular WANUSB CDC Cat.1 / LTE module (PPPoS)4G uplink
Wi-FiESP32-S3 built-inSTA (WAN) or SoftAP (LAN)
SPI BridgeDownstream MCU via SPISeparate SPI bus from W5500
StorageLittleFS (web UI static files)Settings saved to NVS

Features

Multi-WAN — Link Redundancy and Automatic Failover

USB 4G modem, Wi-Fi STA, and W5500 wired Ethernet are all registered as WAN candidates. The multiwan component manages a priority list, failure detection, minimum switchover intervals, and application-level probing. When the active WAN fails, it switches to the next candidate automatically. This is a priority-based failover structure — not simultaneous multi-WAN activation.

37 WAN/LAN Combination Modes

mwr_work_mode_profile defines 37 operation modes. For example: "4G uplink → serve Wi-Fi + wired + SPI downstream", or "Wi-Fi STA uplink → SoftAP + wired LAN". Modes are selectable via the Web UI or NVS.

W5500 — Dynamic WAN/LAN Role Switching

This is the most distinctive use of W5500 in this project. The same RJ45 port switches roles depending on the selected mode — either as internet input (ETH_WAN) or downstream device connection (ETH_LAN).

[Mode Examples]
Mode A: W5500 → ETH_WAN (wired internet input)
          ESP32 SoftAP + SPI → LAN

Mode B: W5500 → ETH_LAN (downstream device connection)
          USB 4G → WAN
          ESP32 SoftAP → LAN

Web UI Configuration

A REST API built on esp_http_server and static web pages stored in LittleFS allow browser-based configuration. Wi-Fi AP/STA settings, network configuration, and mode switching are all handled through the web interface. The web service is started before bridge interfaces are created, minimizing the window where connections are refused during boot.

Stability and Self-Recovery

The design shows clear consideration for long-term operation.

  • WAN keepalive after 4G PPP connection to prevent silent cellular disconnects
  • Soft PPP re-dial under memory pressure (no full reboot needed)
  • LwIP PBUF watermark monitoring and SPI packet loss alerts
  • Periodic heap memory and LwIP statistics logging

System Architecture

Generated by Gemini

The Role of WIZnet W5500

In MWRouter, W5500 is more than just an Ethernet port. There are two reasons it stands out in this project.

① Dynamic WAN/LAN Role Switching

The same W5500 chip (a single RJ45 port) changes its role depending on the selected work mode.

  • Wired internet available → ETH_WAN (internet input)
  • 4G as primary WAN → ETH_LAN (downstream device connection)

Unlike the typical fixed-role Ethernet port, the same hardware serves both WAN and LAN depending on configuration — no hardware changes needed.

② Boot Sequence Design

W5500 detection (system_w5500_detect_run()) runs first during early boot — before USB host or SPI bridge initialization — to prevent SPI resource conflicts. Based on the detection result, network interfaces are created selectively. If W5500 is not present, the corresponding interface is quietly skipped, giving the system hardware configuration flexibility.


Current Status and Roadmap

MWRouter has just released V0.0.1 and is actively under development. The roadmap items the developer has explicitly documented give a clear sense of direction.

  • SPI throughput: Confirm DMA usage, evaluate packet aggregation, hardware READY/handshake GPIO
  • Zero-copy path: Use pbuf/DMA directly to reduce memcpy overhead
  • Bus isolation: Separate W5500 and SPI bridge MCU onto independent SPI hosts (SPI2/SPI3)
  • NAPT table and LwIP tuning: Improve memory efficiency for long-running deployments

Multi-WAN soft router implementations on ESP32-S3 + W5500 are rare, and real demand exists in industrial IoT gateways and edge router applications — making this an early project worth watching.


Tech Stack Summary

ComponentDetails
MCUESP32-S3
Firmware FrameworkESP-IDF (C)
Wired EthernetWIZnet W5500 (espressif/w5500 component)
Network StackLwIP (NAPT, TCP/IP)
CellularUSB CDC PPPoS (Cat.1/LTE)
FilesystemLittleFS (web UI)
Configuration StorageNVS (Non-Volatile Storage)
Base FrameworkEspressif esp-iot-bridge
LicenseApache-2.0

FAQ

Q1. Why use W5500 over ESP32-S3's built-in Wi-Fi for the WAN connection?

A. Wi-Fi is already used for SoftAP (LAN) or Wi-Fi STA (WAN), so adding W5500 provides a fully separate wired interface. This avoids contention on the single Wi-Fi radio and gives a stable, low-latency uplink or downstream port that can be dynamically assigned as ETH_WAN or ETH_LAN depending on the deployment.

Q2. Is this suitable for production use?

A. Not yet. MWRouter is at V0.0.1 and still under active development. The developer has documented known issues around long-running memory pressure (LwIP PBUF exhaustion under PPP + NAT + SPI load) and has outlined further tuning work ahead. It's best evaluated as a capable prototype and a strong foundation for a production-ready build.

Q3. Can W5500 and the SPI bridge to a downstream MCU share the same SPI bus?

A. Currently they can coexist on the same bus with proper CS pin management, but the developer explicitly lists bus isolation — moving W5500 and the SPI bridge onto separate SPI hosts (SPI2/SPI3) — as a near-term optimization goal to reduce mutex contention and timing jitter.


Project Links

Documents
Comments Write