Skip to content

Serial Protocol Document

1. UART communication parameters

  • Baud rate: 115200/9600

  • Data bits: 8

  • Parity: none

  • Stop bits: 1

  • Flow control: none

2. Frame format

FieldHeaderVersionCommand IDData lengthPayloadChecksum
Bytes2112N1
DescriptionFixed 0x5aa5Protocol versionFrame typePayload length, big-endianPayload contentSum all bytes from header through the last byte before checksum, then modulo 256

Protocol notes:

  • All multi-byte fields in the frame use big-endian order.

  • Synchronous transfer

Synchronous transfer uses the same command for request and response. One side sends a command; the other replies with the same command. Typically used for heartbeats or query commands.

As shown:

image-20230114111248249

  • Asynchronous transfer

Asynchronous transfer: command M is sent, command N is the reply. Typically used for control commands—the module sends a control command; the MCU replies via a status report command.

As shown:

Module sends control command

image-20230114111307382

MCU reports status

image-20230114111342181

  • Version usage

The version field supports extension and compatibility. Module-to-MCU frames use version 0x10; MCU-to-module frames use version 0x20.

3. Payload format

Payload fieldData IDData typeData lengthData content
Bytes1121/2/4/N
DescriptionSequence number of this data fieldType of this fieldLength of data contentHex content, big-endian
  • Data types:
Type valueData typeBytesDescription
0x01Bool1Content is 0x00/0x01
0x02value4Integer data, big-endian
0x03StringNString data transferred as hex
0x04Enum1Enum type, range 0–255
  • Protocol notes:
  1. Payload data content and data IDs are defined in the Thing Model document—different content maps to different data IDs and types. Example: switch, data ID 1, type bool.
  2. Multi-byte fields in this format use big-endian order.
  3. When using string type, the string content is JSON.

4. Command list

4.1 Heartbeat command

  • After power-on, the module sends heartbeats once per second until the MCU replies correctly. After a valid reply, the interval becomes 15 seconds, and the module continues subsequent init commands. If no valid reply is received, it keeps sending once per second.

  • The MCU can use heartbeat presence to judge whether the module is running normally or has reset. If there is no heartbeat, the MCU may reset the module via the hardware reset pin.

  • After a heartbeat connection is established, if the module receives no MCU heartbeat reply for 90 consecutive seconds (6 missed heartbeats), it reboots and waits for MCU heartbeat replies.

  • For a provisioned device, if the module and MCU fail to establish a connection for more than 3 minutes, the cloud marks the device offline.

  • Module send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x100x000x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 10 00 00 00 0f

  • MCU reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x200x000x00010x00: First heartbeat after MCU reboot, sent once only—used by the module to detect MCU reboot during operation 0x01: All other heartbeats return 1Sum all bytes from header through the last byte before checksum, then modulo 256

MCU first reply example: 5a a5 20 00 00 01 00 20

MCU normal reply (after first): 5a a5 20 00 00 01 01 21

4.2 Query product information

Use this command to obtain the product ID and MCU software version.

  • Product ID: PID (product id), generated by the Ubases IoT platform for the selected product; identifies the product type.

  • MCU software version: dotted decimal x.x.x, where x is 0–99. Identifies MCU software version for firmware upgrades.

  • Module send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x100x010x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 10 01 00 00 01

  • MCU reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x200x01NPayload includes product KEY, MCU firmware version, and product flagSum all bytes from header through the last byte before checksum, then modulo 256

Data example:

Product info field description:

FieldDescription
pidProduct KEY / pid obtained on the Ubases IoT platform
verMCU software version
flagProduct flag string configured on the Ubases IoT platform

Send example: 5A A5 20 01 00 2E 7B 22 70 69 64 22 3A 22 50 4B 68 79 51 34 62 49 22 2C 22 76 65 72 22 3A 22 31 2E 30 2E 30 22 2C 22 66 6C 61 67 22 3A 22 5A 4D 58 58 22 7D F8

4.3 Query work mode

Defines how device provisioning is triggered and indicated, as configured by the MCU. The work mode controls how Wi-Fi status is indicated and how the module enters device provisioning mode. This command queries the selected mode.

MCU–module cooperative mode:

The MCU triggers device provisioning through a UART command. The module reports its Wi-Fi status to the MCU over UART, and the MCU provides the corresponding indication.

Module self-handled mode:

Wi-Fi status is indicated by an LED driven from a module GPIO. Device provisioning is triggered through a module GPIO input.

Current module firmware does not support this mode yet; it will be updated later.

  • Module send
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x100x020x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 10 02 00 00 11

  • MCU reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes21120/21
Description0x5aa50x200x020x0000/0x0002 0x0000: MCU–module cooperative mode 0x0002: Module self-handled modeLength 2: Data[0]: Wi-Fi status LED GPIO index Data[1]: Network-setup trigger GPIO indexSum all bytes from header through the last byte before checksum, then modulo 256

MCU–module cooperative: 5a a5 20 02 00 00 21

Module self-handled, LED GPIO1, trigger GPIO5: 5a a5 20 02 00 02 01 05 29

4.4 Report network status

  • Device network status:
Network statusDescriptionValue
Status 1Module in BLE provisioning mode0x00
Status 2Module in AP provisioning mode0x01
Status 3Provisioned but not connected to router0x02
Status 4Provisioned and connected to router0x03
Status 5Device connected to cloud0x04
Status 6Module in low-power mode0x05
Status 7Module in BLE+AP coexistence provisioning mode0x06
  • LED indication in module self-handled mode:

Statuses 1, 2, and 7: blink every 250 ms, then every 1000 ms in a cycle

Status 3: blink every 250 ms

Status 4: blink every 1000 ms

Status 5: solid on

Status 6: solid off

  • When the module detects MCU reboot or reconnect after disconnect, it actively reports Wi-Fi status to the MCU.

  • When Wi-Fi status changes, the module actively reports to the MCU.

  • If work mode is self-handled, the MCU need not implement this protocol.

  • On module reboot, Wi-Fi status is also reported to the MCU.

  • Module send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211211
Description0x5aa50x100x030x0001Wi-Fi work status:
0x00: Status 1
0x01: Status 2
0x02: Status 3
0x03: Status 4
0x04: Status 5
0x05: Status 6
0x06: Status 7
Sum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 10 03 00 01 00 13

  • MCU reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x200x030x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 20 03 00 00 22

4.5 Reset network

When the module receives a reset-network command from the MCU, it clears the existing provisioning data and restarts immediately. After restarting, it completes the initialization command exchange with the MCU and enters device provisioning mode. The user can then provision it with the Ubases IoT App.

  • Send reset-network only after module init command exchange is complete; otherwise it is ignored.

  • After a network reset, the module enters BLE+AP coexistence provisioning mode.

  • If work mode is module self-handled, the MCU need not implement this protocol.

In module self-handled mode, holding the trigger GPIO low for 5 seconds resets Wi-Fi and starts device provisioning.

  • MCU send
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x200x040x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 20 04 00 00 23

  • Module reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x100x040x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 10 04 00 00 13

4.6 Select device provisioning mode

This command is similar to the reset-network command. After receiving it, the module enters the selected device provisioning mode.

  • The MCU may select a device provisioning mode as needed.

  • If work mode is module self-handled, the MCU need not implement this protocol.

  • Send only after module init command exchange is complete; otherwise it is ignored.

  • MCU send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211211
Description0x5aa50x200x050x00010x00: Enter BLE provisioning mode 0x01: Enter AP provisioning modeSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 20 05 00 01 00 25

  • Module reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x100x050x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 10 05 00 00 14

4.7 Control command

  • Control commands apply Thing Model data to control device state.

  • Asynchronous protocol: after a control command, the MCU applies the corresponding Thing Model data; when values change, the MCU must report via the status report command.

  • Module send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes2112N1
Description0x5aa50x100x06Depends on payload types and countPayload groupSum all bytes from header through the last byte before checksum, then modulo 256

Example: Thing Model switch, data ID 1, bool type, set on (value 1).

Send example: 5a a5 10 06 00 05 01 01 00 01 01 1E

4.8 Synchronous status report

  • Synchronous protocol: after the MCU reports, it must wait for the module processing result.

  • The module should reply to every report. Do not report repeatedly before a reply.

  • If the network is poor and the module cannot send successfully, it returns failure after 5 seconds. The MCU must wait more than 5 seconds before reporting again.

  • Report data according to Thing Model data types.

  • A status report may include multiple Thing Model data items.

  • MCU send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211211
Description0x5aa50x200x22Depends on payload types and countPayload groupSum all bytes from header through the last byte before checksum, then modulo 256

Example: Thing Model switch, data ID 1, bool type, set on (value 1).

Send example: 5a a5 20 22 00 05 01 01 00 01 01 4A

  • Module reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211211
Description0x5aa50x100x230x00010x00: Report failed 0x01: Report succeededSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 10 23 00 01 01 34

4.9 Asynchronous status report

  • Payload content follows the Thing Model.

  • Asynchronous protocol. Triggers:

    • After the MCU receives a control command and executes it correctly, report changed status to the module.
    • When the MCU detects Thing Model data changes, report them.
    • After receiving a status query command, report all Thing Model data.
  • A status report may include multiple Thing Model data items.

  • MCU send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211211
Description0x5aa50x200x07Depends on payload types and countPayload groupSum all bytes from header through the last byte before checksum, then modulo 256

Example: Thing Model switch, data ID 1, bool type, set on (value 1).

Send example: 5a a5 20 07 00 05 01 01 00 01 01 2F

Example: Thing Model temperature, data ID 12, value type, 26

​ Thing Model humidity, data ID 13, value type, 73

Send example: 5a a5 20 07 00 0F 0C 02 00 04 00 00 00 1A 0D 02 00 04 00 00 00 49 BD

4.10 Status query

  • Asynchronous protocol used by the module to query all Thing Model data on the MCU. After receiving this command, the MCU must report all Thing Model status.

  • Typical use cases:

    • After first power-on and heartbeat connection, the module queries all Thing Model status.
    • If the module detects MCU reboot or reconnect after disconnect, it queries all Thing Model status.
    • When the cloud requests device status, the module queries all Thing Model status.
  • Module send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x100x080x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 10 08 00 00 17

4.11 Get local time

  • Local time is GMT plus the local timezone (device activation location) and daylight saving time.

  • Succeeds only after the module is connected to the cloud. If offline (not connected to Ubases IoT), the module returns failure.

  • MCU send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x200x1C0x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 20 1C 00 00 3B

  • Module reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211281
Description0x5aa50x100x1C0x0008Data[0]: success flag, 0 fail, 1 success Data[1]: year, 0x00 = 2000 Data[2]: month, 1–12 Data[3]: day, 1–31 Data[4]: hour, 0–23 Data[5]: minute, 0–59 Data[6]: second, 0–59 Data[7]: weekday, 1–7, 1 = MondaySum all bytes from header through the last byte before checksum, then modulo 256

Example: For devices in China, local time is Beijing time (UTC+8).

Send example: 5a a5 10 23 00 01 01 34

4.12 Get current network status

  • Device network status:
Network statusDescriptionValue
Status 1Module in BLE provisioning mode0x00
Status 2Module in AP provisioning mode0x01
Status 3Provisioned but not connected to router0x02
Status 4Provisioned and connected to router0x03
Status 5Device connected to cloud0x04
Status 6Module in low-power mode0x05
Status 7Module in BLE+AP coexistence provisioning mode0x06
  • Returns the same network status as the report-network-status command.

  • Initiated by the MCU to query module network status.

  • MCU send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x200x2B0x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 20 2B 00 00 4A

  • Module reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211211
Description0x5aa50x100x2B0x0001Wi-Fi work status: 0x00: Status 1 0x01: Status 2 0x02: Status 3 0x03: Status 4 0x04: Status 5 0x05: Status 6 0x06: Status 7Sum all bytes from header through the last byte before checksum, then modulo 256

Example: Module connected to router and cloud.

Send example: 5a a5 10 2B 00 01 04 3F

4.13 Get module MAC

  • MCU sends this command to obtain the module MAC address

  • MCU send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x200x2D0x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 20 2D 00 00 4C

  • Module reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211211
Description0x5aa50x100x2D0x0007Data[0]: MAC obtain result 0x00: success, following 6 MAC bytes valid 0x01: failure, following 6 MAC bytes invalid Data[1]–Data[6]: MAC addressSum all bytes from header through the last byte before checksum, then modulo 256

Example: Module MAC is 123456abcdef

Send example: 5a a5 10 2D 00 07 00 12 34 56 ab cd ef 46

4.14 Get Wi-Fi signal strength

  • Obtain RSSI of the router currently connected by the module

  • Wait until the module is connected to a router; otherwise the module returns failure.

  • MCU send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211201
Description0x5aa50x200x240x0000NoneSum all bytes from header through the last byte before checksum, then modulo 256

Send example: 5a a5 20 24 00 00 43

  • Module reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211211
Description0x5aa50x100x240x00010x00: Obtain failed Less than 0: signal strength e.g. (-20 dB)Sum all bytes from header through the last byte before checksum, then modulo 256

Example: Current router RSSI is -20

Send example: 5a a5 10 24 00 01 EC 20

4.15 Wi-Fi functional test (connect specified router)

  • When the MCU sends a Wi-Fi functional test command, the module uses the provided router credentials to connect.

  • Judge connection via report-network-status. If the MCU receives a failure reply, or no router-connected status within 15 seconds, treat the test as failed.

  • To repeat the test while the module is connecting, the command is ignored. Reset network first, then send the Wi-Fi functional test again.

  • Valid only after heartbeat connection and product info query (module init complete).

  • SSID max 32 bytes; password max 64 bytes.

  • MCU send

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes2112N1
Description0x5aa50x200x2CN{“ssid”:“xxx”, “password”:“xxxxxxxx”} ssid: router name password: router passwordSum all bytes from header through the last byte before checksum, then modulo 256

Example: {"ssid":"xxx", "password":"12345678"}

Send example: 5a a5 20 2C 00 24 7b 22 73 73 69 64 22 3a 22 78 78 78 22 2c 22 70 61 73 73 77 6f 72 64 22 3a 22 31 32 33 34 35 36 37 38 22 7d 49

  • Module reply
FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes211211
Description0x5aa50x100x2C0x00010x00: Failed to receive router info. Check the outbound router JSON completeness. 0x01: Router info received. Use report-network-status to judge Wi-Fi connection result.Sum all bytes from header through the last byte before checksum, then modulo 256

Example: Module successfully received router info

Send example: 5a a5 10 2C 00 01 01 3D

4.16 MCU OTA request

FieldHeaderVersionCommand IDData lengthDataChecksum
Bytes2112N1
Description0x5aa50x100x0ANPayload includes firmware type, firmware version, and firmware keySum all bytes from header through the last byte before checksum, then modulo 256

Data example:

json
{
  "otatype": "module_extand_all",
  "ver": "1.0.0",
  "key": "current_upgrade_firmware_key",
  "md5": "md5_of_cloud_ota_payload"
}

Field description:

FieldDescription
otatypeOTA type: module_mcu_all = MCU OTA; module_extand_all = extension firmware OTA
verSoftware OTA version
keyCurrent upgrade firmware key
md5MD5 of cloud-delivered OTA data

5. Supported AT commands

AT

AT
DescriptionTest whether the AT framework works
ResponseOK — AT test succeeded
ERR — AT test failed
ExampleSend: AT
Response: OK

AT+KEY

AT+KEY=DeviceID,Username,Password
DescriptionWrite device credentials to module flash via an AT command
ResponseOK — device credentials written successfully
ERR — failed to write device credentials
ExampleSend: AT+KEY=HeeaUopCefFlrg,5VAVPl,HsasNdFZzTP10w
Response: OK

AT+RESTORE

AT+RESTORE
DescriptionRestore factory settings; the module restarts and enters device provisioning mode
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+RESTORE
Response: OK

AT+GDLT

AT+GDLT
DescriptionGet module boot timestamp. After power-on and successful online, the module records that online time in flash (first successful online after this boot). Offline/re-online due to network does not update it. After a new power cycle and successful online, the timestamp is updated; if not online after reboot, it is not updated.
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+GDLT
Response:
image-20230114114816297

AT+RST

AT+RST
DescriptionReset and reboot the module
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+RST
Response: OK

AT+GMR

AT+GMR
DescriptionGet module firmware information
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+GMR
Response:
image-20230114114850079

AT+UARTCFG

AT+UARTCFG=baudrate
DescriptionSet uart0 baud rate. Takes effect after module reset.
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+UARTCFG=115200
Response: OK

AT+CIPSTAMAC

AT+CIPSTAMAC?
DescriptionGet module MAC address
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+CIPSTAMAC?
Response:
image-20230114115109633

AT+AILOG

AT+AILOG=0/1/2/3/4
DescriptionSet AiLink protocol-layer log level. Lower level → fewer logs, higher efficiency; higher level → more logs, lower efficiency.
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+AILOG=4
Response: OK

AT+AILOG

AT+AILOG=0/1/2/3/4
DescriptionSet AiLink protocol-layer log level. Lower level → fewer logs, higher efficiency; higher level → more logs, lower efficiency.
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+AILOG=4
Response: OK

AT+IOTLOG

AT+IOTLOG=0/1/2/3/4
DescriptionSet IoT application-layer log level. Lower level → fewer logs, higher efficiency; higher level → more logs, lower efficiency.
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+IOTLOG=4
Response: OK

AT+MCULOG

AT+MCULOG=0/1/2/3/4
DescriptionSet log level for module MCU serial protocol handling. Lower level → fewer logs, higher efficiency; higher level → more logs, lower efficiency.
ResponseOK — AT succeeded
ERR — AT failed
ExampleSend: AT+MCULOG=4
Response: OK

6. Appendix

  • Module initialization flow

    • After boot, the module sends heartbeats every second, waiting for MCU replies to establish a connection.

    • Only after connecting to the MCU and completing initialization can the module respond to device provisioning, data exchange, and extension features. Initialization includes:

    • Establish heartbeat connection

    • Obtain product information

    • Configure module work mode

    • Report module network status (cooperative MCU–module mode)

    • Status query

    • Post-boot initialization flowchart:

      image-20230114115622686

    • Download the serial protocol document here

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