Wiznet makers

Aimee0

Published February 27, 2026 ©

79 UCC

23 WCC

15 VAR

0 Contests

0 Followers

0 Following

Original Link

EthWiFiManager

EthWiFiManager enables Ethernet-first connectivity on ESP32, with automatic Wi-Fi fallback to maintain stable network access in industrial environments.

COMPONENTS Hardware components

WIZnet - W5500

x 1


PROJECT DESCRIPTION
Image generated by ChatGPT (OpenAI)

📌 Overview

EthWiFiManagerESP32에서 “유선(SPI Ethernet) 우선 + Wi-Fi 자동 폴백(fallback)” 연결 정책을 제공하는 라이브러리입니다. 즉, 평소에는 W5500 같은 SPI 이더넷을 주 연결로 쓰고, 케이블 단선/스위치 장애 등으로 유선이 불안정해지면 Wi-Fi로 자동 전환하는 방식입니다.

📌 Features

  • 유선 우선 + Wi-Fi 폴백(Combined mode): 기본은 이더넷을 우선 사용하고 장애 시 Wi-Fi로 자동 전환합니다.
  • Wi-Fi Only 모드 지원: 설정으로 이더넷을 비활성화하고 Wi-Fi만 사용 가능합니다.
  • DHCP 기본 지원(유선/무선 모두): 현장 설치 시 네트워크 설정 부담을 줄입니다.
  • 유선/무선 각각 Static IP 옵션 제공: 고정 IP가 필요한 설비망(OT망)에서도 적용 여지가 있습니다.
  • WiFi와 유사한 단순 API: begin(), status(), localIP() 등 최소 학습으로 적용 가능한 형태입니다.
  • AP Router 모드 지원 (옵션 기능) : 조건부 컴파일 시 ESP32가 Wi-Fi AP를 생성하고, Ethernet을 WAN으로 사용하여 소형 NAT Router로 동작할 수 있습니다.

📌 System Architecture

구성 요소

  • ESP32(MCU/SoC) + SPI Ethernet 모듈(W5500 등) + 내장 Wi-Fi
  • 스위치/라우터(유선망) 및 Wi-Fi AP(무선망)
  • 상위 서버/클라우드(MQTT/HTTP/TCP 등 애플리케이션 프로토콜은 프로젝트에 따라 선택)

데이터 흐름

  • 정상: ESP32 ⇄(SPI)⇄ W5500 ⇄(Ethernet)⇄ LAN/Internet
  • 장애/단선: 링크/드라이버 상태를 기반으로 Wi-Fi로 전환하여 연결 유지

구현 기반: ESP-IDF의 이더넷 드라이버를 사용하며, SPI 이더넷 모듈(W5500/DM9051/KSZ8851SNL)을 선택 가능하도록 되어 있습니다.

📌Code Implementation

Link : https://github.com/gmag11/EthWiFiManager/blob/main/src/EthWiFiManager.cpp

EthWiFiManager는 ESP-IDF 이벤트 기반 구조로 동작합니다.
Wi-Fi, Ethernet, IP 이벤트를 각각 등록하고(esp_event_handler_register),
링크 상태 및 IP 획득 여부에 따라 네트워크 경로를 자동 전환합니다.

✔ 유선 우선 로직의 핵심

  • 기준 변수: m_ethHasIp
  • Ethernet이 IP를 획득하면 → Wi-Fi 중지
  • Ethernet이 링크 다운되면 → Wi-Fi 자동 시작

즉, 단순 링크 상태가 아니라 “실제 IP 보유 여부”를 기준으로 우선순위를 결정합니다.

✔ DHCP / Static IP 모두 지원

  • Wi-Fi: WiFi.config() 또는 DHCP
  • Ethernet: esp_netif_set_ip_info() 또는 DHCP client

유선/무선 모두 동일한 정책 구조로 설계되어 있습니다.

✔ SPI Ethernet 모듈 자동 감지

probeSpiModule()에서 SPI로 실제 칩 레지스터를 읽어
W5500(VERSIONR=0x04) 등 모듈 존재 여부를 확인합니다.

감지 실패 시:

  • Ethernet 비활성화
  • Wi-Fi Only 모드로 자동 전환

현장 설치 오류에 대비한 안전 설계입니다.

✔ AP Router 모드 (옵션 기능)

조건부 컴파일 시:

  • ESP32가 Wi-Fi AP 생성
  • Ethernet을 WAN으로 사용
  • lwIP NAPT 활성화
  • DNS 프록시 태스크 실행

즉, 단순 연결 관리에서 소형 라우터 기능까지 확장 가능합니다.

📌 Role and Application of the WIZnet's Chip

사용된 WIZnet 칩: W5500 

네트워크에서의 역할

  • 본 라이브러리 관점에서 W5500은 **SPI 기반 유선 이더넷 인터페이스(10/100 MAC+PHY 포함)**로 동작하며, 유선 연결을 “기본 주 경로”로 제공합니다.

📌 Market & Application Value

적용 가능한 산업/시장

  • 스마트 팩토리/산업 자동화(OT): Wi-Fi 음영/간섭이 있는 현장에서 유선 우선 정책은 운영 안정성에 직접 기여합니다.
  • 빌딩/시설 관리, 에너지 모니터링, 키오스크/PoS, 물류 게이트웨이: “유선이 기본이되, 장애 시 무선으로 살아남는” 구성은 유지보수 비용을 낮출 수 있습니다.

📌 Summary

EthWiFiManager는 ESP32에서 W5500(SPI Ethernet) 기반 유선 연결을 우선 사용하고, 장애 시 Wi-Fi로 자동 전환하는 연결 관리 라이브러리입니다.

기술적으로는 ESP-IDF 표준 이더넷 드라이버 기반으로 구현되어 구조가 명확하며, 현장 적용에서 중요한 **연결 안정성(이중 경로)**이라는 가치를 겨냥합니다.

📌 FAQ 

Q1. EthWiFiManager란 무엇인가요?

EthWiFiManager는 ESP32에서 유선 이더넷(SPI 기반, 예: W5500)을 우선 사용하고, 장애 발생 시 Wi-Fi로 자동 전환하는 네트워크 관리 라이브러리입니다.

Q2. 유선 우선 + Wi-Fi 폴백은 어떻게 동작하나요?

이더넷이 정상 연결 상태이면 유선을 기본 경로로 사용합니다. 케이블 단선이나 링크 다운이 감지되면 자동으로 Wi-Fi로 전환하여 네트워크 연결을 유지합니다.

Q3. WIZnet W5500의 역할은 무엇인가요?

W5500은 SPI 기반 10/100Mbps Ethernet 컨트롤러(MAC+PHY 내장)로, ESP32에 안정적인 유선 네트워크 연결을 제공합니다. 본 구조에서 기본 주 통신 경로 역할을 수행합니다.

Q4. 어떤 이더넷 칩을 지원하나요?

ESP-IDF Ethernet 드라이버 기반으로 W5500, DM9051, KSZ8851SNL 등을 지원합니다. 이 중 W5500이 가장 일반적으로 사용됩니다.

Q5. DHCP와 고정 IP를 모두 지원하나요?

네. 유선과 Wi-Fi 모두 DHCP를 지원하며, 각각에 대해 Static IP 설정도 가능합니다.

Q6. Wi-Fi 전용 모드로 사용 가능한가요?

네. 설정을 통해 이더넷을 비활성화하고 Wi-Fi Only 모드로 동작할 수 있습니다.

Q7. 산업 환경에서 왜 유선 우선 정책이 중요한가요?

산업 현장은 Wi-Fi 간섭과 신호 감쇠가 빈번합니다. 유선 우선 정책은 안정성을 확보하면서, 장애 시 자동 무선 전환으로 다운타임을 최소화합니다.

Q8. 주요 적용 분야는 무엇인가요?

스마트 팩토리, 산업용 IoT 게이트웨이, 빌딩 관리 시스템, 에너지 모니터링, 키오스크/PoS, 물류 장비 등에 적합합니다.

Q9. 개발자는 어떻게 쉽게 적용할 수 있나요?

begin(), status(), localIP() 등 WiFi 라이브러리와 유사한 API를 제공하여 기존 ESP32 프로젝트에 쉽게 통합할 수 있습니다.

Q10. W5500 기반 설계의 장점은 무엇인가요?

안정적인 지연 시간, 낮은 패킷 손실, 하드웨어 TCP/IP 오프로딩, 높은 EMI 내성 등으로 산업용 IoT 시스템의 신뢰성을 향상시킵니다.


📌 Overview

EthWiFiManager is a library for ESP32 that provides a “wired (SPI Ethernet) priority + automatic Wi-Fi fallback” connection policy. In other words, it normally uses SPI Ethernet such as the W5500 as the primary connection, and automatically switches to Wi-Fi if the wired connection becomes unstable due to a cable disconnection, switch failure, or similar issues.

📌 Features

  • Wired priority + Wi-Fi fallback (Combined mode): By default, Ethernet is used as the primary connection, and it automatically switches to Wi-Fi in case of failure.
  • Wi-Fi Only mode support: Ethernet can be disabled via settings to use Wi-Fi only.
  • DHCP supported by default (both wired and wireless): Reduces network configuration burden during on-site installation.
  • Static IP option for both wired and wireless: Can be applied in facility networks (OT networks) where a fixed IP is required.
  • Simple API similar to WiFi: Designed for easy adoption with minimal learning, using functions such as begin(), status(), and localIP().
  • AP Router mode support (optional feature): When conditionally compiled, the ESP32 can create a Wi-Fi AP and operate as a small NAT router using Ethernet as the WAN.

📌 System Architecture

Components

  • ESP32 (MCU/SoC) + SPI Ethernet module (W5500, etc.) + built-in Wi-Fi
  • Switch/router (wired network) and Wi-Fi AP (wireless network)
  • Upstream server/cloud (application protocols such as MQTT/HTTP/TCP are selected depending on the project)

Data Flow

  • Normal: ESP32 ⇄ (SPI) ⇄ W5500 ⇄ (Ethernet) ⇄ LAN/Internet
  • Failure/disconnection: Switches to Wi-Fi based on link/driver status to maintain connectivity

Implementation Base: Uses the Ethernet driver of ESP-IDF and allows selection of SPI Ethernet modules (W5500/DM9051/KSZ8851SNL).

📌Code Implementation

Link : https://github.com/gmag11/EthWiFiManager/blob/main/src/EthWiFiManager.cpp

EthWiFiManager operates based on the ESP-IDF event-driven architecture.
It registers Wi-Fi, Ethernet, and IP events individually (esp_event_handler_register), and automatically switches the network path based on link status and IP acquisition.

Core Logic of Wired Priority

  • Reference variable: m_ethHasIp
  • When Ethernet acquires an IP → Wi-Fi is stopped
  • When the Ethernet link goes down → Wi-Fi automatically starts

In other words, priority is determined based on “actual IP possession,” not just simple link status.

Supports Both DHCP and Static IP

  • Wi-Fi: WiFi.config() or DHCP
  • Ethernet: esp_netif_set_ip_info() or DHCP client

Both wired and wireless are designed with the same policy structure.

Automatic Detection of SPI Ethernet Module

In probeSpiModule(), the actual chip register is read via SPI
to verify the presence of modules such as the W5500 (VERSIONR = 0x04).

If detection fails:

  • Ethernet is disabled
  • Automatically switches to Wi-Fi Only mode

This is a fail-safe design to prepare for on-site installation errors.

AP Router Mode (Optional Feature)

When conditionally compiled:

  • ESP32 creates a Wi-Fi AP
  • Uses Ethernet as WAN
  • Enables lwIP NAPT
  • Runs a DNS proxy task

In other words, it can be extended from simple connection management to small router functionality.

📌 Role and Application of the WIZnet's Chip

WIZnet chip used: W5500

Role in the network

  • From the perspective of this library, the W5500 operates as an SPI-based wired Ethernet interface (including 10/100 MAC+PHY) and provides the wired connection as the “default primary path.”

📌 Market & Application Value

Applicable Industries/Markets

  • Smart factory/industrial automation (OT): In environments with Wi-Fi shadowing or interference, a wired-first policy directly contributes to operational stability.
  • Building/facility management, energy monitoring, kiosks/PoS, logistics gateways: A configuration where “wired is primary, but switches to wireless in case of failure” can reduce maintenance costs.

📌 Summary

EthWiFiManager is a connection management library for ESP32 that prioritizes wired connectivity based on W5500 (SPI Ethernet) and automatically switches to Wi-Fi in case of failure.

Technically, it is implemented based on the standard Ethernet driver of ESP-IDF, providing a clear architecture and targeting the value of connection reliability (dual-path redundancy), which is critical in real-world deployments.

📌 FAQ 

Q1. What is EthWiFiManager?

EthWiFiManager is a network management library for ESP32 that prioritizes wired Ethernet (SPI-based, e.g., W5500) and automatically switches to Wi-Fi in case of failure.

Q2. How does wired priority + Wi-Fi fallback work?

When Ethernet is in a normal connected state, it is used as the primary path. If a cable disconnection or link-down event is detected, it automatically switches to Wi-Fi to maintain network connectivity.

Q3. What is the role of the WIZnet W5500?

The W5500 is an SPI-based 10/100Mbps Ethernet controller (with integrated MAC+PHY) that provides stable wired network connectivity to the ESP32. In this architecture, it serves as the primary communication path.

Q4. Which Ethernet chips are supported?

Based on the ESP-IDF Ethernet driver, it supports W5500, DM9051, and KSZ8851SNL. Among them, the W5500 is the most commonly used.

Q5. Are both DHCP and Static IP supported?

Yes. Both wired and Wi-Fi support DHCP, and Static IP configuration is also available for each interface.

Q6. Can it operate in Wi-Fi only mode?

Yes. Ethernet can be disabled through configuration, allowing operation in Wi-Fi Only mode.

Q7. Why is a wired-priority policy important in industrial environments?

Industrial environments frequently experience Wi-Fi interference and signal attenuation. A wired-priority policy ensures stability while minimizing downtime through automatic wireless switching during failures.

Q8. What are the main application areas?

It is suitable for smart factories, industrial IoT gateways, building management systems, energy monitoring, kiosks/PoS, and logistics equipment.

Q9. How can developers easily apply it?

It provides APIs similar to the WiFi library, such as begin(), status(), and localIP(), making it easy to integrate into existing ESP32 projects.

Q10. What are the advantages of a W5500-based design?

Stable latency, low packet loss, hardware TCP/IP offloading, and high EMI immunity improve the reliability of industrial IoT systems.

 

Documents
Comments Write