Skip to content

Contributed by Liming Jiangzhi!, organized by Ai-Thinker

Ai-WB2-32S AT+MQTT Command Series Usage


Preface

1. Notes

You must connect to the network before connecting

  • The domain can be a domain name or an IP address
  • The port number must be different from the server's port number
  • The user ID can be set to any value
  • Set the MQTT username (any username)
  • Set the MQTT password (any password)
  • Connection successful
Click to expand full code
javascript
//MQTT

+
EVENT
:
MQTT_CONNECT
  • Before connecting, you must configure the MQTT parameters first. If the MQTT task is already running, executing the connection again will reconnect (if you change servers, it is recommended to delete all subscriptions first and then reconnect)
  • The connection is asynchronous: showing OK only means the MQTT task has started. The connection status must be checked with AT+MQTT? or by waiting for the URC data "+EVENT:MQTT_CONNECT

2. Usage Example

1. Example Steps

Click to expand full code
javascript
AT
+
MQTT
=
1
,域名

AT
+
MQTT
=
2
,端口号

AT
+
MQTT
=
3
,
1

AT
+
MQTT
=
4
,sdt

AT
+
MQTT
=
5
,账户
ID

AT
+
MQTT
=
6
,密码

AT
+
MQTT
=
7
,
"XXX"
,
0
,
1
,
"XXX"

AT
+
MQTTSUB
=testtopic/
1
,
0

AT
+
MQTTPUB
=testtopic/
2
,
0
,
0
,
456

AT
+
MQTTUNSUB
=testtopic/
1

Screenshots of the Example Process and Results

Summary

Original link: <https://blog.csdn.net/qq_54193285/article/details/135864843?spm=1001.2014.3001.5501>

Released under the MIT License. Build Time 2026-09-11 14:52:23