MQTT Subscribe

Target Category: Arduino, Generic MCU, Linux AMD64 and Raspberry Pi

Target Sub-Category: IoT > ESP8266WiFi

Block Sub-Category: Extensions > IoT

Description: The MQTT Subscribe block receives messages on topics to which you have subscribed. When you subscribe to a topic, the Message Queuing Telemetry Transport (MQTT) broker sends messages to the MQTT Subscribe block on that topic. The broker is primarily responsible for receiving all messages, filtering messages, deciding who is interested in the messages, and publishing the messages to all subscribed clients.

The MQTT Subscribe block has two outputs:

      rdy: Lets you know when new data has arrived.

      val: The data in string format.

Host Name: Specifies the MQTT broker address. For SmartWorks, use mqtt.swx.altairone.com.

Keep Alive: Specifies the maximum time interval between when the client finishes sending a PING message to the broker and starts to send the next PING message. The maximum time interval is 18 hours, 12 minutes, and 15 seconds. When Keep Alive is set to 0, the keep alive mechanism is de-activated and Last Will and Testament is ignored. The default time interval is 60 sec.

Last Will and Testament

Message: Specifies the last will message to be sent to subscribers. If the broker detects that the publisher has unexpectedly disconnected, it sends the last will message to all subscribers of the specified topic.

Retain last will message on server: Retains the last message if the subscriber unexpectedly disconnects.

Will QoS: Specifies the quality of service to the broker. Your choices are:

0: Sends the message once with no guarantee of delivery. The broker does not acknowledge delivery.

1: Guarantees message delivery, but it could send duplicates. The broker acknowledges delivery.

2: Guarantees message delivery without duplicates. The broker acknowledges delivery, then both the broker and publisher discard the stored messages.

Password: Specifies the user password. This is used for authenticating with the broker. As you type the password into the Password parameter, the typed characters are converted to dots.

Port: Indicates the port that the broker is using. The default unencrypted port is 1883; the default encrypted port is 883.

QoS: Specifies the quality of service to the server. Your choices are:

0: Sends the message once with no guarantee of delivery. The server does not acknowledge delivery.

1: Guarantees message delivery, but it could send duplicates. The server acknowledges delivery.

2: Guarantees message delivery without duplicates. The server acknowledges delivery, then both the server and publisher discard the stored messages.

Topic: Specifies the topic on which the message is to be subscribed. For example, spaces/smartwork/categories/mqtt/things/01GKPF0X8JKAFVFDNCA42PVGS/data

User Name: Specifies the account user name attached to your device. This is used for authenticating with the broker. For example Embed@smartwork.

Examples

See Examples > Blocks > Extensions > IoT.