MCU Access
Last updated
Last updated
This article is mainly an overview of the MCU development process of Tuya Gateway general solution.
The development process mainly includes: product creation-hardware debugging-software development-functional debugging.
Log in to the IoT Workbench and create a product. Select the product category according to the actual needs, and select Wi-Fi for the networking method. After the product is created, you can select the functions, panels, modules, and firmware according to the actual needs of the product and then download it to the MCU development kit.
The specific steps to create a product can refer to: Product Creation-IoT Platform Operation
Hardware selection
When creating a product selection module, the platform will recommend some common module models. At present, the gateway MCU access solution can only be provided by Wi-Fi gateway module-WRG1.
After selecting the module and firmware, you can purchase module samples online.
The hardware engineer can enter the drawing board stage, and the related materials for hardware development can be viewed in the document center:
Data manual link: Wi-Fi Gateway Module-WRG1 Datasheet
Module minimum schematic: Wi-Fi Gateway Module-WRG1 minimal system schematic diagram PCB data: Common module package library
Distribution Network Verification
After getting the module, users do n’t need to worry about writing code first. It is recommended to use the module debugging assistant (MCU simulation mode) provided by Tuya to connect with the WRG1 module first. When verifying the module, users can be familiar with The protocol interaction process will greatly improve the efficiency of development and debugging later.
Tuya module debugging assistant-MCU simulation mode. The assistant will simulate the MCU to automatically reply the module's correct protocol data. After the module is networked with a mobile phone, the DP data can be reported and issued. The following briefly introduces the main steps of the assistant and module distribution network operation. Before using it, you need to know the instructions of Tuya Module Debugging Assistant in advance. Users who use the assistant for the first time can read in advance: Module Debugging Assistant Instruction
step1. According to the minimum system schematic diagram, set up the module peripheral circuit, and simple test can directly fly the wire.
step2. Set device capabilities,open the Tuya module debugging assistant in the development kit and import the debugging file. Protocol selection Wi-Fi gateway protocol, MCU simulation mode.
step3. Connect the serial port of the module to the computer through the USB to TTL tool. The assistant selects the corresponding serial port and baud rate. Open the serial port and click Start. You will see that the module and the host computer automatically perform the initialization process protocol interaction.
Note: If no data is sent after power on, please check if the peripheral circuit of the module is correct.
step4. Click Reset Module, the module enters the network distribution mode. The module supports two modes of network configuration: EZ and AP mode (the difference between EZ mode and AP mode). The reset button will switch the network configuration mode. According to the status prompt, the App performs the corresponding network configuration operation. For the network configuration operation, you can read the instruction of the App. Attach a demo video of the network distribution in two modes: Wi-Fi module network distribution demonstration video.
In the process of hardware debugging, the user saw that the module and the MCU have a series of serial protocol protocol interaction data. For the understanding of these data, please refer to the protocol document in the development kit.
The agreement is mainly divided into two parts: the basic agreement and the functional agreement. The basic protocol has nothing to do with the product. It is a common protocol of the module, including module initialization instructions and some extended function instructions. The function protocol part is mainly based on the command word of the report of the basic protocol, and has explained the DP data content format in detail. The complete content of the basic protocol, the document center is kept updated in real time, you can click the link to view: Tuya Cloud Gateway Access Protocol
There are two ways for MCU to interface with Tuya module: transplant the MCU SDK or connect the protocol by yourself.
Self-docking agreement
When MCU resources are limited or the MCU SDK is not suitable for porting, customers can choose to connect the serial port protocol by themselves. The detailed explanation of serial port protocol can refer to: Tuya Cloud Gateway Access Protocol Analysis
Porting MCU SDK
If the MCU resources are sufficient, it is generally recommended that users directly port the MCU SDK for efficient and convenient development. The MCU SDK in the development kit is a C-based protocol application code provided by Tuya, which can be directly added to the MCU project. The MCU SDK requires MCU hardware resources: 4K bytes of Flash; RAM is related to the length of the DP point data, about 100 bytes (if OTA function is required, it must be greater than 260 bytes); the number of function nesting levels is 9 levels. If users with insufficient resources can connect the protocol by themselves, the functions in the SDK package can still be used as a reference.
MCU SDK porting tutorial, please refer to: Tuya Wi-Fi Gateway MCU_SDK Instructions
After porting the MCU SDK code development, you can use the Tuya module debugging assistant-module simulation mode to verify the correctness of the MCU code. The usage method is similar to the MCU simulation mode. In the simulation module mode, the assistant will automatically send the initialization data stream to verify that the MCU response is correct and give corresponding prompts for the incorrect data. After the initial interaction is passed, you can manually click to test other extended functions.
Note: Tuya module debugging assistant module simulation mode, without networking function, only used to verify the correctness of MCU serial protocol transmission and reception. After the test is completed, the MCU can be connected to the actual module and network.
Debugging common tool links:
Background log query entry: IoT Workbench-Operation Center. You can query related device background log data based on the device ID.
Tuya Online Support Portal: Tuya provides online support services. If the problem documents cannot be answered, you can Ask questions directly online, and the professional and technical team will answer your questions.
Version Record:
Version
Revision description
Revised by
Revision date
Remarks
1.0.0
Document creation
Kang Liu
20181018
Document creation
1.0.1
Modify
Kang Liu
20181025
Modify version 3.3 sub-devices protocol added,add the time setting of heartbeat
1.0.2
Modify
Shanshan Zhou
20181027
1.Add command to query product information 2.Add command to query MCU working mode 3.Report command of device network status 4.Add command of resetting WIFI 5.Add command of resetting WIFI-select configuration mode 6.Adjust the command code of each command
1.0.3
Modify
Shanshan Zhou
20181030
1.Delete the pid information in the product 2.Limit the port port in 3.2 to A-D
1.0.4
Modify
Kang Liu
20181107
1. Add sub-device operation of adding and deleting group under local group 2.Modify the query for product information,add device return ability (Whether local groups or local scenes is supported)
1.0.5
Modify
Kang Liu
20181107
1.Add return result set of group operation
1.0.6
Modify
Shanshan Zhou
20190111
1.Add time to read (Green time and local time) 2.Add the function of adding sub-devices in bulk 3.Add the return result of adding sub-devices in bulk 4. sub_id'0000'represent Gateway itself 5. Heartbeat interval time is at least 30S.
1.0.7
Modify
Shanshan Zhou
20190118
1.Add group control frame 2. Return 3.19 to the result of adding devices in bulk,change command word to 0x13. 3 Add group control command 0x014 4.Add production test command 0x15
1.0.8
Modify
Shanshan Zhou
20190319
1.The response after adding sub-devices.
1.0.9
Modify
Shanshan Zhou
20190413
1.The bit3 adding cap identify internal sigmesh。 2.Add the frame of pulling network information 3.Add the frame of applying for network node 4.Add the frame of sigmesh sub-device 5.Add the frame which allows or disable to add sub-devices locally 6.Add the frame of getting module memory
1.1.0
Modify
Shanshan Zhou
20190520
1.The bit4 adding cap,if MCU ota function is available 2.Add remote service instruction 3.Add the frame of getting wifi status 4.Add the frame of deleting the sub-devices locally 5.Add the frame of querying sub-device list 6.Add the frame of restoring factory setting locally 7.Add the command of reporting removal status 8.Add the command of sig mesh getting the source node
1.1.1
Modify
Shanshan Zhou
20190529
1.Add group control command with sub_id information 2.Add the command of getting dev_key 3.The instruction of restoring the factory setting locally 4.Add the group control with sub_id in product information 5.Add dev_key when deleting the sub-devices of sigmesh gateway
1.1.2
Modify
Shanshan Zhou
20190713
1.Add serial port distribution network command (integrated) 2.Add serial transparent transmission network command (split) 3.Add the command of querying dp status 4.Add the command of clearing the sub-devices information by sigmesh 5.Add the command of sigmesh getting local ID 6.Add the command of sigmesh updating group address 7.The serial port upgrade subpacket is compatible with 128byte
1.1.3
Modify
Shanshan Zhou
20191202
1.Add tp code on product information 2.Add dual link extension protocol, add sub-device synchronization 3.Update sub-devices online / offline status 4.Add cancel heartbeat mechanism of the cap code added in product information 5.Add the command of getting Mac 6.Add record real-time reporting interface 7.Change heartbeat minimum interval from 30s to 60s
1.1.4
Modify
Xiangjuan Meng
20191212
1.Add tp code of product information 2. Change heartbeat interval from 60s to 180s
Baud rate:115200
Data bit:8
Parity: None
Stop bit:1
Data flow control: none
MCU:User will control the chip through control board, connected with Tuya module through serial port
Field
Length(byte)
Description
Header
2
Fixed as 0x55aa
Version
1
Used for update and extension
Command word
1
Specific frame type
Data length
2
Large endian
Data
N
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Description:
product ID:Corresponding to the PID on Tuya IoT Platform, generated by Tuya IoT developer platform, used to record product related information in the cloud
The product information is comprised by product ID and MCU version
MCU version number format definition: in dotted decimal format,”x.x.x”(0<=x<=99),x is decimal.
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00/ 0x01 0x00:not supported to get pid; 0x01:supported to get pid;
Command word
1
0x01
Data length
2
0x0000
Data
0
none
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 01 0000 00
MCU return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00/0x01
Command word
1
0x01
Data length
2
N
Data
N
Version is 0x00:{“v”:”1.0.0”,”m”:1,”cap”:0, “tp”:4} Version is 0x01: {“v”:”1.0.0”,”m”:1,”cap”:0, “tp”:4, “p”:”mhnmpqzf7ntzmmdb”}
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:{“v”:”1.0.0”,”m”:1,”cap”:0, “tp”:4,“p”:”mhnmpqzf7ntzmmdb”}
v means MCU version is 1.0.0
m represents pairing methods: 0 default pairing mode、1 Low power consumption mode、2 special pairing mode
cap represent device ability: bit0(local group),bit1(local scene) ,bit2(gateway have function dp), bit3(is sigmesh), bit4(support MCU upgrade), bit5(group control command with sub_id) , bit6 (Bluetooth serial port paring mode,otherwise just AP mode is available)(the bit unused is 0)
Case 1: device support the local group control, cap is 1:
Case 2:device support local group control and local scene,cap is 3;
Case 3:device does not support local group control and local scene, but the gateway has function dp, cap is 4
Case 4:device is sigmesh device, with local group,it has to issue sub_id when control the group(issue 0x22 command), cap is 41(0x29)
tp represents the sub-devices type integrated: 1:Zigbee 2:Bluetooth 3:Smart IR 4:Others if tp is not transmitted, it will be others defaultly; Pls note:The type of sub-devices: zigbee/Bluetooth/Smart IR are applied for Tuya self-developed products, if it the products developed by the customers, the sub-devices category will be others. p represent gateway product pid,pid is mhnmpqzf7ntzmmdb
Description:
The working mode of the module is mainly for how to indicate the working status of the Wi-Fi module and how to reset the Wi-Fi module. There are two main cases:
MCU cooperates with the module, that is, the module notifies the MCU through the serial port, the current working status is supported by the MCU, the Wi-Fi will be reset through the serial port when the MCU detect the reset request.
Module self-processing: The working status of the WIFI module drives the LED status display through the WIFI GPIO pin; WIFI reset is processed by detecting the GPIO input requirements
The method of resetting the Wi-Fi module through module self-processing:WIFI will be triggered when detecting that the low level of GPIO entrance last for more than 5s. Reset: The GPIO pins used by the indicators and buttons are configured by the following commands.
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x02
Data length
2
0x0000
Data
0
none
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 02 0000 01
MCU return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x02
Data length
2
0x0000/0x0004 0x0000:Indicating the module to work in the 'MCU and module co-processing' mode, the MCU needs to implement the functions mentioned in the "Description" above 0x0004:Instructing the module to work in "module self-processing" mode.
Data
0/2
Data length is 4: Data[0]:WIFI indicator port, Data[1]: WIFI indicator pin, Datat[2]:reset button port, Datat[3]:reset button pin, Port range:0-3 represent A-D Pin range:0-7
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 02 0000 04(MCU work with the module)
0x55aa 00 02 0004 0103 0102 0C(module self-processing,indicator 0x0103:PB_3,reset button 0x0102:PB_2)
Device connection status
Description
Status value
Status 1
smart configuration status
0x00
Status 2
AP configuration status
0x01
Status 3
WIFI is configured but not connected to the router
0x02
Status 4
WIFI is configured and connected to the router
0x03
Status 5
Connected to the router and the cloud
0x04
Status 6
WIFI device is in low power mode
0x05
Description:
Device connection status:1 smart configuration status 2 AP configuration status 3 WIFI is configured but not connected to the router 4 WIFI is configured and connected to the router 5 Device is connected to the router and the cloud. The LED indicator under 'module self-processing' working mode is:1 Flashing at intervals of 250ms;2 Flashing at intervals of 1500ms;3 Long dark status;4 or 5 Long light status
When the module detects that the MCU restarts or the MCU is disconnected and then goes online, it will sends the WIFI status to the MCU actively.
When the WIFI status of the module changes, it will actively send the WIFI status to the MCU
If the module working mode is set to 'module self-processing', the MCU does not need to implement this protocol
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x03
Data length
2
0x0001
Data
1
Indicating Wi-Fi working status: 0x00:Status 1 0x01:Status 2 0x02:Status 3 0x03:Status 4 0x04:Status 5
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 03 0001 00 03
MCU return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x03
Data length
2
0x0000
Data
0
none
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 03 0000 02
Description:
If the module working mode is set to 'module self-processing', the MCU does not need to implement this protocol
MCU send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x04
Data length
2
0x0000
Data
0
none
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 04 0000 03
Module return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x04
Data length
2
0x0000
Data
0
none
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 04 0000 03
Description:
Compared with 'Reset WIFI' in section 3.5, this section provides the MCU to selectively choose the configuration method after resetting the WIFI depend on different conditions.
MCU solution users can selectively implement this protocol depend on their requirements.
If the module working mode is set to 'module self-processing', the MCU does not need to implement this protocol
MCU send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x05
Data length
2
0x0001
Data
1
0x00:get into smart configuration mode 0x01:get into AP configuration mode
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 05 0001 00 05,get into smart configuration mode
Module return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x05
Data length
2
0x0000
Data
0
none
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Foe example:0x55aa 00 05 0000 04
Description:
The App sends a network access permission to the Gateway, and allows the sub-device to access the network within a certain period of time.
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x06
Data length
2
0x0000
Data
0
none
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
MCU return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x06
Data length
2
0x0000
Data
0
none
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Description:
The App sends a command to close the network to the Gateway
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x07
Data length
2
0x0000
Data
0
None
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
MCU return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x07
Data length
2
0x0000
Data
0
None
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Description:
MCU send the sub-device network access to Wi-Fi
pk_type is alternate field, can be ignored, the default value is 1
MCU send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x08
Data length
2
N
Data
{ 'pk_type':xx, 'sub_id':'xxxx', 'pid':'xxxx', 'ver':'x.x.x' }
User product classification pk_type: The user-defined product type is optional to be filled Sub-device identification sub_id: Generally it is MAC address or chip id, it has to be Uniqueness. '0000' is not allowed.'0000' represent the gateway itself. Product identification pid: Product ID(ProductID),when creating the product generated by the Tuya cloud version:such as 1.0.0
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Module return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x08
Data length
2
0x0001
Data
1
0x00 accept the request 0x01 refuse the request (Whether the sub-device is connected to the network successfully, see 3.19)
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Description:
The App sends a command to close the network to the Gateway.
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x09
Data Length
2
N
Data
{ “sub_id”:”xxxx”, “devkey”:”xxx” }
the sub-device id to be deleted Devkey: used to remove sigmesh sub-device
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
MCU return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x09
Data length
2
0x0000
Data
0
None
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Description:
WIFI module schedule(1-3 mins)detect the online/offline status of sub-device. When adding sub-devices in batches,heartbeat detection will stop.
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x0A
Data length
2
N
Data
{ “sub_id”:“xxxx” }
sub_id:sub-device ID
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
MCU return:
| Field | Length(byte) | Description |
| -------- | --------------------------------- | ------------------------------------------------------------ | | Header | 2 | 0x55aa | | Version | 1 | 0x00 | | Command word | 1 | 0x0A | | Data length | 2 | N | | Data | { “sub_id”:“xxxx”, “hb_time”:xx } | sub_id:sub-device ID Heartbeat intervalhb_time(Unit: second)for example:60 means 60 seconds,0 does not support heartbeat,always online。If the heartbeat interval is less than 180s, it will be processed for 180s (except 0) | | Checksum | 1 | The result obtained by summing bytes from the beginning of the frame to the remainder of 256 |
Description:
The online device needs to responde to the heartbeat. If it does not reply for two consecutive heartbeat cycles, the device is considered offline.
Description:
Used to synchronize the status of sub-devices.
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x0B
Data length
2
N
Data
0
None
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
MCU return:(3.13 status report)
Description:
Control command issue.
datapoint: command status unit:
datapoint: the command / status data unit is as follows:
Data segment
length(byte)
Description
dpid
1
datapoint Serial number
type
1
corresponding to the specific data type of a datapoint on IoT platform, it is identified by the following 'representation value'
type
Representation value
length (bytes)
description
raw
0x00
N
corresponding to raw datapoint(Module transparent transmission)
bool
0x01
1
value range:0x00/0x01
value
0x02
4
corresponding to int type,large endian representation
string
0x03
N
corresponding to a specific string
enum
0x04
1
Enum,range from 0-255
bitmap
0x05
1/2/4
when the length is more than 1 byte,using large endian
len
2
number of bytes corresponding to length (big endian)
value
1/2/4/N
hex represent,big endian transmission for larger than 1 byte
datapoint command/ except for the 'raw' type, other types of state data units belong to the 'obj' type datapoint
'command issue' contains several datapoint 'command data unit'
'command issue' is asynchronous processing protocol,corresponding to MCU datapoint 'status report'
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x0C
Data length
2
N
Data
id_len(1byte) + sub_id(nbyte)+ datapoint
id_len: sub-device id length sub_id: sub-device id, when sub_id is '0000',means that this command is to the gateway itself's dp (main device). datapoint: Control command data point collection
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Description:
The sub-device actively pushes the instruction after the command is issued and replied or the status changes.
MCU send:
| Field | Length(byte) | Description |
| -------- | ---------------------------------------- | ------------------------------------------------------------ | | Header | 2 | 0x55aa | | Version | 1 | 0x00 | | Command word | 1 | 0x0D | | Data length | 2 | N | | Data | id_len(1byte) + sub_id(nbyte)+ datapoint | id_len: sub-device id length sub_id: sub-device id. when the sub_id is '0000',this command is to the gateway itself's dp (main device) . datapoint: Control command data point collection | | Checksum | 1 | The result obtained by summing bytes from the beginning of the frame to the remainder of 256 |
Description:Local group sub-devices are added, support local group-created devices. Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x0E
Data length
2
N
Data
{ “gid”:”01”, “cids”:[”12”,”34”,”56”] }
gid represents group id cids:The set of sub-devices to join the group. For example:sub-device ”12”,”34”,”56” will join in to group ”01”
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
MCU return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x0E
Data length
2
N
Data
{ “gid”:”12”, “cids”:[”12”,”34”,”56”], “rets”:[0,0,0] }
gid represents group id cids:The collection of sub-devices to join the group,the return result combined with rets: 0:add successfully 1:group limit exceeded 2:sub-device times out 3:the value exceed the limit 4:file writing error 5:other errors
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Description:The local group sub-device is deleted.
Module send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x0F
Data length
2
N
Data
{ 'gid':'01', 'cids':['12'] }
gid represents group id cids:The collection of sub-devices to be deleted. For example:Sub-device '12' need to be deleted from group '01'
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
MCU return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x0F
Data length
2
N
Data
{ “gid”:”01”, “cids”:[”12”], “rets”:[0] }
gid represents group id cids:The collection of sub-devices to join the group the return results combined with rets: 0:add successfully 1:group limit exceeded 2:sub-device times out 3:the value exceed the limit 4:file writing error 5:other errors
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
MCU send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x10
Data length
2
0x0000
Data
0
None
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 10 0000 0F
Module return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x10
Data length
2
0x0007
Data
7
data length is 7 bytes: Data[0] is the symbol whether to obtain the time successfully, 0 means failure, 1 means success Data [1] is the year, 0x00 means 2000 Data[2] means month,start from Jan, end with Dec Data[3] means data,start from 1st, end with 31st.Data[4] means hours,start from 0, end with 23 Data[5] means mins,start from 0, end with 59. Data[6] means seconds ,start from 0, end with 59.
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:0x55aa 00 10 0007 01 10 04 13 05 06 07 50(April 19, 2016 5: 6: 7 GMT)
MCU send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x11
Data length
2
0x0000
Data
xxxx
None
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Module return:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x11
Data length
2
0x0008
Data
Data
data length is 8 bytes: Data[0]is the symbol whether to obtain the time successfully, 0 means failure, 1 means success Data [1] is the year, 0x00 means 2000 Data[2] means month,start from Jan, end with Dec Data[3] means data,start from 1st, end with 31st.Data[4] means hours,start from 0, end with 23 Data[5] means mins,start from 0, end with 59. Data[6] means seconds ,start from 0, end with 15. Data[7] means week,start from 1, end with 7. 1 means Mon
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
For example:
(1)If the device is activated in China, the local time is Beijing time (East 8 District)
0x55aa 00 11 0008 01 10 04 13 05 06 07 02 54(Beijing time April 19, 2016 5: 6: 7)
(2)If the device is activated abroad, the local time is the time zone of the device
Description:Add multiple sub-devices of the same pid in batch. Note:The maximum number of sub-devices added in a batch is 32. MCU send:
Field
Length(byte)
Description
Header
2
0x55aa
Version
1
0x00
Command word
1
0x12
Data length
2
N
Data
{ “pid”:” xxxx”, “cids”:[”12”,”34”,”56”], “ver”:”x.x.x” }
product identity pid: Product ID(ProductID),generated by the Tuya cloud when creating the product cids:Collection of sub-devices to be added. ver: for example:1.0.0
Checksum
1
The result obtained by summing bytes from the beginning of the frame to the remainder of 256
Module return:
<