pdf-icon

Unit MQTT

SKU:U129

Description

Unit MQTT is an Ethernet MQTT communication module with an embedded W5500 Ethernet chip. It uses a UART communication interface (controlled by AT commands) and integrates an RJ45 adaptive 10/100M Ethernet port. It supports 4x Topic subscriptions. With extremely low network latency and high stability, it is suitable for various industrial automation, security monitoring systems, automatic measurement and control systems, and device data cloud applications.

Features

  • Embedded W5500 Ethernet chip
  • RJ45 Ethernet port 10/100Mbps
  • Ethernet MQTT communication
  • Supports 4x Topic subscriptions
  • Low latency
  • Development methods:
    • AT commands, UART: 9600bps default
    • Development platforms: UIFlow, Arduino

Includes

  • 1 x Unit MQTT
  • 1 x HY2.0-4P Grove cable (20cm)

Applications

  • Remote data collection/cloud upload

Specifications

Specification Parameter
Module Processor ARM Cortex-M3
Communication Interface UART: baud 9600bps 8N1 default
MQTT Supports 4x Topic subscriptions, does not support MQTTS
Ethernet Port RJ45 adaptive 10/100M Ethernet port
Delay Latency `10ms
Standby Current 40.4mA
Net Weight 22.4g
Gross Weight 27.2g
Product Dimensions 72 x 26 x 19mm
Package Dimensions 73 x 35 x 20mm

PinMap

Unit MQTT

HY2.0-4P Black Red Yellow White
PORT.C GND 5V UART_TX UART_RX

Softwares

Arduino

UIFlow 2.0

Protocol

Note: Each command must end with a carriage return and line feed \r\n

Setting AT Commands

AT+NETMAC=MAC Address

  • Command Description: Set the module's MAC address
  • MAC address must be in the format: XX-XX-XX-XX-XX-XX
//Example
AT+NETMAC=12-34-56-78-90-AB
+NETMAC=OK

AT+NETSTATICIP=IP Address, Subnet Mask, Gateway

  • Command Description: Set the module's static IP address (AT+NETSTATICIP=IP Address, Subnet Mask, Gateway)
Note:
When DHCP is enabled, the static IP setting will not take effect
IP Address (text), represents the local IP address, can be an IP address or domain name
Subnet Mask (text), must be in IP address format
Gateway (text), must be in IP address format
//Example
AT+NETSTATICIP="192.168.0.101","255.255.255.0","192.168.0.1"
+NETSTATICIP=OK

AT+NETDHCPEN=1/0

  • Command Description: Enable/disable DHCP function 1/0
    1: Enable DHCP function
    0: Disable DHCP function
//Example
AT+NETDHCPEN=1
+NETDHCPEN=OK

AT+MQCLIENTID=Client Name

  • Command Description: Set MQTT server
    Client Name
    (text) MQTT client name
//Example
AT+MQCLIENTID="CLIENT ID"
+MQCLIENTID=OK

AT+MQKEEP=Keep Alive Time

  • Command Description: Set the keep-alive time for connecting to the MQTT server
    Keep Alive Time
    The interval for automatically sending PINGREQ packets, unit: seconds, range 5~300
//Example
AT+MQKEEP=500
+MQKEEP=OK

AT+MQSUBSCRIBE=Topic Number**,1/0,Topic Name,**QoS

  • Command Description: Set the topic to subscribe to on the MQTT server. This module can subscribe to 4 topics simultaneously. Modifying the subscription topic with this command will not immediately subscribe or unsubscribe; it will take effect the next time the MQTT connection is established.
    Topic Number Number 1-4
    1/0 1: Enable subscription for this topic, 0: Disable subscription for this topic. When this parameter is 0, the following two parameters must be empty.
    Topic Name (text) QoS must be one of 0, 1, 2.
//Example
AT+MQSUBSCRIBE=1,1,"sub",0
+MQSUBSCRIBE=OK

AT+MQSERVER=Server Address**,**Server Port

  • Command Description: Set the MQTT server address and port number
    Server Address
    (text), can be an IP address or domain name
    Server Port Number 0~65535
//Example
AT+MQSERVER="xxx.mqttserver.com",1883
+MQSERVER=OK

AT+MQUSERPWD=Username**,**Password

  • Command Description:
    Set username and password Username (text) MQTT username
    Password (text) MQTT login password
//Example
AT+MQUSERPWD="user","123456"
+MQUSERPWD=OK

AT+MQAUTO=1/0

  • Command Description:
    Set whether to connect to the server directly upon power-up
    1/0 0: Do not start connection upon power-up, 1: Start connection with configured parameters upon power-up
//Example
AT+MQAUTO=1
+MQAUTO=OK

AT+MQRESETCFG

  • Command Description: Restore factory settings related to MQTT
//Example
AT+MQRESETCFG
+MQRESETCFG=OK

AT+MQPUBLISH=Topic**,Message,**QoS

  • Command Description: Publish MQTT message
    Topic (text), the topic name of the message to be published
    Message (text), the message to be published, the maximum length allowed for this parameter is 1000
    QoS QOS, must be 0, 1, 2, this parameter can be omitted, in which case QOS is 0

AT+BAUD=Baud Rate

  • Command Description: Set the serial port baud rate
    Baud Rate Baud rate can only be one of the following values: /4800/9600/19200/34800/115200/230400
//Example
AT+BAUD=115200
+BAUD=OK

AT+SAVE

  • Command Description: Save parameters, After configuring MQTT parameters, you need to execute the SAVE command and perform a RESET soft reset for the configuration to take effect
//Example
AT+SAVE
+SAVE=OK

AT+RESET

  • Command Description: Perform a soft reset on the module, After configuring MQTT parameters, you need to execute the SAVE command and perform a RESET soft reset for the configuration to take effect
//Example
AT+RESET
+RESET=OK

Query AT Commands

AT

  • Command Description: Test communication with the module, response: AT
//Example
AT
AT

AT+MQSUBSCRIBE=Topic Number**?**

  • Command Description: Query the subscribed topic, response: +MQSUBSCRIBE=OK:Topic Number, Enable/Disable, Topic Name, QoS Level
    Topic Number can only be one of 1~4
    Enable/Disable 1: Current subscription is enabled, 0: Current subscription is invalid
    Topic Name QoS Level can only be one of 0, 1, 2 representing MQTT QoS levels QOS0, QOS1, QOS2
//Example
AT+MQSUBSCRIBE=1?
+MQSUBSCRIBE=OK:1,1,"/topic",0

AT+MQAUTO?

  • Command Description: Query whether to start connection directly upon power-up, response: +MQAUTO=OK:Enable/Disable 0: Do not start connection upon power-up, 1: Start connection with configured parameters upon power-up
//Example
AT+MQAUTO?
+MQAUTO=OK:1

AT+NETMAC?

  • Command Description: Query the current MAC address of the module, response: +NETMAC=OK:MAC Address Format: XX-XX-XX-XX-XX-XX
//Example
AT+NETMAC?
+NETMAC=OK:12-34-56-78-90-AB

AT+NETSTATICIP?

  • Command Description: Query the static IP settings of the module, response: +NETSTATICIP=OK:Static IP Address, Subnet Mask, Gateway
//Example
AT+NETSTATICIP?
+NETSTATICIP=OK:"192.168.1.2","255.255.255.0","192.168.1.1"

AT+NETDHCPEN?

  • Command Description: Query whether DHCP function is enabled/disabled, response: +NETDHCPEN=OK:Enable/Disable 1: DHCP function enabled, 0: DHCP function disabled
//Example
AT+NETDHCPEN?
+NETDHCPEN=OK:1

AT+MQCLIENTID?

  • Command Description: Query the MQTT client name, response: +MQCLIENTID=OK:Client IP
//Example
AT+MQCLIENTID?
+MQCLIENTID=OK:"clientID" 

AT+MQSERVER?

  • Command Description: Query the MQTT server address and port number, response: +MQSERVER=OK:Server Address, Server Port
//Example
AT+MQSERVER?
+MQSERVER=OK:"192.168.1.55",1883

AT+MQUSERPWD?

  • Command Description: Query the set MQTT server username and password, response: +MQUSERPWD=OK:Username, Password
//Example
AT+MQUSERPWD?
+MQUSERPWD=OK:"USER","123456" 

AT+MQKEEP?

  • Command Description: Query the keep-alive interval for connecting to the MQTT server, response: +MQKEEP=OK:Keep Alive Interval
//Example
AT+MQKEEP?
+MQKEEP=OK:60

AT+BAUD?

  • Command Description: Query the serial port baud rate, response: +BAUD=OK:Baud Rate Default baud rate is 9600
//Example
AT+BAUD?
+BAUD=OK:9600

AT+VERSION?

  • Command Description: Query the current firmware version, response: +VERSION=OK:Current Firmware Version
//Example
AT+VERSION?
+VERSION=OK:1.0

AT+MQSTATUS?

  • Command Description: Query MQTT connection status/connection disconnected
    Response: +MQSTATUS=OK:Connection Status
//Example
AT+MQSTATUS?
+MQSTATUS=OK:1

AT+NETIP?

  • Command Description: Query the current actual IP address of the module
    Response: +NETIP=OK:IP Address, Subnet Mask, Gateway, DNS Server Address
//Example
AT+NETIP?
+NETIP=OK:"192.168.2.121","255.255.255.0","192.168.2.1","192.168.2.1"

Active AT Commands


//Network not connected
+NETUNCONNECT

//MQTT server not connected
+MQUNCONNECT
 
//Connected to MQTT server successfully
+MQCONNECT

//Received topic message
+MQRECV:**Topic**,**Length**,**Message**

Error Codes Returned When Commands Fail


//Parameter content error
ERROR:Error Param

//Parameter count does not meet requirements
ERROR:Error Param Num

//Parameter length is too long, each parameter field must be less than 128 bytes (maximum message length is 1000 bytes) 
ERROR:Parma is too long

//Failed to connect to the network
ERROR:Unconnected

//MQTT server communication error
ERROR:MQTT Connect Fail

//Server did not respond when publishing message (Qos1 and Qos2) 
ERROR:MQTT Publish Fail
 

Video