Data Point (DP) Service

Last Updated on : 2024-06-04 06:33:21download

This topic describes the commands for the DP service.

Data units

The following table defines the data units for a DP.

Field Bytes Description
dpid 1 The DP ID.
type 1 The data type of DP defined on the Tuya Developer Platform. For more information, see the description of the type field in the following table.
len 2 The length of a value, in bytes. For more information, see the description of the type field in the following table.
value 1/2/4/N Represented in hexadecimal format. Data greater than one byte is transmitted in big-endian format.

Description of the type field:

type Data type Bytes Description
0x00 Raw N Represents a DP of raw data type. The module transmits the raw data to the receiver.
0x01 Boolean 1 Represents a DP of Boolean data type. Valid values include 0x00 and 0x01.
0x02 Value 4 Represents a DP of integer data type. The data is represented in big-endian format.
0x03 String N Represents a DP of string data type.
0x04 Enum 1 Represents a DP of enum data type, ranging from 0 to 255.
0x05 Bitmap 1/2/4 Data greater than one byte is transmitted in big-endian format.
  • Except for the raw data type, all others belong to the object type.
  • One command can contain data units of multiple DPs.
  • Asynchronous communication applies when the module sends control commands and the MCU reports DP status.

Send commands (0x06)

The module sends the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x06
Data length 2 It depends on the types and the number of data units.
Data N Data units
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Suppose that DP 3 of Boolean type is used for on/off control, and 1 means to turn on the device, the module sends 0x55aa 00 06 0005 03 01 0001 01 10 to the MCU.

The MCU responds when dp_ack is enabled in the product information.

Field Bytes Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x06
Data length 2 0x0001
Data 1
  • 0x00: Failure.
  • 0x01: Success.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Report status (async) (0x07)

  • For more information, see Data units.

  • This is an asynchronous command. The MCU uses it to report device status to the module, which can be triggered by three mechanisms.

    • After the MCU executes the command received from the module, it reports the changed DP status to the module.

    • When the MCU proactively detects status changes of DPs, it reports the changed DP status to the module.

    • When the MCU receives the DP status query, it sends the status of all DPs to the module.

  • The MCU can report the status of multiple DPs.

The MCU sends the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x07
Data length 2 It depends on the types and the number of data units.
Data N Data units
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Suppose that DP 5 of value type is used for reporting the current humidity, and the current humidity is 30%, the MCU reports 0x55aa 03 07 0008 05 02 0004 0000001e 3a to the module.

Query status (0x08)

  • The module asynchronously queries the status of all object DPs. When the MCU receives a query, it sends the status of DPs to the module through the command 0x07.

  • The module sends a status query to the MCU when the following two events occur.

    • When powered on for the first time, the module sends a status query after it connects to the MCU and cloud.

    • When the module detects the MCU is restarted or disconnected and then goes online, the module sends a status query.

The module sends the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x08
Data length 2 0x0000
Data 0 None
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Example: 0x55aa 00 08 0000 07

Report non-record type status (0x22)

  • This is a synchronous command. The MCU reports DP status and then waits for the result from the module.

  • The MCU should not send a new request until receiving a response to the previous status reporting.

  • If the data fails to be reported to the cloud due to poor network quality, the module will return a failure code five seconds later. In this case, the MCU should wait for more than five seconds.

  • For more information, see Data units.

  • The MCU can report the status of multiple DPs.

The MCU sends the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x22
Data length 2 It depends on the types and the number of data units.
Data N Data units
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The module returns the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x23
Data length 2 0x01
Data 1
  • 0x00: Failure.
  • 0x01: Success.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Report record type status (0x26)

  • This is a synchronous command. The MCU reports DP status and then waits for the result from the module.

  • The MCU should not send a new request until receiving a response to the previous status reporting.

  • If the data fails to be reported to the cloud due to poor network quality, the module will return a failure code five seconds later. In this case, the MCU should wait for more than five seconds.

  • For more information, see Data units.

  • The MCU can report the status of multiple DPs.

The MCU sends the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x26
Data length 2 The length of the DP data unit plus seven
Timestamp 7
  • Data[0]: Specifies whether the local time is included.
    • 0: The local time provided by the MCU is not included. The module considers the received time data invalid.
    • 1: The local time is included.
    • 2: The time in GMT is included.
  • Data[1] indicates the year. 0x00 indicates the year 2000.
  • Data[2] indicates the month, ranging from 1 to 12.
  • Data[3] indicates the day, ranging from 1 to 31.
  • Data[4] indicates the hour, ranging from 0 to 23.
  • Data[5] indicates the minute, ranging from 0 to 59.
  • Data[6] indicates the second, ranging from 0 to 59.
Data N Data units
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The module returns the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x26
Data length 2 0x0001
Data 1
  • 0x00: Failure.
  • 0x01: Success.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.