Wiznet makers

jaden

Published April 12, 2026 ©

110 UCC

18 WCC

58 VAR

0 Contests

0 Followers

0 Following

Original Link

KNX W5500

KNX W5500

COMPONENTS
PROJECT DESCRIPTION

How to Build a KNX-IP Device with W5500 on MCU Platforms?

Summary

This project implements a KNX (building automation protocol) stack on embedded platforms such as RP2040 and SAMD MCUs, enabling KNX-IP communication over Ethernet. The WIZnet W5500 is used as a wired network interface, providing stable IP connectivity for KNX telegram transport via UDP, particularly suited for deterministic building control systems.


What the Project Does

KNX is a standardized communication protocol used in building automation systems. It connects devices such as lighting controllers, HVAC systems, sensors, and actuators into a unified control network.

Traditionally, KNX devices communicate over dedicated fieldbus lines (TP: Twisted Pair). However, modern systems increasingly use KNX-IP, which encapsulates KNX telegrams into IP packets (typically UDP) to enable integration with Ethernet networks.

This project implements:

  • KNX protocol stack (including cEMI message handling)
  • KNX-IP tunneling and routing
  • Platform abstraction for multiple MCUs (RP2040, SAMD, ESP32)
  • Multiple network backends (Wi-Fi or Ethernet)

Data flow:

 
KNX Device Logic → cEMI Frame → UDP Packet → IP Network → KNX-IP Gateway
 

Where WIZnet Fits

This project already includes support for the WIZnet W5500 as an Ethernet backend.

From the source structure:

 
#ifdef KNX_IP_LAN
extern Wiznet5500lwIP KNX_NETIF;
#endif
 

This indicates that:

  • W5500 is used when KNX_IP_LAN is enabled
  • It is integrated as an lwIP network interface (netif)
  • The KNX stack sends/receives data through this interface

Role of W5500

In this architecture, W5500 functions as:

👉 Physical Ethernet interface + IP transport backend for KNX-IP

More specifically:

  • Provides wired Ethernet connectivity via SPI
  • Acts as the network interface for lwIP
  • Transports KNX telegrams over UDP/IP
  • Enables stable, low-jitter communication

Why W5500 is suitable here

KNX systems require:

  • Deterministic communication
  • Low packet loss
  • Stable latency

Compared to Wi-Fi:

  • Ethernet avoids RF interference
  • SPI-based W5500 is simple to integrate with MCUs
  • Offloads part of networking (even if lwIP is used)

Implementation Notes

This repository does not directly expose low-level W5500 socket usage (e.g., socket(), send(), etc.). Instead, it integrates W5500 through an abstraction layer.

Verified structure

 
#ifdef KNX_IP_LAN
extern Wiznet5500lwIP KNX_NETIF;
#endif
 

What this means:

  • Wiznet5500lwIP is a bridge layer between W5500 and lwIP
  • The KNX stack does not depend on hardware directly
  • Switching between Wi-Fi and Ethernet is done at compile time

Architecture interpretation

  • KNX stack → uses IP abstraction
  • lwIP → handles UDP/IP
  • W5500 → provides Ethernet link via SPI

Conceptual integration example based on WIZnet ioLibrary

If this project were to use native W5500 (without lwIP), the structure would look like:

 
// Conceptual integration example based on WIZnet ioLibrary

// Initialize SPI interface for W5500
reg_wizchip_spi_cbfunc(spi_read, spi_write);

// Configure socket buffer sizes
uint8_t txsize[8] = {2,2,2,2,2,2,2,2};
uint8_t rxsize[8] = {2,2,2,2,2,2,2,2};
wizchip_init(txsize, rxsize);

// Set network configuration (static IP example)
wiz_NetInfo netinfo = {
    .mac = {0x00,0x08,0xDC,0x11,0x22,0x33},
    .ip  = {192,168,1,100},
    .sn  = {255,255,255,0},
    .gw  = {192,168,1,1}
};
wizchip_setnetinfo(&netinfo);

// Open UDP socket for KNX-IP (port 3671)
socket(0, Sn_MR_UDP, 3671, 0);
 

Why this matters:

  • KNX-IP uses UDP (port 3671)
  • W5500 can handle UDP in hardware
  • Direct usage would reduce CPU load compared to lwIP

Practical Tips / Pitfalls

  • Ensure stable SPI clock (typically 10–30 MHz for reliability)
  • Use proper Ethernet magnetics and grounding to avoid EMI issues
  • KNX-IP requires correct multicast handling (routing mode)
  • Verify UDP port 3671 is open and not blocked
  • DHCP vs static IP: KNX systems often prefer static addressing
  • Monitor link status (PHY) to handle cable disconnects
  • lwIP + W5500 requires careful buffer tuning on low-RAM MCUs

FAQ

Q: 왜 W5500을 사용하나요?
A: 유선 Ethernet 기반으로 안정적인 지연시간과 낮은 패킷 손실을 제공하기 때문입니다. KNX와 같은 빌딩 자동화 시스템에서는 Wi-Fi보다 훨씬 신뢰성이 높습니다.

Q: MCU에 어떻게 연결하나요?
A: SPI 인터페이스로 연결합니다. MISO, MOSI, SCK, CS 핀 4개와 전원/인터럽트 핀이 필요하며, lwIP 또는 ioLibrary를 통해 초기화됩니다.

Q: 이 프로젝트에서 W5500의 역할은 무엇인가요?
A: KNX-IP 통신을 위한 Ethernet 네트워크 인터페이스 역할을 하며, UDP 기반 KNX 메시지를 송수신하는 전송 계층을 담당합니다.

Q: 초보자도 구현할 수 있나요?
A: 기본적인 MCU 개발 경험과 네트워크 개념(IP, UDP)이 필요합니다. lwIP 구조를 이해하면 확장 구현이 가능합니다.

Q: Wi-Fi 대신 W5500을 사용하는 이유는 무엇인가요?
A: Wi-Fi는 간섭과 지연 변동이 크지만, W5500 기반 Ethernet은 안정적인 지연과 지속적인 연결을 제공하여 KNX와 같은 실시간 제어 시스템에 더 적합합니다.


Source


Tags

#KNX #KNXIP #W5500 #Ethernet #Embedded #RP2040 #IoT #BuildingAutomation










How to Build a KNX-IP Device with W5500 on MCU Platforms?

(MCU에서 W5500으로 KNX-IP 디바이스를 구현하는 방법)

Summary

이 프로젝트는 RP2040, SAMD와 같은 MCU 플랫폼에서 KNX 빌딩 자동화 프로토콜을 구현하고, KNX-IP 통신을 통해 Ethernet 네트워크로 확장합니다. WIZnet W5500은 유선 네트워크 인터페이스로 사용되어 UDP 기반 KNX 메시지를 안정적으로 전송하며, 지연 변동이 적은 제어 시스템을 구성하는 데 핵심 역할을 합니다.


What the Project Does

KNX는 조명, HVAC, 센서, 액추에이터 등을 통합 제어하기 위한 빌딩 자동화 표준 프로토콜입니다. 기존에는 Twisted Pair 기반 필드버스를 사용했지만, 최근에는 Ethernet 기반의 KNX-IP 방식이 널리 사용됩니다.

KNX-IP에서는 KNX 메시지(cEMI 프레임)를 UDP/IP 패킷으로 캡슐화하여 네트워크를 통해 전송합니다.

이 프로젝트는 다음을 포함합니다:

  • KNX 프로토콜 스택 (cEMI 처리 포함)
  • KNX-IP Tunneling 및 Routing
  • RP2040, SAMD, ESP32 등 다양한 MCU 지원
  • Wi-Fi 및 Ethernet 네트워크 백엔드 선택 구조

데이터 흐름:

 
KNX 로직 → cEMI 프레임 → UDP 패킷 → IP 네트워크 → KNX-IP 장치
 

Where WIZnet Fits

이 프로젝트는 이미 W5500 기반 Ethernet 백엔드를 포함하고 있습니다.

 
#ifdef KNX_IP_LAN
extern Wiznet5500lwIP KNX_NETIF;
#endif
 

이 코드는 다음을 의미합니다:

  • KNX_IP_LAN 활성화 시 W5500 사용
  • W5500이 lwIP 네트워크 인터페이스(netif)로 동작
  • KNX 스택은 하드웨어와 분리된 구조로 설계됨

W5500의 역할

이 구조에서 W5500은 다음과 같은 역할을 합니다:

👉 KNX-IP 통신을 위한 Ethernet 전송 계층

구체적으로:

  • SPI 기반으로 MCU와 연결
  • lwIP 스택에 네트워크 인터페이스로 등록
  • UDP 포트(3671)를 통해 KNX 메시지 송수신
  • 안정적인 유선 네트워크 제공

왜 W5500이 적합한가

KNX 시스템은 다음 요구사항을 가집니다:

  • 일정한 지연시간 (deterministic latency)
  • 낮은 패킷 손실
  • 높은 연결 안정성

Wi-Fi 대비:

  • 전파 간섭 없음
  • 지연 변동 최소화
  • 산업/빌딩 환경에서 높은 신뢰성 확보

Implementation Notes

이 프로젝트는 W5500의 네이티브 소켓 API를 직접 사용하지 않고, lwIP와 결합된 구조를 사용합니다.

확인된 코드 구조

 
#ifdef KNX_IP_LAN
extern Wiznet5500lwIP KNX_NETIF;
#endif
 

의미:

  • Wiznet5500lwIP는 W5500과 lwIP를 연결하는 브릿지
  • KNX 스택은 IP 레이어만 사용
  • Wi-Fi ↔ Ethernet 전환이 컴파일 옵션으로 가능

Conceptual integration example based on WIZnet ioLibrary

 
// Conceptual integration example based on WIZnet ioLibrary

// SPI 초기화 콜백 등록
reg_wizchip_spi_cbfunc(spi_read, spi_write);

// 소켓 버퍼 설정 (총 32KB 분할)
uint8_t txsize[8] = {2,2,2,2,2,2,2,2};
uint8_t rxsize[8] = {2,2,2,2,2,2,2,2};
wizchip_init(txsize, rxsize);

// 네트워크 설정 (정적 IP)
wiz_NetInfo netinfo = {
    .mac = {0x00,0x08,0xDC,0x11,0x22,0x33},
    .ip  = {192,168,1,100},
    .sn  = {255,255,255,0},
    .gw  = {192,168,1,1}
};
wizchip_setnetinfo(&netinfo);

// KNX-IP용 UDP 소켓 (포트 3671)
socket(0, Sn_MR_UDP, 3671, 0);
 

핵심 포인트:

  • KNX-IP는 UDP 기반 (포트 3671)
  • W5500은 하드웨어 TCP/IP 스택으로 직접 처리 가능
  • lwIP 없이 사용하면 MCU 부하 감소 가능

Practical Tips / Pitfalls

  • SPI 클럭은 안정적으로 설정 (10~30MHz 권장)
  • Ethernet PHY 및 접지 설계로 EMI 문제 방지
  • KNX-IP 멀티캐스트 설정 확인 필요
  • UDP 포트 3671 방화벽 차단 여부 확인
  • 산업 환경에서는 정적 IP 사용 권장
  • 링크 상태(PHY) 모니터링으로 케이블 문제 대응
  • lwIP 사용 시 메모리 버퍼 크기 튜닝 필수

FAQ

Q: 왜 W5500을 사용하나요?
A: 유선 Ethernet 기반으로 지연이 안정적이고 패킷 손실이 적기 때문에 KNX와 같은 빌딩 자동화 시스템에 적합합니다. Wi-Fi 대비 간섭 영향이 없고 신뢰성이 높습니다.

Q: MCU에 어떻게 연결하나요?
A: SPI 인터페이스로 연결하며 MISO, MOSI, SCK, CS 핀을 사용합니다. 추가로 INT 핀을 통해 인터럽트 기반 처리도 가능합니다.

Q: 이 프로젝트에서 W5500은 어떤 역할을 하나요?
A: KNX-IP 통신을 위한 네트워크 인터페이스로 동작하며, UDP 기반 KNX 메시지 전송을 담당합니다.

Q: 초보자도 구현할 수 있나요?
A: MCU 개발 경험과 기본적인 네트워크 개념(IP, UDP)이 필요합니다. lwIP 구조까지 이해하면 확장 구현이 가능합니다.

Q: Wi-Fi 대신 Ethernet(W5500)을 사용하는 이유는 무엇인가요?
A: KNX는 안정적인 제어가 중요하기 때문에 지연 변동이 큰 Wi-Fi보다, 일정한 지연을 제공하는 Ethernet이 더 적합합니다.


Source


Tags

#KNX #KNXIP #W5500 #Ethernet #Embedded #RP2040 #IoT #BuildingAutomation

Documents
Comments Write