MQTT Subscribe

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

Target Sub-Category: IoT, IoT > ESP8266WiFi

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 output connector tabs:

      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 mqttbroker.altairsmartcore.com for data exchange and mqtt.altairsmartcore.com for API.

Keep Alive: Specifies the keep alive period. That is, how often the client sends a PING message to the broker. 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.

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 published. For SmartWorks, enter your-API-key/streams.

User Name: Specifies the user ID on the MQTT broker. This is used for authenticating with the broker. For SmartWorks, enter your API key.

Examples

See Examples > Blocks > Extensions > IOT.