WiFi MQTT Subscribe
Receive messages from message queuing telemetry transport (MQTT) broker
Simulink Support Package for Arduino Hardware / WiFi
Use the WiFi MQTT Subscribe block to receive messages from the message queuing telemetry transport (MQTT) broker on the specified topic.
The WiFi MQTT Subscribe block supports MQTT over TCP/IP sockets only.
The WiFi MQTT Subscribe block supports these hardware boards.
Arduino MKR WiFi 1010
Arduino MKR 1000
Arduino Nano 33 IoT
ESP32-WROOM (Arduino Compatible)
ESP32-WROVER (Arduino Compatible)
isNew — New message indicator
0 (default) |
The block outputs
1 if the client receives a new message since
the last sample time. Otherwise, the block outputs
message — Message received from MQTT broker
The block outputs the message received from the MQTT broker as an array of ASCII characters.
topic — Topic of message
The block outputs ASCII values corresponding to the topic name of the received
message. For example, if the topic of the received message is
model/data, the port outputs the topic as
109 111 100
101 108 47 100 97 116 97.
To convert the ASCII values into their alphanumeric equivalent, attach an ASCII to String block to the output of the topic port. A topic can have a maximum of 128 characters. For information on topics and their structure, see Topics in MQTT (Simulink Support Package for Raspberry Pi Hardware).
To enable this port, include a wildcard entry in the Topic parameter. For more information on wildcards in MQTT, see Wildcards in MQTT Topics (Simulink Support Package for Raspberry Pi Hardware).
Topic — Topic for subscription
channels/<channelID>/subscribe (default) | any valid topic name
Specify a topic to which the client subscribes. A topic can have a maximum of 128 characters. For information on topics and their structure, see Topics in MQTT (Simulink Support Package for Raspberry Pi Hardware).
Data length — Length of data read from the MQTT broker
10 (default) |
Specify the length of the data you want to receive at each sample time.
Print diagnostic messages — Print MQTT broker response on serial port
off (default) |
Select this option to print the response from the MQTT broker on the Arduino® serial port for each publish request.
Sample time — Frequency to check for messages from MQTT broker
1 (default) |
-1 | any positive integer
Specify how often the client checks for a new message from the broker. When you
specify the sample time as
-1, the block inherits its sample time
based on the context of the block within the model.
Introduced in R2022b