Usage Example for Easy IoT Platform - MQTT Communication

Last revision 2025/12/31

This article provides a detailed guide on setting up and using the Easy IoT Platform for MQTT communication, including hardware preparation, AT command usage, and step-by-step instructions for sending messages to a server.

Hardware Preparation

Note:

  • This module supports USB drivers under Windows 7/8/8.1/10, Linux, Android and other operating systems, so no need to install drivers.
  • This AT command is case insensitive.
  • Upon connecting the module to a computer, three COM ports will appear, of which only one is designated for AT command debugging. The remaining two COM ports are not operational.

Command set used

Command Meaning Return Value
AT+CPIN? Query whether sim card is normal +CPIN: READY
AT+CGATT? Query whether it is attached to the data network +CGATT: 1
AT+MCONFIG="clientid","user","password" Set MQTT related parameters OK
AT+MIPSTART="svraddr","port" Establish TCP connection CONNECT OK
AT+MCONNECT=clean_session, keepalive Client requests session connection to server CONNACK OK
AT+MSUB="topic",qos Subscribe to topic SUBACK
AT+MPUB="topic",qos,retain,"message" Publish message

Operation Steps: send a message to the target server

Enter Easy IoT. If you do not possess an account, you may commence by registering one.
Upon successful login, proceed to open your workspace. Retrieve your credentials: username, password. Then, proceed to add a novel device, denoted as a Topic, and meticulously document the aforementioned three pivotal parameters.

Easy IoT

  1. Open SSCOM Assistant, send AT+CPIN? to query if the SIM card is normal. If +CPIN: READY is returned, it indicates that the SIM card is normal. If +CME ERROR: 10 is returned, it means that the SIM card is not inserted.

  2. Send AT+CGATT? to query whether it is attached to the data network. +CGATT: 1 indicates that the current GPRS is already attached. If +CGATT: 0 is returned, it indicates that it is not attached.

  3. Send AT+MCONFIG="12345678987","user","password" (Set MQTT related parameters: "clientid" is customized as "12345678987" (max 256 bytes, unique), "user" and "password" are from Easy IoT platform).

  4. Send AT+MIPSTART="iot.dfrobot.com","1883" to establish TCP connection. Note: Receiving OK only means the module starts processing; CONNECT OK indicates success.

  5. Send AT+MCONNECT=1,60 to connect to MQTT server ("1" = new session, "60" = keep-alive time). Note: CONNACK OK indicates success.

  6. Send AT+MSUB="mqtt/sub_topic",0 to subscribe to the topic ("mqtt/sub_topic" is from Easy IoT platform, "0" = QoS 0). Note: SUBACK indicates success.

  7. Send AT+MPUB="mqtt/pub_topic",2,0,"HELLO DFROBOT" to publish a message ("mqtt/pub_topic" is from Easy IoT platform, "2" = QoS 2, "0" = no retention, "HELLO DFROBOT" = message content). Note: PUBCOMP indicates success for QoS 2.

    success1

  8. Finally, enter the Easy IoT workspace, check the details of the created topic, and query the information received from the module.

    success2

Note: All published commands need to check "Add Carriage Return Line Feed"

Was this article helpful?

TOP