Offline Voice I2C Protocol of Zigbee Module

Last Updated on : 2024-06-21 03:24:41download

This topic describes the offline voice I2C protocol of the Zigbee module. It is suitable for developers who use Tuya offline voice modules for MCU development.

Communication convention

  • Communication rate: 100 Kbit/s

  • Bus address: 0x64

  • Communication data line: SCL, SDA

  • Data interrupt pin: INT_PIN (Pin is pulled up, when the voice module needs to actively send data to the IoT module, a low level of 100 ms is generated to inform the IoT module that there is data to send)

  • Data transfer volume: a single piece of data cannot exceed 256 bytes.

    Offline Voice I2C Protocol of Zigbee Module

    The Zigbee module acts as the primary, and the voice module acts as the secondary. The primary actively queries the status of the secondary, and the secondary responds to the primary with the latest status information after receiving the command.

Frame format

Field Length (byte) Description
Header 2 It is fixed as 0x55aa.
Version 1 It is used for update and extension.
Command 1 Frame type.
Data length 2 Big-endian.
Data N -
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.
  • All data greater than one byte shall be transmitted in big-endian mode.
  • Generally, the same command adopts synchronous sending and receiving mechanism. One party sends a command, and the other party responds.

Scene 1

The IoT module actively sends a command, and the voice module responds immediately after receiving the command (within 50 ms).

Offline Voice I2C Protocol of Zigbee Module

Scene 2

If the voice module wants to actively report messages to the IoT module, the following steps are required.

  1. The voice module needs to pull the INT pin low for 100 ms to generate a 100 ms low-level pulse.

  2. After the IoT module receives the interrupt signal, it uses the 0x88 command to query the status change of the voice module.

  3. The voice module responds with information about the status change.

  4. The IoT module replies to the voice module that it has received a state change message.

    Offline Voice I2C Protocol of Zigbee Module

Protocol details

The table below lists commands for I2C communication.

Command Feature Description
0x00 Heartbeat detection The IoT module sends a heartbeat to the offline voice module every 5s.
0x03 Zigbee network status of IoT module The IoT module sends the Zigbee network status to the voice module.
0x05 Reset Zigbee and switch network pairing mode You can specify which pairing mode the IoT module enters when resetting.
0x06 DP status reporting The offline voice module reports the DP control to the IoT module. After the IoT module receives the data, the command is forwarded to the MCU to control the DP execution.
0x07 DP status issuing The IoT module synchronizes the DP information to the voice module.
0x2B Offline voice module queries network status The offline voice module actively queries the network status of the IoT module.
0x65 Voice settings Set offline voice module parameters.
0x66 Speech recognition text reporting The voice module provides speech recognition text in Unicode format to the IoT module.
0x67 Issuing text verification results The IoT module informs the voice module of the result of the voice and text verified by the platform in Unicode format.
0x68 Voice reporting Voice module parameters are actively reported.

Status query

  • After the Zigbee module is powered on, it periodically sends a command (0x88) at 5s intervals to query the status of the voice module. If the voice module status changes, the latest status information will be returned to the Zigbee module. If there is no status change, the heartbeat information (0x00) will be returned. If the voice module does not respond within the 90-second timeout period, the module considers a communication exception occurred and will restart the software.
  • In order to reduce the amount of interactive data, the query interval is set to 5 seconds, which may cause the delay for the Zigbee module to receive voice commands. In order to solve this problem, an interrupt method is adopted to add a data trigger I/O. When the voice module has a new state, this I/O will be triggered to be low level. At this time, the Zigbee module will immediately send a 0x88 query command to query the voice status after detecting the low level. The voice module will upload the changed information to the Zigbee module according to the status type.

For example, Zigbee module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x88
Data length 2 0x0000
Data 0 None
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 0x55aa 00 88 0000 ff

The voice module will decide what data to send based on whether there is a current status change. For example, if there is a user’s voice request to reset the network, the voice module will send the 0x05 command. If the volume is modified, then the 0x09 command will be sent. If the current status of voice module has not changed, then send the 0x00 heartbeat command as the heartbeat to the Zigbee module as a reply.

Heartbeat detection

After power-on, the IoT module sends heartbeats every 5 seconds. If the voice module does not respond within the 90-second timeout period, the module considers a communication exception occurred and will restart the software.

The voice module returns the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x00
Data length 2 0x0001
Data 1 0x00: the return value of the first heartbeat after the voice module reboots. It is only sent once, used for the module to determine whether the MCU reboots during the working process.
0x01: this value is returned except for the first return value of 0 after the voice module reboots.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, the voice module returns 0x55aa 03 00 0001 00 03 after a restart.
Returns 0x55aa 03 00 0001 01 04 except for the first response after a restart. Reply the voice module that a heartbeat command is received.

For example, Zigbee module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x00
Data length 2 0x0000
Data 0 None
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 0x55aa 00 00 0000 03

Select configuration mode (Zigbee)

With this frame, the MCU can select the required configuration mode after the Zigbee is reset.

The voice module returns the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x05
Data length 2 0x0001
Data 1 0x00: reset
0x01: network pairing
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 0x55aa 03 05 0001 01 09. The voice module makes Zigbee enter the network pairing mode.

Reply the voice module that a command of resetting Zigbee-selecting configuration mode is received.

For example, Zigbee module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x05
Data length 2 0x0000
Data 0 None
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 0x55aa 00 05 0000 03

DP control reporting

Data point command and status data unit is shown as follows:

Data segment Length (byte) Description
dpid 1 Data point serial number.
type 1 The specific data type of a data point on the Developer Platform, which is marked with the following “Value”.
Type Value Length (byte) Description
raw 0x00 N Corresponding to raw data point (module pass-through).
bool 0x01 1 Value range: 0x00/0x01.
Value 0x02 4 Corresponding to the integer type, which is expressed in big-endian.
string 0x03 N Correspond to specific strings.
enum 0x04 1 Enumeration data, ranging from 0 to 255.
bitmap 0x05 1/2/4 Represented by big-endian when there is more than one byte.
len 2 The length corresponds to the number of bytes of value. -
Value 1/2/4/N Expressed in the hexadecimal format. Use a big-endian representation when there is more than one byte. -
  • For the data point command/status data unit, except the “raw” type, all other types belong to the “obj” type data point.
  • The DP command reporting can contain command data units of multiple DPs.
  • The DP command reporting is an asynchronous processing protocol, corresponding to the data point status update issuing of the Zigbee module.
  • The status reporting can contain command data units of multiple DPs.
  • The voice module converts the voice input by the user into the corresponding DP and sends it to the Zigbee module. For example, the user sets a humidity of 30% by voice, the corresponding DP point is 5, and the humidity refers to the value 30 (0x1e).

The voice module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x06
Data length 2 It depends on the type and number of the status data unit.
Data N See the DP status data unit section.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, the humidity corresponds to DP 5, valve variable is used, and the humidity is 30%.
0x55aa 03 06 0008 05 02 0004 0000001e 3a

Reply the voice module that a DP control reporting command is received.

For example, Zigbee module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x06
Data length 2 0x0000
Data 0 None
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 0x55aa 00 06 0000 03

The offline voice module actively queries the network status

The voice module actively queries the network status of the Zigbee module through the command (0x2B), and the Zigbee module informs the voice module of the network status through the 0x2B command.

The MCU sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x2B
Data length 2 0x0000
Data 0 None
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 0x55aa 03 2B 0000 05

The Zigbee module returns the device network status as follows.

Device network status Description Status value
Status 1 Network not paired 0x00
Status 2 Pairing 0x03
Status 3 Paired (after the network pairing is successful, it has been in the paired status) 0x01

For example, Zigbee module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x2B
Data length 2 0x0001
Data 1 The Zigbee module returns the device network status as follows.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 0x55aa 00 2B 0001 02 01. The IoT module is connected to the cloud.

The IoT module sends the network status to the voice module

Device network status Description Status value
Status 1 Network not paired 0x00
Status 2 Pairing 0x03
Status 3 Paired (after the network pairing is successful, it has been in the paired status) 0x01

Note: The initial status of the Zigbee module is not paired. When the voice module sends a pairing command to the Zigbee module, it will send out a status notification of pairing, and then the Zigbee module will start the pairing. The timeout period is 3 minutes. If the network is successfully paired within 3 minutes, the network status will be reported. Otherwise, a failure will be reported when it expires.

The module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x03
Data length 2 0x0001
Data 1 See above table.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 0x55aa 00 03 0001 00 03

The voice module returns the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x03
Data length 2 0x0000
Data 0 None
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 0x55aa 03 03 0000 09. Reply to the pairing status command.

Voice recognition text reporting

  • The text is in character format. For example, I am going home. The text message is “I am going home”, and the voice module transmits these data directly.
  • The voice text information is sent to the Zigbee module through the 0x66 command, and the Zigbee module directly responds to the 0x66 command after receiving it to inform the voice module that the command has been received. After that, the text information is uploaded to the platform through the 501 protocol to verify the text. After receiving the reply from the platform, the Zigbee module informs the voice module of the result of the text verification through the 0x67 command.

The voice module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x66
Data length 2 0x0012
Data 2 Voice text ID. The voice module can correspond to unique scene commands through ID. For example, the ID corresponding to “home mode” is 00 01.
2 Country code, used to identify the language of which country the following characters are, such as China “CN”, United States “US”. -
N The total data length does not exceed 256 bytes. For example, Chinese: “回家场景”, English: “good night mode”. -
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

Country code standards. See Mappings Between OEM App Accounts and Data Centers.

For example, home scene, ID is 00 01.

55 aa 03 66 00 10 00 01 43 4e e5 9b 9e e5 ae b6 e5 9c ba e6 99 af 44

After the Zigbee module receives the text information of the voice module, it will be sent to the platform to verify whether the scene is valid.

For example, Zigbee module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x66
Data length 2 0x0000
Data N None
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 55 aa 00 66 00 00 65

Issuing text verification results

For example, Zigbee module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x67
Data length 2 0x0013
1 The result of the scene platform verification.
01: Verification succeeded.
00: Verification failed.
02: Network abnormality.
2 The unique voice scene ID. For example, the ID corresponding to “home mode” is 00 01.
Data N The total data length does not exceed 256 bytes. For example, Chinese: “回家场景”, English: “good night mode”.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, return the verification result of the following “home scene”, which means that the platform verification of “home scene” is successful.

55 aa 00 67 00 0F 01 00 01 e5 9b 9e e5 ae b6 e5 9c ba e6 99 af 2f

The voice module returns the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x67
Data length 2 0x0000
Data N None
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, 55 aa 03 67 00 00 69

Set, query, and report voice parameters

  • Extend the functions of voice module: Add status notification and settings of play/pause, Bluetooth on/off, local alarm clock, and voice control group.
  • Play/pause: play and pause music, poems, and jokes.
  • Bluetooth on/off: turn on/off Bluetooth speaker.
  • Local alarm clock: synchronization notification of the clock data set by the voice and app.
  • Voice control group: notification of voice control command of the previous/next song.
  • MIC on/off: turn on/off MIC, and report the MIC status changes.
  • Volume setting: set the volume of the voice module and actively report the volume change.

For example, Zigbee sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x65
Data length 2 xx
Data N It depends on the type and number of the status data unit.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

The voice module returns the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x65
Data length 2 xx
Data N It depends on the type and number of the status data unit.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

Status notification: The offline voice module actively reports the status

The voice module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x68
Data length 2 N
Data 1 It depends on the type and number of the status data unit.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, Zigbee module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x68
Data length 2 2
Data 1 Result: 0x00: indicates success. 0x01: indicates failure.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

Synchronize the DP information to the voice module

  • Status reporting can contain command data units of multiple data points.
  • The Zigbee module updates the MCU status information to the voice module. For example, the MCU humidity is 30%, the corresponding DP point is 5, and the humidity refers to the value 30 (0x1e).
  • When the MCU has a DP change and the Zigbee module is notified, the Zigbee module will notify the data to the voice module.

For example, Zigbee module sends the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x07
Data length 2 It depends on the type and number of the status data unit.
Data N See the DP status data unit section.
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, the humidity corresponds to DP 5, valve variable is used, and the humidity is 30%.

0x55aa 03 07 0008 05 02 0004 0000001e 3a

The voice module returns the following command:

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x07
Data length 2 0x0000
Data 0 None
Checksum 1 Add up all bytes starting from the header and divide the sum by 256 to get the remainder.

For example, return the mute status value:

55 aa 00 07 00 00 61