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 Client output for other blocks.

  • Other blocks receive the Modbus Client through 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

  1. Set the IP Address and TCP Port in the controls.

  2. Let the scenario run β€” the block will establish the connection and provide the Modbus Client on its output.

  3. Connect the Modbus Client output 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 Client output to the Modbus Read block and use a Logic Input or another trigger to control when reads happen.

  • To write commands or values, feed the Modbus Client to the Modbus Write block 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 into MQTT Publish) for lightweight messaging.

  • Save or log values by sending read outputs into SQL-DB Operations or CSV Export for persistent storage and later analysis.

  • Use Debug Input or Scope to 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 Address and TCP Port are 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 Client output with other blocks.

  • If connection appears unstable, verify the network quality and try a different network cable or switch port.

Last updated