Publish message to an MQTT broker with the specified Topic
Simulink Support Package for Android Devices / Communication
Use the MQTT Publish block to publish messages from your publisher (hardware) to the MQTT broker on the topic you specify in the Topic parameter.
message — Message to publish
Specify the message you want the publisher to publish to the MQTT broker as an
array of ASCII characters of type
Broker Service — MQTT broker service provider
ThingSpeak (default) |
Select the MQTT broker service provider that receives, filters, and sends messages to the clients.
ThingSpeak— When you specify this option, the MQTT access to your channels is handled by a ThingSpeak™ MQTT broker. To create an MQTT device, follow the steps in Create a ThingSpeak MQTT Device (ThingSpeak).
Other— Specify this option when the MQTT access to your channels is handled by other MQTT public brokers such as HiveMQ®, Mosquitto™, and so on.
Configure the same MQTT broker properties as in the MQTT properties.
Topic — Routing information for MQTT broker
channels/<channelID>/publish (default) | any valid topic name
Specify a topic that the publisher uses to filter messages. A topic can have a maximum of 128 characters. For information on topics and their structure, see Topics in MQTT.
Quality of Service — Level of quality of service
0 (default) |
Quality of Service (QoS) defines the reliability of the message delivery process in MQTT. MQTT provides three QoS levels for message delivery: QoS 0, QoS 1, and QoS 2. The MQTT broker that you are using might not support all three levels of QoS. For example, ThingSpeak MQTT supports only QoS 0.
Select a QoS level from the drop-down menu:
0— The publisher sends the message to the MQTT broker once. The broker does not send an acknowledgment of the receipt.
1— The publisher sends the message to the MQTT broker at least once. The publisher resends the message if it does not receive an acknowledgment from the broker.
2— The publisher sends the message to the MQTT broker exactly once. The publisher and broker exchange acknowledgments to ensure that the message is received only once.
Retain Message — Option to send message to new subscribers
off (default) |
Control how the MQTT broker handles new subscriptions.
on— When a new subscription is made to a topic, the broker identifies the message in its database with the matching topic name and sends the message immediately.
The MQTT broker retains only the last published message related to the specified topic.
off— When a new subscription is made to a topic, the subscriber must wait until the publisher sends the next message.
To enable this parameter, set Broker Service to
Update interval (seconds) — Rate of publishing message(s)
60 (default) | scalar
Enter the time interval in seconds to publish message(s) to the MQTT broker.
Introduced in R2023a