Objective: Use a RevPi base module as a Modbus TCP Client to read data from or write data to server devices. The configuration is performed in the RevPi application PiCtory using a practical example.
Using the RevPi as a Modbus TCP Client is suitable for scenarios where devices such as sensors, actuators, or other industrial equipment need to be controlled or monitored in a networked environment.
This tutorial applies to all RevPi base modules.
Prerequisites #
Devices
✓ Server device(s)
✓ Cable with RJ45 connectors
Hardware Installation
✓ The RevPi base module is connected to the network.
✓ The RevPi base module is connected to the power supply.
✓ The server devices are connected to the RevPi via the RJ45 connector.
Software Installation
✓ Web browser (e.g., Chrome, Firefox, or Edge)
✓ The RevPi and the server devices are on the same network.
✓ Each server device has a unique IP address.
✓ The IP addresses and ports of all server devices are documented according to the manufacturer’s specifications.
|
Note
|
Multiple server devices should not have the same IP address on the same port, as this causes communication errors. |
|
Note
|
As of RevPi Bookworm (08/2025) the firewall on the RevPi must also be enabled to allow the default ports of the Modbus server: ▷ Add the service revpi-modbus-default to the firewall settings in Cockpit, see Firewall. |
1. Configuring the Modbus TCP Client in PiCtory #
▷ Start PiCtory.
▷ Drag the RevPi base module from the Device Catalog to the empty slot in the configuration area with position number 0.
▷ Drag a ModbusTCP Master [1] from Virtual Modbus Devices in the Device Catalog to the base module in the configuration area.
❯ The virtual device is now displayed in the configuration area.
▷ Select the Modbus TCP Client in the configuration area.
▷ Configure the following parameters at the very bottom of the list in the Value Editor:
-
slave_IP_address: IP address of the Modbus TCP server.
-
slave_tcp_port: Default is
502, as specified in the Modbus specification. This can be changed if required.
▷ In the Value Editor, you can also optionally assign suitable I/O names for easier reference, e.g., Modbus_Input_1.
See also Configuring Values.
▷ Select to save the configuration.
▷ Select to apply the configuration.
2. Configuring Modbus Commands #
▷ Open the context menu of the Modbus TCP Client in the configuration area.
▷ Select Extended Data to open the command configuration window.
▷ Configure the commands using the following parameters:
| Parameter | Description |
|---|---|
Unit ID |
This address can be found in the server manual. |
Function Code |
|
Register Addr. |
Define the Modbus register or bit address to be accessed. |
Quantity of Registers |
Number of registers or bits to read/write. |
Action Interval (ms) |
Time interval for sending the command in milliseconds. |
Device Value |
Name of the variable in the process image. |
|
Note
|
For devices that use 0-based addressing, the register address must be incremented by 1 during configuration. |
▷ Select to save the configuration.
▷ Select to apply the configuration.
3. Task Management and Error Codes #
The Modbus TCP Client can manage up to 32 tasks. Each task has its own status and reset registers available in the process image.
If an error occurs while a task is being executed, an error code is stored in the corresponding status register: Modbus_Action_Status[1…32].
The error remains stored until the corresponding reset register is set to 1: Action_Status_Reset[1…32].
The status registers can contain both Modbus exception codes from the server and communication or driver errors.
▷ If communication problems occur, check the Modbus_Master_Status register in the Value Editor.
Common error codes:
| Code | Description |
|---|---|
|
The TCP connection to the Modbus server could not be established. |
|
No valid response received from the Modbus server. |
|
Connection timeout. |
Possible error causes:
-
Network connection interrupted
-
Incorrect IP address or port number
-
Invalid register address
-
Overlapping or conflicting Modbus commands
-
Firewall blocks communication
Example: Temperature Measurements with RevPi as Modbus TCP Client #
The Inveo NANO TEMP temperature sensor serves as the Modbus server in this example.
Configuration
▷ Refer to the sensor manual for the following data:
| Parameter | Value |
|---|---|
IP address |
|
Port |
|
Modbus register |
|
Modbus function |
|
Server address |
|
▷ Configure the settings accordingly in PiCtory in the Extended Data window:
-
Unit ID: 1
-
Function Code: READ_HOLDING_REGISTERS
-
Register Addr.: 4004
-
Quantity of Registers: 1
-
Action Interval (ms): 1000
-
Device Value: Input_Word_1
▷ Save the configuration and reset the driver.
Querying Data
▷ Open a terminal and run:
piTest -r Input_Word_1
❯ You receive the data from your server:
2 Byte-Value of Input_Word_1: 284 dec (=011c hex)
The value 284 corresponds to 28.4 °C.