Protocol Description

Last Updated on : 2024-11-20 08:51:39download

This topic describes the serial protocol used between Remotec’s infrared (IR) controller and Tuya’s Wi-Fi module. The protocol can enable the Wi-Fi module to send IR codes to the MCU, trigger IR learning, and report user parameters to the cloud.

Send IR codes

The IR codes can be used for device control or IR learning, so it is necessary to differentiate between these two types of IR codes.

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x39
Data length 2 It depends on the size of the data unit.
Data 1 The types of IR codes.
  • 1: IR codes for device control.
  • 2: IR codes for IR learning.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

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

IR learning

  • The types of IR learning include learning new buttons and matching devices.
  • The commands for IR learning include starting learning and stopping learning.
  • Learning new buttons can be performed by short learning or long learning, which are triggered by short pressing or pressing and holding the button on a remote control respectively.

Learning new buttons

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x40
Data length 2 0x0002
Data Data
  • The first byte: The learning type.
    • 1: Start short learning.
    • 2: Stop short learning.
    • 3: Start long learning.
    • 4: Stop long learning.
  • The second byte: The learning state.
    • 1: Enter the learning state.
    • 2: Exit the learning state.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x40
Data length 2 It depends on the size of the data unit.
Data Data Data
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Matching devices

The module sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x41
Data length 2 0x0001
Data 1 The matching state.
  • 1: Enter the matching state.
  • 2: Exit the matching state.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

The MCU returns the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x41
Data length 2 It depends on the size of the data unit.
Data Data Data
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Report user parameters

For cloud-to-cloud integration, the Wi-Fi module receives the user_email, user_pwd, and pa_key from the MCU and sends these unique parameters to the Remotec’s cloud for interaction.

The MCU sends the following data.

Field Length (byte) Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x42
Data length 2 It depends on the size of the data unit.
Data Data Data format
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

For example, test1**@tuya.com,B7R4****,BEGV**** indicates the user_email, user_pwd, and pa_key respectively.