Modbus Connect
This function block establishes a Modbus TCP connection to a remote device and provides a reusable Modbus Client output that other blocks can use to perform reads/writes.
π₯ Inputs
This function block does not have any inputs.
π€ Outputs
Modbus Client A connected Modbus client reference that can be fed into communication blocks to read or write registers.
πΉοΈ Controls
IP Address Enter the Modbus TCP server IP address (for example 192.168.0.10).
TCP Port Enter the Modbus TCP port (default is commonly 502).
βοΈ Running mechanism
When evaluated, the block attempts to connect to the Modbus server at the address and port provided in the controls.
If the address or port is changed, or if the connection drops, the block will attempt to reconnect automatically and continues to provide an updated
Modbus Clientoutput for other blocks.Other blocks receive the
Modbus Clientthrough the output socket and use it to perform communication tasks (reads/writes).
π― Features
Persistent connection output so multiple blocks can share a single client.
Automatic reconnection when address changes or the connection is lost.
Simple UI controls for IP and port configuration.
π How to use
Set the
IP AddressandTCP Portin the controls.Let the scenario run β the block will establish the connection and provide the
Modbus Clienton its output.Connect the
Modbus Clientoutput to communication blocks that require it (for example read/write blocks) to perform Modbus operations.
π‘ Tips and Tricks
To read data regularly, connect the
Modbus Clientoutput to theModbus Readblock and use aLogic Inputor another trigger to control when reads happen.To write commands or values, feed the
Modbus Clientto theModbus Writeblock and use a logic trigger to perform writes only when needed.Forward telemetry to remote systems by combining with
MQTT Publish(connect output from a read block intoMQTT Publish) for lightweight messaging.Save or log values by sending read outputs into
SQL-DB OperationsorCSV Exportfor persistent storage and later analysis.Use
Debug InputorScopeto inspect values coming from read blocks during setup and troubleshooting.
(hint: recommended companion blocks β Modbus Read, Modbus Write, Logic Input, MQTT Publish, SQL-DB Operations, CSV Export, Debug Input, Scope)
π οΈ Troubleshooting
Connection refused or timeouts β check the
IP AddressandTCP Portare correct and that the Modbus server is reachable on the network.Firewall or network rules β ensure the port used for Modbus TCP is allowed through firewalls on both ends.
Multiple clients β if the server limits connections, avoid creating many simultaneous connections; share the provided
Modbus Clientoutput with other blocks.If connection appears unstable, verify the network quality and try a different network cable or switch port.
Last updated