Connect Slave Device via Modbus RTU

Modbus RTU enables serial communication between the OpenPLC master and slave devices. OpenPLC supports Modbus RTU master mode on Linux and Windows. Microcontroller-based devices (such as Arduino) without an OS are supported only as Modbus RTU slaves.

Hardware Preparation

Prepare for the following hardware items:
Item Quantity Note
VisionFive 2 or VisionFive 2 Lite 1 Configured as master device
Arduino UNO 1 Configured as slave device
Breadboard 1 For Slave board wiring
LED 2 Preferably two different colors
Button 2 For digital input testing
USB-to-Serial adapter 1 Corresponding to the enabled type in the kernel options.
Dupont wires Several For breadboard connections

Hardware Setup

Figure 1. Hardware Setup

Configure Arduino UNO

Upload the default Blank Program to the Arduino UNO.

  1. Connect Arduino UNO and PC by USB.

  2. Open the OpenPLC runtime and prepare the program needed to run Arduino UNO as a Modbus-TCP slave device.

  3. Click the icon, as in Step 1, to open the detailed settings. In the Board type field, select Arduino UNO and select the corresponding COM port. Select Enable Modbus RTU (Serial) to enable communication between the Arduino UNO and the master device via serial.
    Figure 2. Arduino UNO
  4. Click the Upload button to compile and upload the program and OpenPLC micro-runtime to the Arduino UNO. The message Done is displayed when the upload process is completed.

Add Slave Device on Master Board

Add Arduino UNO as a slave device on the master VisionFive 2 board:
  1. Open the OpenPLC web interface: http://<Master-IP>:8080

  2. Navigate to Slave Devices in the left menu.

  3. Click Add New Device.
    Figure 3. Configure Slave Device
  4. As OpenPLC supports Arduino UNO by default, only the device name, device type, and connected port need to be configured.