3.2 MQTT Client Mode (MQTT)
In the NORMAL mode chapter, we introduced in detail about the module setup process and the use of AT commands, in
this chapter and other modes of introduction, we only do some simple introduction and use of AT commands for the
function.
The MQTT protocol is lightweight, simple, open and easy to implement, which makes it suitable for a wide range of
applications. In many situations, including restricted environments, such as: machine-to-machine (M2M)
communication and the Internet of Things (IoT). It has been widely used in, for example, communication sensors via
satellite links, occasional dial-up medical devices, smart homes, and some miniaturized devices
3.2.1 Setup process
When the module is working in MQTT mode, some sub-functions of other modes will not be enabled at this time (e.g.
NORMAL's remote AT command will not
When using MQTT mode, if the user wants to access the public network, realize long-distance transmission or access
the cloud server, he needs to know that the network role of the module should be set to STA mode. In the following,
ONENET is used as an example to introduce the access method and communication.
1. Enter AT mode, so that the current network role is in STA mode
+++ AT+ROLE=STA
2. Connect the destination WIFI (AP), access the network AT+STA=EBYTE,2,JSZXE880
3. switch mode, set the working mode to MQTT mode AT+MODE=MQTT
4. set the MQTT connection information, connect to ONENET's MQTT server (provided that the user has created the
relevant MQTT device) AT+MADDR=183.230.40.39,6002 (the address can be either an IP or a URL)
5. Set the MQTT access information (the specific information is filled in according to the user's actual parameters)
AT+MUSER="ClientID", "Username", "Userpassword " (the parameters here must be quoted differently)
6. AT+MSUB=Topic,Qos
7. set the MQTT upload information AT+MPUB= Topic,Qos,Retain
8,restart to take effect command AT+RST