EzData2 currently provides two connection methods: MQTT and WebSocket, which can be used by devices to implement data interaction. Before device access, the hardware device MAC address must be used to call the registration interface to obtain a Device Token. After completing registration and successfully obtaining the Device Token, visit my.m5stack.com to log in to your personal account, click Add Group, and select the Token option. Copy and paste the Device Token to create it, completing the binding between the Device Token and the account. The Device Token of a single device is equivalent to one dataset Group. The device side can refer to the communication protocol below; after logging in and verification based on the Device Token, it can perform create, read, update, and delete operations on data fields.
| Code | Type | Description |
|---|---|---|
| 100 | Data Operation | Device adds data |
| 101 | Data Operation | Device modifies data |
| 102 | Data Operation | Device deletes data |
| 103 | Data Query | Device queries data list |
| 104 | Data Query | Device queries data details |
| 105 | File Upload | Device uploads file (notification) |
| 106 | User Operation | User scans QR code |
| 107 | User Operation | User modifies data |
| 108 | User Operation | User deletes data |
| 109 | User Operation | User adds data |
| 500 | Error | Device request error |
Request Interface:
https://ezdata2.m5stack.com/api/v2/device/registerMacPOSTdeviceToken.Request Parameters:
| Parameter | Type | Description |
|---|---|---|
| deviceType | string | Refer to the Product name field in Board Definitions |
| mac | string | Device MAC address, without ":" separators, case-insensitive |
{
"deviceType": "basic",
"mac": "AABBCCDDEEFF"
} Response Parameters:
| Parameter | Type | Description |
|---|---|---|
| code | int | Status code (0 indicates success) |
| data | string | Returned deviceToken |
| msg | string | Response message |
{
"code": 0,
"data": "4fbb52fb5b6243e083377f45d216820f",
"msg": "success"
} Request Interface:
https://ezdata2.m5stack.com/api/v2/device/uploadDeviceFilePOST (multipart/form-data)cmd: 105 via WebSocket/MQTT.Request Parameters:
| Parameter | Type | Description |
|---|---|---|
| deviceToken | string | Device token |
| file | file | Uploaded file |
Response Parameters:
| Parameter | Type | Description |
|---|---|---|
| code | int | Status code (200 indicates success) |
Request Interface:
wss://ezdata2.m5stack.com/wsWebSocketRequest Interface:
Request Parameters:
| Parameter | Type | Description |
|---|---|---|
| deviceToken | string | Device token |
{
"deviceToken": "4fbb52fb5b6243e083377f45d216820f"
} Response Parameters:
| Parameter | Type | Description |
|---|---|---|
| - | string | Login success message |
device Login successful Request Interface:
Request Parameters:
| Parameter | Type | Description |
|---|---|---|
| deviceToken | string | Device token |
| body | string | Heartbeat signal (fixed value: "ping") |
{
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"body": "ping"
} Response Parameters:
| Parameter | Type | Description |
|---|---|---|
| - | string | Heartbeat response |
pong Request Interface:
uiflow2.m5stack.com1883MQTT 3.1.1Connection Parameters:
| Parameter | Type | Description |
|---|---|---|
| Name | string | ez{mac}ez |
| ClientId | string | ez{mac}ez |
| Username | string | {deviceToken} (Device Token) |
| Password | string | No password required |
Topics:
| Topic | Direction | Description |
|---|---|---|
$ezdata/{deviceToken}/up | Publish | Uplink data |
$ezdata/{deviceToken}/down | Subscribe | Downlink data |
Notes:
The following content is the message body for WebSocket or MQTT.
Request Interface:
100Request Parameters:
| Parameter | Type | Description |
|---|---|---|
| deviceToken | string | Device token |
| body.name | string | Data field name |
| body.value | string | Data field value |
| body.requestType | int | Request type (fixed value: 100) |
{
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"body": {
"name": "adasd",
"value": "ddsad",
"requestType": 100
}
} Response Parameters:
| Parameter | Type | Description |
|---|---|---|
| cmd | int | Command code (100) |
| code | int | Status code (200 indicates success) |
| body.deviceToken | string | Device token |
| body.name | string | Data field name |
| body.value | string | Data field value |
{
"body": {
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"name": "adasd",
"value": "ddsad"
},
"cmd": 100,
"code": 200
} Request Interface:
101Request Parameters:
| Parameter | Type | Description |
|---|---|---|
| deviceToken | string | Device token |
| body.name | string | Data field name |
| body.value | string | Data field value |
| body.requestType | int | Request type (fixed value: 101) |
{
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"body": {
"name": "adasd",
"value": "ddsad",
"requestType": 101
}
} Response Parameters:
| Parameter | Type | Description |
|---|---|---|
| cmd | int | Command code (101) |
| code | int | Status code (200 indicates success) |
| body.deviceToken | string | Device token |
| body.name | string | Data field name |
| body.value | string | Data field value |
{
"body": {
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"name": "adasd",
"value": "ddsad"
},
"cmd": 101,
"code": 200
} Request Interface:
102Request Parameters:
| Parameter | Type | Description |
|---|---|---|
| deviceToken | string | Device token |
| body.name | string | Data field name |
| body.value | string | Data field value |
| body.requestType | int | Request type (fixed value: 102) |
{
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"body": {
"name": "adasd(3)",
"value": "ddsad",
"requestType": 102
}
} Response Parameters:
| Parameter | Type | Description |
|---|---|---|
| cmd | int | Command code (102) |
| code | int | Status code (200 indicates success) |
| body.deviceToken | string | Device token |
| body.name | string | Data field name |
| body.value | string | Data field value |
{
"body": {
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"name": "adasd(3)",
"value": "ddsad"
},
"cmd": 102,
"code": 200
} Request Interface:
103Request Parameters:
| Parameter | Type | Description |
|---|---|---|
| deviceToken | string | Device token |
| body.requestType | int | Request type (fixed value: 103) |
{
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"body": {
"requestType": 103
}
} Response Parameters:
| Parameter | Type | Description |
|---|---|---|
| cmd | int | Command code (103) |
| code | int | Status code (200 indicates success) |
| body[].id | string | Data ID |
| body[].dataToken | string | Data token |
| body[].name | string | Data field name |
| body[].value | string | Data field value |
| body[].createTime | long | Creation time (milliseconds timestamp) |
| body[].updateTime | long | Update time (milliseconds timestamp) |
{
"body": [
{
"createTime": 1751274100000,
"dataToken": "6a330c4bf0924da3a2b11c833f9c2db1",
"id": "6a330c4bf0924da3a2b11c833f9c2db1",
"name": "adasd",
"updateTime": 1751274100000,
"value": "ddsad"
},
{
"createTime": 1751274119000,
"dataToken": "60ea29ff4df446358b7bf2151939abb4",
"id": "60ea29ff4df446358b7bf2151939abb4",
"name": "adasd(1)",
"updateTime": 1751274119000,
"value": "ddsad"
}
],
"cmd": 103,
"code": 200
} Request Interface:
104Request Parameters:
| Parameter | Type | Description |
|---|---|---|
| deviceToken | string | Device token |
| body.name | string | Data field name |
| body.requestType | int | Request type (fixed value: 104) |
{
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"body": {
"name": "adasd",
"requestType": 104
}
} Response Parameters:
| Parameter | Type | Description |
|---|---|---|
| cmd | int | Command code (104) |
| code | int | Status code (200 indicates success) |
| body.id | string | Data ID |
| body.dataToken | string | Data token |
| body.name | string | Data field name |
| body.value | string | Data field value |
| body.createTime | long | Creation time (milliseconds timestamp) |
| body.updateTime | long | Update time (milliseconds timestamp) |
{
"body": {
"createTime": 1751274100000,
"dataToken": "6a330c4bf0924da3a2b11c833f9c2db1",
"id": "6a330c4bf0924da3a2b11c833f9c2db1",
"name": "adasd",
"updateTime": 1751274100000,
"value": "ddsad"
},
"cmd": 104,
"code": 200
} Description:
This message is triggered by an HTTP upload. The device receives the response through a persistent connection.
Request Interface:
https://ezdata2.m5stack.com/api/v2/device/uploadDeviceFile105Response Parameters (WebSocket/MQTT):
| Parameter | Type | Description |
|---|---|---|
| cmd | int | Command code (105) |
| code | int | Status code (200 indicates success) |
| body.deviceToken | string | Device token |
| body.name | string | File field name |
| body.value | string | File URL |
{
"body": {
"deviceToken": "4fbb52fb5b6243e083377f45d216820f",
"name": "deviceFile",
"value": "https://ezdata2-oss-dev.m5stack.com/37a6259cc0c1dae299a7866489dff0bd/deviceFile/deviceFile.jpg"
},
"cmd": 105,
"code": 200
}