Last Updated on : 2024-06-24 08:13:32download
This topic describes how to use the MCU SDK to get the weather data for your product. The weather service is an important feature for smart devices, allowing the MCU to request weather data through the Bluetooth LE module.
After the Bluetooth module is connected to the cloud through a mobile phone or gateway, the MCU can send commands to get weather data. The module does not support subscribing to weather changes. Therefore, the MCU needs to invoke commands regularly to get the latest weather information.
The weather location depends on the latitude and longitude where a mobile phone is located.
The MCU sends the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xB6 |
4 5 |
2 | Data length (Len) | Upper 8 bits Lower 8 bits |
6 to 6+Len-1 | Len | Data | See the description below |
6+Len | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Data description:
Location | Weather parameter | Number of forecast days |
---|---|---|
1 byte | 4 bytes | 1 byte |
Location:
0x01
: The location where the device is paired.0x02
: The location where the mobile phone is.Weather parameter
(1 << 0), /**< temperature. */
(1 << 1), /**< high temperature. */
(1 << 2), /**< low temperature. */
(1 << 3), /**< humidity. */
(1 << 4), /**< weather condition. */
(1 << 5), /**< pressure. */
(1 << 6), /**< sensible temperature. */
(1 << 7), /**< uvi. */
(1 << 8), /**< sunrise. */
(1 << 9), /**< sunset. */
(1 << 10), /**< unix time, used with sunrise and sunset. */
(1 << 11), /**< local time, used with sunrise and sunset. */
(1 << 12), /**< wind speed. */
(1 << 13), /**< wind direction. */
(1 << 14), /**< wind speed scale/level. */
(1 << 15), /**< aqi. */
(1 << 16), /**< tips. */
(1 << 17), /**< detailed AQI status and national ranking. */
(1 << 18), /**< pm10. */
(1 << 19), /**< pm2.5. */
(1 << 20), /**< o3. */
(1 << 21), /**< no2. */
(1 << 22), /**< co. */
(1 << 23), /**< so2. */
(1 << 24), /**< weather condition mapping id. */
Number of forecast days: Specifies the number of days for which the server returns forecast data. The valid value ranges from 1
to 7
, and 1
indicates today. For more information, see the Appendix.
The module returns the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xB6 |
4 5 |
2 | Data length (Len) | Upper 8 bits Lower 8 bits |
6 to 6+Len-1 | Len | Data | See the description below |
6+Len | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Data description: status (1 byte) + weather_values
(0 bytes or Len-1
bytes).
Status:
0x00
: Success
0x01
: Parameter error
0x02
: Request failed
0x03
: Request timeout
0x04
: Repeated request
0x05
: Status error
Weather_values
: The value of weather, which is valid when status
is 0x00
. For more information about the data format, see the following table.
{Day | Weather parameter (little-endian) | Data type | Data length x | Data} | … | Recurring in the specified format |
---|---|---|---|---|---|---|
1 byte | 4 bytes | 1 byte | 1 byte | x bytes | … | Recurring in the specified format |
Data type: 0x00
: Integer, 0x01
: String
Example:
MCU to module: 55 AA 00 B6 00 06 01 00 00 00 0F 01 CC
Module to MCU: 55 AA 00 B6 00 2D 00 01 01 00 00 00 00 04 00 00 00 21 01 02 00 00 00 00 04 00 00 00 24 01 04 00 00 00 00 04 00 00 00 1C 01 08 00 00 00 00 04 00 00 00 44 AA
conditionNum | Condition | Chinese characters in UTF-8 (Hexadecimal) |
---|---|---|
120 | Sunny | E699B4 |
101 | Heavy rain | E5A4A7 E99BA8 |
102 | Thunderstorm | E99BB7 E69AB4 |
103 | Sandstorm | E6B299 E5B098 E69AB4 |
104 | Light snow | E5B08F E99BAA |
105 | Snow | E99BAA |
106 | Freezing fog | E586BB E99BBE |
107 | Rainstorm | E69AB4 E99BA8 |
108 | Isolated shower | E5B180 E983A8 E998B5 E99BA8 |
109 | Dust | E6B5AE E5B098 |
110 | Thunder and lightning | E99BB7 E794B5 |
111 | Light shower | E5B08F E998B5 E99BA8 |
112 | Rain | E99BA8 |
113 | Sleet | E99BA8 E5A4B9 E99BAA |
114 | Dust devil | E5B098 E58DB7 E9A38E |
115 | Ice pellet | E586B0 E7B292 |
116 | Strong sandstorm | E5BCBA E6B299 E5B098 E69AB4 |
117 | Sand blowing | E689AC E6B299 |
118 | Light to moderate rain | E5B08F E588B0 E4B8AD E99BA8 |
119 | Mostly clear | E5A4A7 E983A8 E699B4 E69C97 |
121 | Fog | E99BBE |
122 | Shower | E998B5 E99BA8 |
123 | Heavy shower | E5BCBA E998B5 E99BA8 |
124 | Heavy snow | E5A4A7 E99BAA |
125 | Extraordinary rainstorm | E789B9 E5A4A7 E69AB4 E99BA8 |
126 | Blizzard | E69AB4 E99BAA |
127 | Hail | E586B0 E99BB9 |
128 | Light to moderate snow | E5B08F E588B0 E4B8AD E99BAA |
129 | Partly cloudy | E5B091 E4BA91 |
130 | Light snow shower | E5B08F E998B5 E99BAA |
131 | Moderate snow | E4B8AD E99BAA |
132 | Overcast | E998B4 |
133 | Needle ice | E586B0 E99288 |
134 | Downpour | E5A4A7 E69AB4 E99BA8 |
136 | Thundershower and hail | E99BB7 E998B5 E99BA8 E4BCB4 E69C89 E586B0 E99BB9 |
137 | Freezing rain | E586BB E99BA8 |
138 | Snow shower | E998B5 E99BAA |
139 | Light rain | E5B08F E99BA8 |
140 | Haze | E99CBE |
141 | Moderate rain | E4B8AD E99BA8 |
142 | Cloudy | E5A49A E4BA91 |
143 | Thundershower | E99BB7 E998B5 E99BA8 |
144 | Moderate to heavy rain | E4B8AD E588B0 E5A4A7 E99BA8 |
145 | Heavy rain to rainstorm | E5A4A7 E588B0 E69AB4 E99BA8 |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback