Get Started
MQTT Communication
On this page
  1. Commands
  2. Fields
  3. Output variables

MQTT Communication

Publishes messages to an MQTT broker, or subscribes to a topic and receives messages. MQTT is a lightweight messaging protocol optimized for low-power, low-bandwidth environments and widely used in IoT. The broker connection (host, port, authentication, TLS) is registered in Settings > MQTT Client (Part 6).

MQTT Client

Select the MQTT client to use.

Commands

  • Publish (default): Sends a message to the topic.
  • Subscribe: Subscribes to the topic and requests the messages that arrive. If the topic is already subscribed, only the messages are requested.

Fields

Topic

Enter the topic to publish to or subscribe to (for example, home/sensor/temperature). A topic is the path a message is delivered through, with levels separated by slashes (/).

QoS

Select the quality-of-service level of the message. The default is QoS 1; a higher number gives more reliability but uses more network resources.

  • QoS 0: Sends the message without checking for a response. The message may not be delivered.
  • QoS 1: Resends the message until a response arrives. The message may be delivered more than once.
  • QoS 2: Guarantees exactly-once delivery with a four-way handshake.
Message

Enter the message to publish. Displayed only when Command is Publish.

Retain Message

When on, the last message sent is stored on the broker so that newly connecting subscribers receive it immediately. The default is off. Displayed only when Command is Publish.

Max Wait Time

Enter how long (duration) to wait for a message. The default is 1 second; when the time is exceeded, no message is considered received. Displayed only when Command is Subscribe.

Output variables

  • Receive Complete: A Digital variable that becomes true the moment a new message is received and false otherwise.
  • Received Topic: A Text variable for the topic of the received message.
  • Received Message: A Text variable for the received message.

All three are displayed only when Command is Subscribe.