Serial Connect
This function block opens and manages a serial (COM) connection. Use it to connect to serial devices, monitor connection state, and expose a connection identifier for other blocks to reference.
π₯ Inputs
This function block does not have any inputs.
π€ Outputs
ConnId Unique identifier for the opened serial connection. Use this value to reference the connection from other blocks.
Connected? Boolean flag that indicates whether the serial connection is currently active.
πΉοΈ Controls
Port COM port name to connect to (for example COM3).
Baud Communication speed (for example 115200).
Read timeout (s) Time in seconds to wait for read operations.
Line delimiter Select the line ending used by your device (LF / CRLF / CR).
AutoReconnect Switch that enables automatic reconnection when the connection drops.
Reconnect interval (s) Interval between reconnection attempts when auto-reconnect is enabled.
Idle disconnect (s) Time of inactivity after which the connection will be closed automatically to free the port.
π¨ Features
Automatic connection management: opens a connection with the configured parameters and keeps the
ConnIdavailable to other blocks.Auto-reconnect: optionally retries when the device becomes unavailable.
Idle disconnect: closes the port when unused to avoid locking the device for other applications.
Human-readable settings: select newline convention and tune timeouts to match the connected device.
π Usage Instructions
Set the
PortandBaudvalues to match your device.Configure
Read timeout (s)andLine delimiteraccording to your device protocol.Toggle
AutoReconnectand setReconnect interval (s)if you want the block to recover from disconnections automatically.Adjust
Idle disconnect (s)to let the block close the port when not in use.Run the scenario. The block will open the connection and output
ConnIdandConnected?. Use theConnIdin other communication blocks that accept a connection reference.
π Evaluation
When evaluated, the block ensures a serial connection exists with the current settings. If settings change, the previous connection is released and a new one is created. The outputs reflect the active connection id and whether the connection is currently established.
π‘ Tips and Tricks
Use
Led Outputto visually reflect theConnected?state in your UI.Use
String InputorNumber InputandString Mergeto craft commands to send over the serial link.Use
Data Write Global/Data Read Globalto share theConnIdor serial results with other parts of your scenario without direct wiring.Feed serial data into
Data to JSONorCSV Exportto log communication for later analysis.Forward parsed data to remote systems with
MQTT PublishorREST API - Postfor cloud integration or monitoring.Use
Debug Inputto inspect messages while developing your serial workflow.Combine with
Send Mailto trigger email alerts when connection drops or when specific messages arrive.
π οΈ Troubleshooting
If
Connected?remains false: verify the device port and baud settings match the device; check device drivers and OS device manager.If you cannot open the port: make sure no other application is using the same COM port. Close other programs or enable idle disconnect in those systems.
If lines appear truncated or merged: try a different
Line delimitersetting or increaseRead timeout (s).If frequent disconnects occur: enable
AutoReconnectand increaseReconnect interval (s)to give the device time to recover.If unexpected characters appear: confirm baud rate and parity settings with the device documentation and adjust accordingly.
Last updated