---
title: "NiusBus: One Arduino Library for CAN, RS-485, Modbus and W5500 Ethernet"
url: "https://maker.wiznet.io/irina/projects/niusbus-one-arduino-library-for-can-rs-485-modbus-and-w5500-ethernet/"
markdown_url: "https://maker.wiznet.io/irina/projects/niusbus-one-arduino-library-for-can-rs-485-modbus-and-w5500-ethernet/md"
type: "UCC: User Created Content"
author: "dunknowcoding"
author_url: "https://github.com/dunknowcoding/NiusBus"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "dunknowcoding"
original_url: "https://github.com/dunknowcoding/NiusBus"
published: "2026-10-12"
language: "en"
hardware: ["WIZnet W5500"]
likes: 0
views: 15
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# NiusBus: One Arduino Library for CAN, RS-485, Modbus and W5500 Ethernet

> Unified Arduino drivers for CAN, CAN FD, RS-485, Modbus and W5500 Ethernet, with diagnostics, DHCP, sockets and portable no-heap design.

Original author: dunknowcoding (source: https://github.com/dunknowcoding/NiusBus)

## Components

- **WIZnet W5500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5500))
- Software: **Arduino IDE** ([docs](https://www.arduino.cc/en/software))

WIZnet parts: W5500 ([Datasheet](https://docs.wiznet.io/Product/Chip/Ethernet/W5500/datasheet?utm_source=maker&utm_medium=project&utm_campaign=w5500), [product hub](https://maker.wiznet.io/products/w5500/))

## Article

## 📌 서랍 속 통신 모듈을 하나의 Library로

**NiusBus**는 Arduino 환경에서 자주 사용하는 CAN, CAN FD, RS-485 및 Ethernet module을 하나의 library에서 사용할 수 있도록 만든 communication driver collection입니다.

단순히 여러 chip driver를 한 폴더에 모은 것이 아니라, 같은 종류의 bus에서는 가능한 한 동일한 API 구조를 사용하도록 설계되어 있습니다.

예를 들어 Classic CAN에서는 `Mcp2515`, `Esp32Twai`가 서로 다른 hardware를 사용하지만 비슷한 API로 frame을 송수신할 수 있습니다.

Ethernet에서는 **WIZnet W5500**을 이용한 socket networking과 DHCP를 지원하며, RS-485에서는 Modbus RTU, Ethernet에서는 Modbus TCP까지 제공합니다.

## 🌐 W5500으로 Ethernet을 추가하다

WIZnet 관점에서 가장 중요한 부분은 `W5500` class입니다.

```cpp
W5500 eth(/*cs_pin=*/10, /*reset_pin=*/9);
 DhcpLease lease;
eth.beginDhcp(
    localMac(0xA1, 0xB2, 0xC3, 0x01),
    &lease
);
```

DHCP뿐 아니라 static IP configuration과 TCP client/server도 지원합니다.

Repository에는 다음 Ethernet 관련 example이 제공됩니다.

| Example | 기능 |
| --- | --- |
| `09_EthernetSetup` | W5500 Link / Static IP / DHCP |
| `10_ModbusTcpClient` | Modbus TCP Client + reconnect |
| `11_EthernetTcpServer` | Listening TCP Socket |
| `13_SerialBridgeConfig` | WIZnet/USR Serial Bridge 설정 |
| `15_HardwareProbe` | Register dump / self-test |

즉, NiusBus에서 W5500은 단순한 Ethernet interface가 아니라 **TCP/IP application을 위한 hardware socket controller** 역할을 합니다. W5500이 ARP, IP, ICMP, TCP, UDP를 칩 안에서 8개 socket으로 처리하므로 MCU는 payload byte만 옮기면 됩니다.

### Socket 하나를 transport로 보기

구조적으로 흥미로운 점은 W5500 socket 하나가 `W5500Socket`이라는 `FullDuplexTransport`(`write`, `readSome`, `readExactly`)로 노출된다는 것입니다. `ModbusTcpClient`는 이 transport 위에서 동작하고, 같은 인터페이스로 작성된 다른 protocol code도 그대로 올릴 수 있습니다.

`setSocketBufferSizes()`로 16 KB 버퍼를 socket별로 나눌 수도 있습니다. 예컨대 socket 하나만 쓰는 TCP echo server 예제는 기본 2 KB 대신 8 KB를 할당합니다.

![](https://maker.wiznet.io/upload/ckeditor5/bc828fbe33b241a5b44b7d8071640944.jpg)

**생성 다이어그램: NiusBus docs/architecture.md와 W5500.h의 클래스 주석에 설명된 계층 구조.**

## 🔄 Modbus RTU와 Modbus TCP를 한 Library에서

NiusBus는 serial과 Ethernet을 하나의 communication library 안에서 함께 다룹니다.

**MAX485 → RS-485 → Modbus RTUW5500 → TCP Socket → Modbus TCP**

RS-485에서는 `ModbusRtuMaster`, Ethernet에서는 `ModbusTcpClient`를 사용할 수 있습니다.

따라서 산업용 serial device와 Ethernet device를 함께 다루거나, RTU와 TCP를 함께 사용하는 시스템의 기반 library로 활용할 수 있습니다.

소스에서 참고할 만한 구현 포인트가 두 가지 있습니다.

- TCP client는 고정 6바이트 header를 먼저 읽습니다. "TCP는 message를 어디서든 쪼갤 수 있기" 때문이며, header가 알려 준 길이만큼 나머지를 읽습니다. RTU의 CRC 대신 length와 transaction id가 들어가는 것이 두 framing의 차이입니다.

- Troubleshooting 문서는 **unit id**를 실제 실패 원인으로 다룹니다. Native TCP device에서는 보통 무시되지만 RTU gateway를 거치면 gateway 뒤의 serial slave를 선택하므로, 값이 틀리면 모든 request가 timeout됩니다.

## 🔍 실제 PCB 이름을 기준으로 Hardware를 구분

NiusBus의 독특한 부분은 chip name뿐 아니라 **실제 PCB silkscreen**을 기준으로 module을 구분한다는 점입니다.

예를 들어 MCP2515 module을 모두 동일하게 취급하지 않고 다음처럼 실제 판매 board를 구분합니다.

- `HW-184`

- `MCP2515 CAN MODULE`

- `NiRen MCP2515_CAN`

W5500 계열도 다음과 같은 실제 board 이름을 문서화합니다.

- `W5500 Lite`

- `USR-ES1`

- `WIZ850io`

Module catalog에는 총 **48개 board**가 정리되어 있으며 pin order와 board별 주의사항을 함께 제공합니다. W5500 쪽 예를 들면 다음과 같습니다.

- 신호 pin은 정품 WIZnet 칩에서 5 V tolerant지만, `3.3V`로 표시된 전원 pin에 5 V를 넣으면 board가 파손됩니다.

- W5500 Ethernet Shield는 network를 쓰기 전에 D4(SD card CS)를 HIGH로 올려야 합니다. 그러지 않으면 SD slot이 W5500과 MISO를 두고 다투어 "이더넷 board가 죽은 것과 똑같아" 보입니다.

- Arduino Ethernet Shield(W5100)와 WIZ820io(W5200)는 "참고용, 구동 안 함"으로 분류되며, W5100에는 기본 `Ethernet.h` 사용을 권합니다.

## 🛠️ 통신 실패를 Error Code 하나로 끝내지 않는다

NiusBus는 정상 통신뿐 아니라 문제 발생 시 원인을 찾는 기능도 중요하게 다룹니다.

```cpp
CanDiagnostics health;
can.driver().diagnostics(&health);
```

또한 각 bus에서 packet loss statistics를 관리합니다.

```cpp
modbus.statistics().lossPermille();
canHealth.sendLossPermille();
ethHealth.lossPermille();
```

단순한 communication failure가 아니라 다음과 같은 상태를 구분합니다.

- timeout

- CRC mismatch

- no acknowledgement

- bus-off

- packet loss

Ethernet에서도 `EthDiagnostics`가 link up 여부, 송수신 frame 수, 수신 overflow, CRC error, 송신/연결 실패 횟수를 누적하고, 마지막 오류를 `link down`, `no ARP reply`, `connection refused`, `connection timed out`, `no DHCP server answered` 같은 구체적 원인으로 알려 줍니다. 예를 들어 `connect()`의 timeout이 케이블 문제인지 방화벽인지를 구분하는 데 쓸 수 있습니다.

## 🔬 Register까지 내려가는 Hardware Probe

각 driver는 자체 bring-up chain을 검사하고 어느 단계에서 실패했는지 알려주는 `selfTest()`와 register dump용 `probe()` 기능을 제공합니다.

```cpp
SelfTestResult result;
 can.selfTest(
    &result,
    /*include_loopback=*/true
);
```

이 결과는 사람이 Serial Monitor로 확인하는 것뿐 아니라 script나 automated board test에서 활용할 수 있도록 number/enum 중심으로 구성되어 있습니다.

W5500의 `selfTest()`는 5단계를 차례로 거치고 처음 실패한 단계에서 멈춥니다.

1. 배선: SPI bus, chip select, clock adapter가 설정되어 있는가?

2. SPI link: `VERSIONR`이 `0x04`여야 합니다. 전부 0이거나 1이면 `SCS`와 MISO/MOSI 뒤바뀜을 확인하라는 메시지가 나옵니다.

3. 설정: `RTR`에 `0x1234`를 쓰고 읽은 뒤 원래 값으로 복원합니다.

4. MAC: `SHAR`가 전부 0이면 `begin()`이 실행되지 않은 것입니다.

5. Carrier: `PHYCFGR` bit 0을 마지막에 확인합니다. 케이블이 빠져 있어도 앞 단계는 통과할 수 있기 때문입니다.

![](https://maker.wiznet.io/upload/ckeditor5/7bc5b1195f2d43a886cd38cd27ba5d65.jpg)

**생성 다이어그램: W5500.h의 selfTest() 단계와 docs/architecture.md에 설명된 DHCP 교환.**

## 💾 Arduino UNO에서 가능한 DHCP

DHCP message는 약 300바이트이고 응답은 548바이트까지 될 수 있어서 UNO의 RAM에는 만들 수 없습니다. NiusBus는 message를 W5500의 송신 buffer에 16바이트 조각으로 직접 조립하고, 응답은 칩의 random-access peek로 제자리에서 훑습니다. 문서는 비용을 stack 약 80바이트로 적습니다. `beginDhcp()`는 IP, subnet, gateway, DNS, server, lease time을 반환하며, 만료 전 갱신은 sketch가 해야 할 일입니다.

## 🧩 Arduino 위와 아래를 분리한 2-Layer 구조

```plaintext
Application
     │
     ▼
Mcp2515 / Rs485 / W5500
     │
  .driver()
     ▼
Mcp2515Driver / W5500Driver / Rs485Driver
ModbusRtuMaster / ModbusTcpClient
     │
     ▼
SPI / GPIO / Clock / ByteStream
```

위쪽은 Arduino에서 쉽게 사용할 수 있는 convenience layer이고, 아래쪽 driver layer는 Arduino 자체에 직접 의존하지 않도록 구성되어 있습니다.

또한 library 내부에서는 다음 원칙을 사용합니다.

**No **`**new**`** · No **`**delete**`** · No **`**String**`** · No recursion**

Buffer 역시 object member 또는 caller-supplied memory를 사용하도록 설계되어 있습니다. `W5500` 객체는 RAM 약 50바이트, 48종 module catalog는 `Serial` 포함 UNO RAM 약 440바이트입니다.

## ⚙️ W5500뿐 아니라 WIZnet Serial-to-Ethernet도 지원

NiusBus에는 WIZnet Serial-to-Ethernet module을 설정하기 위한 `WizS2E`도 포함되어 있습니다.

지원 대상으로 문서화된 제품은 다음과 같습니다.

- WIZ750SR

- W5500S2E-S1

- WIZ550S2E

즉, MCU가 W5500을 직접 SPI로 제어하는 방식과 WIZnet S2E module을 설정하는 방식 모두를 하나의 library에서 다룹니다.

S2E module은 두 글자 command를 쓰며, `+++`와 guard time으로 진입하거나 전원 인가 시 `CFGn`을 LOW로 당겨 진입합니다. 문서는 `SV`를 보내기 전까지 설정이 RAM에만 있어 저장 없이 재부팅하면 session이 조용히 사라진다고 경고합니다.

## 📊 Project Snapshot (v0.2.0)

| 항목 | 내용 |
| --- | --- |
| W5500 driver | `W5500.h` 1,406줄; socket 8개, TCP/UDP, DHCP, interrupt, keep-alive, `selfTest()`, register probe |
| Board catalog | 48종 |
| 상위 protocol | Modbus RTU (RS-485), Modbus TCP (W5500 socket), raw Ethernet frame (ENC28J60) |
| Example | 16개 |
| Build 검증 | 모든 example을 AVR, megaAVR, SAMD, ESP32, Renesas RA4용으로 compile |

## 🧭 활용 가치와 한계

가치는 규율에 있습니다. Driver는 실행 전에 칩이 있는지 확인하고, 뭉뚱그린 실패 대신 hardware가 말한 내용을 보고하며, 초보자의 시간을 빼앗는 board 수준의 함정을 문서화합니다. 안정적인 bring-up 경로가 필요한 W5500 프로젝트라면 socket에는 다른 library를 쓰더라도 `selfTest()`와 `SCS`/`RST`/`INT` 배선 노트는 가져다 쓸 만합니다.

한계도 분명합니다.

- W5500 쪽은 socket, DHCP, Modbus TCP를 다루며 문서에 MQTT, HTTP, TLS 계층은 없습니다. 필요하면 다른 library와 조합해야 합니다.

- DHCP 갱신은 sketch의 몫입니다.

- README의 hardware 검증 문구는 CAN, RS-485, Modbus에 대한 것이고 Ethernet driver 별도 결과는 적혀 있지 않으므로, W5500 경로는 소스 검토와 example compile 수준으로 보고 사용 환경에서 직접 확인하는 것이 좋습니다.

- 개인이 관리하는 library(v0.2.0)이므로 vendor 지원 제품과는 지속성 면에서 다릅니다.

## 🔗 비슷한 WIZnet Maker 프로젝트와 비교

| Project | 주요 Interface | W5500 역할 | NiusBus와 차이 |
| --- | --- | --- | --- |
| **NiusBus** | CAN / CAN FD / RS-485 / Modbus / Ethernet | Library-level TCP/IP socket driver | 여러 bus를 하나의 library에서 지원 |
| [**Modbus RTU-to-TCP Gateway with W5500 and STM32**](https://maker.wiznet.io/jakelee/resellers/modbus-rtu-to-tcp-gateway-with-w5500-and-stm32/) | RS-485 + Ethernet | Modbus RTU ↔ Modbus TCP Gateway | 하나의 완성된 gateway application에 집중 |
| [**ETH_CANable Firmware**](https://maker.wiznet.io/matthew/projects/eth-canable-firmware---can--iris-its------robot/) | Dual CAN + Ethernet | CAN frame을 UDP/Ethernet으로 전달 | CAN-to-Ethernet application에 집중 |
| [**Wiznet-W5500-library-for-Arduino**](https://maker.wiznet.io/scott/projects/wiznet-w5500-library-for-arduino/) | Ethernet | Arduino용 W5500 driver/library | W5500 Ethernet 자체에 집중 |

### Modbus RTU-to-TCP Gateway with W5500 and STM32

[Maker Project 보기](https://maker.wiznet.io/jakelee/resellers/modbus-rtu-to-tcp-gateway-with-w5500-and-stm32/)

STM32F103과 W5500io-M module을 이용해 기존 RS-485 Modbus RTU 장치를 Ethernet 기반 Modbus TCP network에 연결하는 프로젝트입니다. RTU의 CRC16을 떼고 MBAP header를 붙이는 변환을 STM32가 수행하고, W5500은 TCP/UDP/ARP/ICMP와 socket 관리를 hardware로 처리합니다.

NiusBus는 이런 하나의 gateway application을 만드는 대신 **RS-485, Modbus RTU, W5500, Modbus TCP 각각의 building block을 library 형태로 제공**한다는 점이 다릅니다. 두 프로젝트는 경쟁 관계보다는 위아래 관계에 가깝습니다. Gateway 같은 application이 NiusBus 같은 library 위에 만들어질 수 있습니다.

### ETH_CANable Firmware

[Maker Project 보기](https://maker.wiznet.io/matthew/projects/eth-canable-firmware---can--iris-its------robot/)

STM32G474 기반의 dual-channel CAN-to-Ethernet bridge입니다. Host가 UDP 포트 5001로 SLCAN command를 보내면 STM32가 해석해 두 CAN bus를 구동하고, W5500은 hardware UDP socket을 제공합니다. 문서화된 protocol은 payload 8바이트 이하의 Classic CAN입니다.

NiusBus는 고정된 CAN-to-Ethernet protocol을 구현하는 대신 **CAN과 W5500을 reusable communication driver로 제공**한다는 점이 다릅니다.

### Wiznet-W5500-library-for-Arduino

[Maker Project 보기](https://maker.wiznet.io/scott/projects/wiznet-w5500-library-for-arduino/)

Arjen Hiemstra의 Ethernet55를 소개하는 W5500용 Arduino library로, 직접적인 비교 대상입니다. 해당 페이지는 working example과 user guide가 없어 사용법을 코드에서 읽어야 한다고 적고 있습니다.

NiusBus는 W5500 Ethernet 기능에 더해 16개 example과 문서(module reference, troubleshooting, API book), 진단 기능을 갖추고, CAN, CAN FD, RS-485, Modbus RTU/TCP까지 하나의 library architecture 안에서 다룹니다.

**Q. NiusBus는 W5500을 지원하나요?**
네. DHCP, static addressing, TCP client/server를 지원하며 W5500 socket을 사용하는 Modbus TCP Client example도 제공합니다.

**Q. W5500만을 위한 Library인가요?**
아닙니다. CAN, CAN FD, RS-485, Modbus RTU, W5500 Ethernet, ENC28J60 raw Ethernet 및 Serial-to-Ethernet module을 함께 지원합니다.

**Q. CAN과 Ethernet API가 완전히 같은가요?**
아닙니다. 서로 다른 bus를 억지로 하나의 API로 추상화하기보다 **같은 category 안에서 공통 API를 제공**하는 방식입니다.

**Q. Arduino UNO에서도 사용할 수 있나요?**
Library는 dynamic allocation을 피하도록 설계되었으며 AVR를 포함한 여러 Arduino architecture에서 example compilation을 검증합니다. DHCP도 UNO에서 쓸 수 있도록 W5500의 송신 buffer 안에서 조립합니다.

**Q. W5500 Lite를 5 V로 구동해도 되나요?**
`3.3V`로 표시된 pin에는 안 됩니다. 신호 pin은 정품 WIZnet 칩에서 5 V tolerant지만 전원 pin에 5 V를 넣으면 board가 파손된다고 문서에 적혀 있습니다.

**Q. W5500 외의 WIZnet 제품도 지원하나요?**
네. `WizS2E` class를 통해 WIZ750SR, W5500S2E-S1, WIZ550S2E 같은 Serial-to-Ethernet module도 다룹니다.

---

## 📌 One Library for the Communication Boards in Your Drawer

**NiusBus** is an Arduino communication-driver library covering CAN, CAN FD, RS-485, Modbus, and Ethernet hardware.

Rather than exposing one unrelated programming style for every controller, NiusBus provides a consistent API within each bus category. For Classic CAN, for example, `Mcp2515` and `Esp32Twai` use different hardware but a similar API for sending and receiving frames.

Supported hardware includes:

- MCP2515 Classic CAN

- MCP2518FD / MCP2517FD CAN FD

- ESP32 TWAI

- MAX485-family RS-485

- WIZnet W5500 Ethernet

- ENC28J60 raw Ethernet

- WIZnet and USR serial-to-Ethernet bridges

## 🌐 W5500 Ethernet Support

NiusBus provides a dedicated `W5500` class for wired Ethernet.

```cpp
W5500 eth(/*cs_pin=*/10, /*reset_pin=*/9);
 DhcpLease lease;
eth.beginDhcp(
    localMac(0xA1, 0xB2, 0xC3, 0x01),
    &lease
);
```

The repository includes examples for:

| Example | Function |
| --- | --- |
| `09_EthernetSetup` | W5500 link, static IP, DHCP |
| `10_ModbusTcpClient` | Modbus TCP client with reconnect |
| `11_EthernetTcpServer` | Listening TCP socket |
| `13_SerialBridgeConfig` | WIZnet/USR serial-bridge configuration |
| `15_HardwareProbe` | Register dump and self-test |

The W5500 therefore serves as NiusBus's **hardwired TCP/IP Ethernet controller** for socket-based networking: it runs ARP, IP, ICMP, TCP and UDP across eight sockets, so the MCU only moves payload bytes.

### One socket, seen as a transport

Each W5500 socket is exposed as a `W5500Socket`, a `FullDuplexTransport` with `write`, `readSome` and `readExactly`. `ModbusTcpClient` runs on that transport, and so can any other protocol code written against the same interface. `setSocketBufferSizes()` splits the chip's 16 KB of buffer between sockets; the one-socket TCP echo example gives its socket 8 KB instead of the default 2 KB.

![](https://maker.wiznet.io/upload/ckeditor5/8d827ce0433848f1a87d7ee37ff80187.jpg)

*Generated diagram: the layering described in NiusBus docs/architecture.md and the class comments in W5500.h*

## 🔄 Modbus on Serial and Ethernet

NiusBus covers both sides of a common industrial communication split.

**RS-485 → Modbus RTU** (`ModbusRtuMaster`)

**W5500 → TCP Socket → Modbus TCP** (`ModbusTcpClient`)

This makes the library useful as a common foundation for applications that need to interact with legacy serial devices and Ethernet-connected equipment.

Two implementation details are worth borrowing:

- The TCP client reads the fixed 6-byte header first because "TCP can split a message anywhere", then reads the rest by the length announced. That header, with its explicit length and transaction id, is what replaces the RTU CRC.

- The troubleshooting page treats the **unit id** as a real failure mode. A native TCP device usually ignores it, but through an RTU gateway it selects the serial slave behind the gateway, so a wrong value reaches nothing and every request times out.

## 🔍 Hardware Identified by Its Actual PCB

One unusual feature of NiusBus is its hardware catalog. Instead of documenting only chip names, the library identifies boards using the **silkscreen printed on the real module**.

Examples include `HW-184`, `MCP2515 CAN MODULE`, and `NiRen MCP2515_CAN`, and W5500 boards such as `W5500 Lite`, `USR-ES1`, and `WIZ850io`. The repository catalogs 48 boards with header order and known hardware-specific pitfalls. On the W5500 side:

- Signal pins are 5 V tolerant on genuine WIZnet silicon, but 5 V on the pin marked `3.3V` destroys the board.

- On the W5500 Ethernet Shield, D4 (SD card CS) must be driven high before using the network, or the SD slot fights the W5500 for MISO and "looks exactly like a dead Ethernet board".

- The W5100-based Arduino Ethernet Shield and the W5200-based WIZ820io are listed as "reference, not driven"; the docs recommend the stock `Ethernet.h` for the W5100.

## 🛠️ Diagnostics as a First-Class Feature

NiusBus exposes bus-specific diagnostics and cumulative packet-loss statistics so users can distinguish conditions such as:

- timeout

- CRC mismatch

- missing CAN acknowledgement

- bus-off

- degraded packet delivery

On Ethernet, `EthDiagnostics` keeps running totals for link state, frames sent and received, receive overflows, CRC errors, and send or connect failures, and the last error is reported as a specific cause: `link down`, `no ARP reply`, `connection refused`, `connection timed out`, or `no DHCP server answered`. That lets a sketch tell whether a `connect()` timeout came from a dead cable or a firewall.

## 🔬 Hardware Probes Down to the Register

Each driver provides a staged `selfTest()` that reports where its bring-up chain failed, plus a `probe()` register dump. Results are number- and enum-based so a script or automated board test can use them, not only a person at the Serial Monitor.

`W5500Driver::selfTest()` walks five stages and stops at the first failure:

1. Wiring: are the SPI bus, chip select and clock adapter set up?

2. SPI link: `VERSIONR` must read `0x04`. All zeros or all ones means no answer, and the message says to check `SCS` and whether MISO and MOSI are swapped.

3. Configuration: write `0x1234` to `RTR`, read it back, then restore it.

4. MAC: an all-zero `SHAR` means `begin()` never ran.

5. Carrier: `PHYCFGR` bit 0, checked last because everything above can pass with the cable unplugged.

![](https://maker.wiznet.io/upload/ckeditor5/722603344f4c4cf2803f7c28dced19d7.jpg)

*Generated diagram: selfTest() stages from W5500.h, and the DHCP exchange described in docs/architecture.md.*

## 💾 DHCP on an Arduino UNO

A DHCP message is about 300 bytes and a reply can be 548, which does not fit in a UNO's RAM alongside anything else. NiusBus assembles the message directly in the W5500's own transmit buffer in 16-byte pieces and scans the reply in place with the chip's random-access peek. The docs put the cost at about 80 bytes of stack. `beginDhcp()` returns IP, subnet, gateway, DNS, server and lease time; renewing before expiry is the sketch's job.

## 🧩 Two-Layer Architecture

```plaintext
Sketch
  │
  ▼
Mcp2515 / Rs485 / W5500
  │
  ▼
Portable Drivers / Protocols
  │
  ▼
SPI / GPIO / Clock / ByteStream
```

The portable driver layer does not depend directly on Arduino. The project also avoids library-owned dynamic allocation:

**No **`**new**`** · No **`**delete**`** · No **`**String**`** · No recursion**

A `W5500` object costs about 50 bytes of RAM, and the 48-board catalog costs about 440 bytes of a UNO's RAM with `Serial` included.

## ⚙️ More WIZnet Support Than W5500

NiusBus also includes support for configuring WIZnet Serial-to-Ethernet products through its `WizS2E` interface. Documented devices include WIZ750SR, W5500S2E-S1 and WIZ550S2E.

These modules use two-letter commands, entered with `+++` and a guard time or by pulling `CFGn` low at power-up. The docs warn that settings stay in RAM until `SV` is sent, so a reboot without saving silently discards the session.

## 📊 Project Snapshot (v0.2.0)

| Item | Detail |
| --- | --- |
| W5500 driver | 1,406-line `W5500.h`; 8 sockets, TCP/UDP, DHCP, interrupts, keep-alive, `selfTest()`, register probe |
| Board catalog | 48 boards |
| Protocols on top | Modbus RTU (RS-485), Modbus TCP (W5500 socket), raw Ethernet frames (ENC28J60) |
| Examples | 16 |
| Build check | Every example compiled for AVR, megaAVR, SAMD, ESP32 and Renesas RA4 |

## 🧭 Where It Fits — Value and Limits

The value is in the discipline. Drivers verify the chip is there before running, report what the hardware said rather than a generic failure, and document the board-level traps that cost beginners hours. A W5500 project that needs a reliable bring-up path can take `selfTest()` and the `SCS`/`RST`/`INT` wiring notes even if it uses another library for sockets.

The limits are plain:

- The W5500 side covers sockets, DHCP and Modbus TCP; the docs describe no MQTT, HTTP or TLS layer, so those must come from elsewhere.

- DHCP renewal is left to the sketch.

- The README's hardware-validation statement covers CAN, RS-485 and Modbus rather than the Ethernet drivers specifically, so treat the W5500 path as source-reviewed and example-compiled, and verify it on your own hardware.

- It is a personally maintained v0.2.0 library, with a different continuity profile than a vendor-backed product.

## 🔗 Related WIZnet Maker Projects

| Project | Main Interface | W5500 Role | Difference from NiusBus |
| --- | --- | --- | --- |
| **NiusBus** | CAN / CAN FD / RS-485 / Modbus / Ethernet | Library-level TCP/IP socket driver | Multiple buses in one reusable library |
| [**Modbus RTU-to-TCP Gateway with W5500 and STM32**](https://maker.wiznet.io/jakelee/resellers/modbus-rtu-to-tcp-gateway-with-w5500-and-stm32/) | RS-485 + Ethernet | Modbus RTU ↔ Modbus TCP gateway | Focuses on one complete gateway application |
| [**ETH_CANable Firmware**](https://maker.wiznet.io/matthew/projects/eth-canable-firmware---can--iris-its------robot/) | Dual CAN + Ethernet | CAN frames over UDP/Ethernet | Focuses on one CAN-to-Ethernet application |
| [**Wiznet-W5500-library-for-Arduino**](https://maker.wiznet.io/scott/projects/wiznet-w5500-library-for-arduino/) | Ethernet | Arduino W5500 driver/library | Focuses specifically on W5500 Ethernet |

### Modbus RTU-to-TCP Gateway with W5500 and STM32

[View Maker Project](https://maker.wiznet.io/jakelee/resellers/modbus-rtu-to-tcp-gateway-with-w5500-and-stm32/)

This project uses an STM32F103 and a W5500io-M module to connect existing RS-485 Modbus RTU devices to a Modbus TCP network. The STM32 strips the RTU CRC16 and adds the MBAP header, while the W5500 handles TCP, UDP, ARP, ICMP and socket management in hardware.

NiusBus differs by providing the **RS-485, Modbus RTU, W5500, and Modbus TCP building blocks as reusable library components** rather than one fixed gateway application. The two sit at different levels: a gateway like this could be built on a library like NiusBus.

### ETH_CANable Firmware

[View Maker Project](https://maker.wiznet.io/matthew/projects/eth-canable-firmware---can--iris-its------robot/)

This STM32G474-based project is a dual-channel CAN-to-Ethernet bridge: a host sends SLCAN commands over UDP port 5001, the STM32 drives either CAN bus, and the W5500 provides the hardware UDP sockets. The documented protocol carries Classic CAN with payloads up to 8 bytes.

NiusBus instead exposes **CAN and W5500 as reusable communication drivers** rather than implementing a fixed CAN-to-Ethernet protocol.

### Wiznet-W5500-library-for-Arduino

[View Maker Project](https://maker.wiznet.io/scott/projects/wiznet-w5500-library-for-arduino/)

This is an Arduino library for the W5500 based on Arjen Hiemstra's Ethernet55, and the most direct comparison. Its page notes there are no working examples or user guides, so usage has to be read from the code.

NiusBus adds 16 examples, a module reference, troubleshooting pages and diagnostics around W5500 networking, and places it inside a broader CAN, CAN FD, RS-485, and Modbus framework.

## ❓ FAQ

**Does NiusBus support W5500?**
Yes. It supports network setup, DHCP, TCP client/server sockets and Modbus TCP examples.

**Is NiusBus only an Ethernet library?**
No. It also supports CAN, CAN FD, RS-485, Modbus RTU, raw Ethernet and serial-to-Ethernet modules.

**Does it require dynamic memory allocation?**
The library is designed without library-owned dynamic allocation, and DHCP is assembled in the W5500's transmit buffer so it fits on a UNO.

**Can I power a W5500 Lite from 5 V?**
Not through the pin marked `3.3V`. The signal pins are 5 V tolerant on genuine WIZnet silicon, but 5 V on the supply pin destroys the board.

**What platforms does it target?**
The repository verifies examples for AVR, megaAVR, SAMD, ESP32 and Renesas RA4.

---

Source: https://maker.wiznet.io/irina/projects/niusbus-one-arduino-library-for-can-rs-485-modbus-and-w5500-ethernet/
