Weather Service

Last Updated on : 2024-06-04 08:16:34download

This topic describes the commands for the weather service.

(Optional) Enable the weather service (0x20)

The MCU sends the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x20
Data length 2 N((L+K)+(L+K)…)
Data N
  • L: a 1-byte value, representing the length of K.
  • K: parameter name.
Example:
  • L: 0x06 K: w.temp
  • L: 0x06 K: w.pm25
  • L: 0x0a K: w.humidity
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 0x20
Data length 2 0x0002
Data 2
  • Result (1 byte):
    • 0x00: Failure.
    • 0x01: Success.
  • Error code (1 byte):
    • 0x00: No error.
    • 0x01: Invalid data format.
    • 0x02: Exception.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

(Optional) Send weather data (0x21)

After the weather service is enabled, the module regularly sends weather data received from the cloud to the MCU.

The module sends the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x21
Data length 2 N((LKTLV)(LKTLV)…)
Data N
  • 0x00: Failure.
    • 0x01: Access denied. Check whether you have subscribed to the weather service.
  • 0x01: Success.
    • L: The length of the parameter name.
    • K: The parameter name.
    • T: 0x00 for integer and 0x01 for string.
    • L: The length of the field name.
    • V: The value of the field.
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 Bytes Description
Header 2 0x55aa
Version 1 0x03
Command 1 0x21
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.

If the request parameter is w.temp,w.pm25, only w.temp returns a value, you need to check whether the request parameter name is correct.