MQTT Subscribe
This function block listens to an MQTT topic and outputs incoming messages for use elsewhere in your scenario. It keeps track of whether a message is new so you can trigger actions only when fresh data arrives.
π₯ Inputs
EnableInput socket β Enable or disable the subscription. When active, the block connects to the broker and listens for messages.
π€ Outputs
DataOutput socket β Latest received message payload (text) from the subscribed topic.New DataOutput socket β Boolean output socket that becomes true for one run when a new message arrives.
πΉοΈ Controls
Broker AddressHostname or IP of the MQTT broker to connect to.PortBroker TCP port (commonly 1883 or 8883 for TLS).TopicTopic string to subscribe to (supports exact topic matching).Client IDOptional identifier for the MQTT client.UsernameOptional username for broker authentication.PasswordOptional password for broker authentication.Keep AliveInterval used to maintain the broker connection.Use TLSToggle to enable TLS-secured connection (if supported by broker).Reconnect / ConnectButton or automatic logic in the UI to (re)establish connection when settings change.
(how these controls appear in the UI may vary; provide valid connection parameters and enable the block to start receiving messages)
π― Features
Persistent subscription while
Enableis true β messages are received in real time.Provides both the raw
Dataand a one-runNew Dataflag so downstream blocks can respond only to new messages.Automatically reconnects if connection parameters change.
Basic connection status and informational messages appear in the block UI to help diagnose connection events.
βοΈ Running mechanism
When
Enableis active, the block uses the configured connection settings to connect to the MQTT broker and subscribe to the chosenTopic.Incoming messages are stored internally and exposed on the
Dataoutput.The block sets
New Datato true only for the run immediately after a new message arrives; on subsequent runs it resets to false until another message is received.Changing connection settings causes the block to reconnect so the new parameters take effect.
π Usage instructions
Fill in connection parameters:
Broker Address,Port, andTopic(add credentials if broker requires them).Enable the block via the
Enableinput.Use the
Dataoutput to pass received payloads to other blocks. Use theNew Dataoutput to trigger downstream processing only when a new message arrives.If you change connection settings, allow a short moment for the block to reconnect.
π‘ Tips and Tricks
To forward received messages to a server or service, connect
DatatoREST API - Post.To re-publish or echo messages, combine this block with
MQTT PublishorMQTT Publish (TLS-Beta).Use
Data to JSONto structure multiple fields from incoming text before logging or exporting.Save incoming messages for later review by connecting
DatatoCSV Exportor toSQL-DB Operations(viaData to JSONor appropriate formatting).Add a
Debug Inputblock to quickly inspect message contents in the log window during development.When dealing with changing formats, use
Replace NoneorIs Noneblocks to handle missing or malformed messages gracefully.
(hints above use only the function blocks available in the system)
π οΈ Troubleshooting
No messages received: verify
Broker Address,PortandTopicare correct and that the broker is reachable from the machine running the scenario.Authentication errors: double-check
UsernameandPasswordand whether your broker requires TLS.Intermittent connection: check network/firewall settings and try enabling TLS or adjusting
Keep Alive.Messages arrive but are not forwarded: ensure downstream blocks are enabled and use the
New Dataflag if they should only run on new payloads.If you change parameters, wait briefly after re-enabling for the block to reconnect before expecting messages.
Last updated
Was this helpful?