11 MQTT

MQTT Commands

11.1 AT Commands

AT Command
Description
MQTT Connection Parameters
MQTT Connect to Broker
MQTT Keep Alive
MQTT Last Will and Testament
MQTT TLS Configuration
MQTT Disconnect
MQTT Publish String
MQTT Publish Binary
MQTT Subscribe
MQTT Read String
MQTT Read Binary

11.1.1 AT+UMQCP - MQTT Connection Parameters

Syntax
AT Command
Description
AT+UMQCP=<mqtt_id>,<hostname>,<port>[,<client_id>[,<username>[,<password>]]]
Set the MQTT connection parameters.


Notes:
Can be stored using AT&W.
AT+UMQCP=<mqtt_id>
Get the MQTT connection parameters.
Response
Description
+UMQCP:<mqtt_id>,<hostname>,<port>,<client_id>,<username>
Successful read response
Defined values
Parameter
Type
Description
hostname
string
Hostname or IP address of the broker

Valid length: 0..128
port
integer
The port of the broker

Valid values: 1..65535
client_id
string
Client ID. Can be left empty to let the broker decide

Valid length: 0..128
username
string
Valid length: 0..128
password
string
Valid length: 0..128
mqtt_id
integer
MQTT Config ID

Valid values: 0 only
Notes
Empty strings for username and password mean they will not be used during the connection.

11.1.2 AT+UMQC - MQTT Connect to Broker

Syntax
AT Command
Description
AT+UMQC=<mqtt_id>
Connect to a broker using the MQTT config ID.
Defined values
Parameter
Type
Description
mqtt_id
integer
MQTT Config ID

Valid values: 0 only

11.1.3 AT+UMQKA - MQTT Keep Alive

Syntax
AT Command
Description
AT+UMQKA=<mqtt_id>,<keep_alive>
Set keepalive timeout for MQTT the MQTT config

Notes:
Can be stored using AT&W.
AT+UMQKA=<mqtt_id>
Get keepalive timeout for MQTT config
Response
Description
+UMQKA:<mqtt_id>,<keep_alive>
Successful read response
Defined values
Parameter
Type
Description
mqtt_id
integer
MQTT Config ID

Valid values: 0 only
keep_alive
integer
MQTT keepalive in seconds. If set to 0, no keepalive is used

Valid values: 0..65535

Default value: 60

11.1.4 AT+UMQLWT - MQTT Last Will and Testament

Syntax
AT Command
Description
AT+UMQLWT=<mqtt_id>,<topic>,<will_msg>[,<qos>[,<retain>]]
Add last will and testament configuration for the client

Notes:
Can be stored using AT&W.
AT+UMQLWT=<mqtt_id>
Get last will and testament configuration for the client
Response
Description
+UMQLWT:<mqtt_id>,<topic>,<will_msg>,<qos>,<retain>
Successful read response
Defined values
Parameter
Type
Description
will_msg
string
Valid length: 0..256
mqtt_id
integer
MQTT Config ID

Valid values: 0 only
topic
string
Topic name or filter (wildcard allowed)

Valid length: 0..256
qos
enumerator
Quality of Service (QoS) for the message or topic

Valid values:
0: At most once
1: At least once
2: Exactly once

Default value: 0
retain
enumerator
Retain flag for message

Valid values:
0: Do not retain message on broker
1: Retain message on broker

Default value: 0

11.1.5 AT+UMQTLS - MQTT TLS Configuration

Syntax
AT Command
Description
AT+UMQTLS=<mqtt_id>,<tls_version>[,<ca_name>[,<client_cert_name>,<client_key_name>]]
Setup MQTT TLS config. Certs do not have to be uploaded until connection.

Notes:
Can be stored using AT&W.
AT+UMQTLS=<mqtt_id>
Get TLS config
Response
Description
+UMQTLS:<mqtt_id>,<tls_version>,<ca_name>,<client_cert_name>,<client_key_name>
Successful read response
+UMQTLS:<mqtt_id>,<tls_version>
Successful read response with TLS off
Defined values
Parameter
Type
Description
tls_version
enumerator
Minimum TLS version to use

Valid values:
0: Disable TLS
1: TLS 1.2 or up
ca_name
string
Name of the certificate authority (CA) certificate to use

Valid length: 1..32
client_cert_name
string
Name of the client certificate to use

Valid length: 1..32
client_key_name
string
Name of the private key for client certificate

Valid length: 1..32
mqtt_id
integer
MQTT Config ID

Valid values: 0 only

11.1.6 AT+UMQDC - MQTT Disconnect

Syntax
AT Command
Description
AT+UMQDC=<mqtt_id>
Disconnect the MQTT client from the broker.
Note that the disconnection is not complete until the +UEMQDC URC arrives.
Defined values
Parameter
Type
Description
mqtt_id
integer
MQTT Config ID

Valid values: 0 only

11.1.7 AT+UMQPS - MQTT Publish String

Syntax
AT Command
Description
AT+UMQPS=<mqtt_id>,<qos>,<retain>,<topic>,<message>
Publish an MQTT message in string format to the specified topic.
Defined values
Parameter
Type
Description
mqtt_id
integer
MQTT Config ID

Valid values: 0 only
qos
enumerator
Quality of Service (QoS) for the message or topic

Valid values:
0: At most once
1: At least once
2: Exactly once

Default value: 0
retain
enumerator
Retain flag for message

Valid values:
0: Do not retain message on broker
1: Retain message on broker

Default value: 0
topic
string
Topic name or filter (wildcard allowed)

Valid length: 0..256
message
string
MQTT message

Valid length: 0..730

11.1.8 AT+UMQPB - MQTT Publish Binary

Syntax
AT Command
Description
AT+UMQPB=<mqtt_id>,<qos>,<retain>,<topic>{binary_data}
Publish an MQTT message in binary format to the specified topic.
Defined values
Parameter
Type
Description
binary_data
binary
The MQTT message data.
mqtt_id
integer
MQTT Config ID

Valid values: 0 only
qos
enumerator
Quality of Service (QoS) for the message or topic

Valid values:
0: At most once
1: At least once
2: Exactly once

Default value: 0
retain
enumerator
Retain flag for message

Valid values:
0: Do not retain message on broker
1: Retain message on broker

Default value: 0
topic
string
Topic name or filter (wildcard allowed)

Valid length: 0..256

11.1.9 AT+UMQS - MQTT Subscribe

Syntax
AT Command
Description
AT+UMQS=<mqtt_id>,<subscribe_action>,<topic>[,<qos>]
Subscribe or unsubscribe to/from MQTT topic.
Defined values
Parameter
Type
Description
subscribe_action
enumerator
Valid values:
0: Subscribe to topic
1: Unsubscribe from topic
mqtt_id
integer
MQTT Config ID

Valid values: 0 only
topic
string
Topic name or filter (wildcard allowed)

Valid length: 0..256
qos
enumerator
Quality of Service (QoS) for the message or topic

Valid values:
0: At most once
1: At least once
2: Exactly once

Default value: 0

11.1.10 AT+UMQRS - MQTT Read String

Syntax
AT Command
Description
AT+UMQRS=<mqtt_id>
Read available MQTT message in string format.
Response
Description
+UMQRS:<mqtt_id>,<topic>,<message_len>,<message>
Successful read response
Defined values
Parameter
Type
Description
mqtt_id
integer
MQTT Config ID

Valid values: 0 only
topic
string
Topic name or filter (wildcard allowed)

Valid length: 0..256
message_len
integer
Length of the MQTT message
message
string
MQTT message

Valid length: 0..730

11.1.11 AT+UMQRB - MQTT Read Binary

Syntax
AT Command
Description
AT+UMQRB=<mqtt_id>
Read available MQTT message in binary format.
Response
Description
+UMQRB:<mqtt_id>,<topic>{binary_data}
Successful read response
Defined values
Parameter
Type
Description
binary_data
binary
The MQTT message data.
mqtt_id
integer
MQTT Config ID

Valid values: 0 only
topic
string
Topic name or filter (wildcard allowed)

Valid length: 0..256

11.2 Unsolicited Response Codes

Unsolicited Response Code
Description
Event MQTT Connected
Event MQTT Disconnected
Event MQTT Data Available

11.2.1 +UEMQC - Event MQTT Connected

Connected to MQTT broker
Syntax
+UEMQC:<mqtt_id>
Defined values
Parameter
Type
Description
mqtt_id
integer
MQTT Config ID

Valid values: 0 only

11.2.2 +UEMQDC - Event MQTT Disconnected

Disconnected from MQTT Broker
Syntax
+UEMQDC:<mqtt_id>,<disconnect_reason>
Defined values
Parameter
Type
Description
disconnect_reason
integer
Disconnection reason
mqtt_id
integer
MQTT Config ID

Valid values: 0 only

11.2.3 +UEMQDA - Event MQTT Data Available

Syntax
+UEMQDA:<mqtt_id>,<message_len>
Defined values
Parameter
Type
Description
mqtt_id
integer
MQTT Config ID

Valid values: 0 only
message_len
integer
Length of the MQTT message
Last updated: 04 March 2025
Need help?Contact Support
Questions?Contact us