[아두이노#614] Arduino에 W5500을 연결해서 C#윈폼으로 모드버스(modbus) TCP의 프로토콜에 대해서 이해하고 통신하는 방법 알아보기!(녹칸다의 아두이노 시즌2)
Arduino + W5500 runs Modbus TCP with C# WinForms UI, showing coil control, register read/write, and key RTU vs TCP differences.

1. Overview
By combining Arduino with the W5500 Ethernet module, you can easily implement Modbus TCP communication for industrial and IoT applications.
This post explains the differences between Modbus RTU and TCP, introduces common function codes, and demonstrates a C# WinForms UI that controls and monitors LEDs via Modbus TCP.
2. Modbus RTU vs TCP
- Modbus RTU
- Requires CRC16 checksum for error detection.
- Works over serial communication such as RS-485/RS-232.
- Slave address is represented in 1 byte.
- Modbus TCP
- No CRC required, since error handling is done by TCP/IP layers.
- Adds a 6-byte MBAP header (Transaction ID, Protocol ID, Length, Unit ID).
- Still keeps the Unit ID field, but in practice devices are identified by IP address.
👉 Conclusion: Modbus TCP is more scalable and suitable for network-based industrial control compared to RTU.
3. Modbus Basics
- Coils: 1-bit storage (ON/OFF, usually mapped to GPIO pins).
- Registers: 16-bit storage (used for sensor values or internal variables).
- Function Codes (FC):
0x05
: Write Single Coil0x01
: Read Coils0x03
: Read Holding Registers0x06
: Write Single Register0x10
: Write Multiple Registers
4. Arduino + W5500 Example
(1) Write Single Coil (FC = 0x05)
Control an LED connected to digital pin 2.
- ON Command
0x00 0x01 0x00 0x00 0x00 0x06 0x01 0x05 0x00 0x00 0xFF 0x00