Reference
This article delves into the RS485 communication protocol, explaining data frame formats, Modbus-RTU usage, and providing practical examples for sensor data communication.
Communication Protocol Description
1. Basic communication parameters
| Interface | Encoding | Data bits | Parity bits | Stop bits | Error checking | Baud rate |
|---|---|---|---|---|---|---|
| RS485 | 8-bit binary | 8 | None | 1 | CRC | 1200bit/s, 2400bit/s, 4800bit/s, 9600bit/s, 19200bit/s, 38400bit/s, 57600bit/s, 115200bit/s configurable, default 4800bit/s |
2. Data frame format definition
Using Modbus-RTU communication protocol, the format is as follows:
Initial structure ≥4 bytes of time
Address code = 1 byte
Function code = 1 byte
Data area = N bytes
Error check = 16-bit CRC code
End structure ≥4 bytes of time
Address code: The address of the sensor, which is unique in the communication network (factory default 0x01).
Function code: The function indication of the command sent by the host. This sensor reads the register function code 0x03 and writes the register function code 0x06
Data area: The data area is the specific communication data. Note that the high byte of 16-bit data is in front!
CRC code: A two-byte check code.
Host inquiry frame structure:
| Address code | Function code | Register start address | Register length | Check code low bit | Check code high bit |
|---|---|---|---|---|---|
| 1byte | 1byte | 2byte | 2byte | 1byte | 1byte |
Slave response frame structure:
| Address code | Function code | Number of valid bytes | Data area 1 | Data area 2 | Nth data area | Check code |
|---|---|---|---|---|---|---|
| 1byte | 1byte | 1byte | 2byte | 2byte | 2byte | 2byte |
General register address
| Register address | PLC or configuration address | Content | Supported function code | Definition description |
|---|---|---|---|---|
| 01F4H | 40501 | Wind speed value | 0x03 | 10 times the actual value |
| 01F6H | 40503 | Wind direction (0-7 gears) | 0x03 | Actual value (0 for due north, increasing value clockwise, 2 for due east) |
| 01F7H | 40504 | Wind direction (0-360°) | 0x03 | Actual value (0° for due north, increasing value clockwise, 90° for due east) |
| 01F8H | 40505 | Humidity value | 0x03 | 10 times the actual value |
| 01F9H | 40506 | Temperature value | 0x03 | 10 times of actual value |
| 01FAH | 40507 | Noise value | 0x03 | 10 times of actual value |
| 01FBH | 40508 | PM2.5 value | 0x03 | Actual value |
| 01FCH | 40509 | PM10 value | 0x03 | Actual value |
| 01FDH | 40510 | Atmospheric pressure value | 0x03 | Actual value |
| 01FEH | 40511 | High 16 bits of illumination value | 0x03 | Actual value |
| 01FFH | 40512 | Low 16 bits of illumination value | 0x03 | Actual value |
| 0200H | 40513 | Illumination value | 0x03 | Actual value |
| 0201H | 40514 | Rainfall value | 0x03 | 10 times the actual value |
| 07D0H | 42001 | Device address | 0x03/0x06 | 1~254 (factory default 1) |
| 07D1H | 42002 | Device baud rate | 0x03/0x06 | 0 represents 2400, 1 represents 4800, 2 represents 9600, 3 represents 19200, 4 represents 38400, 5 represents 57600, 6 represents 115200, 7 represents 1200 |
Calibration register address
| Register address | Content | Supported function code | Definition description |
|---|---|---|---|
| 6000H | Wind direction offset register | 0x06 | 0 represents the normal direction, 1 represents the direction offset by 180 degrees |
| 6001H | Wind speed zeroing register | 0x06 | Write 0xAA, wait for 10 seconds, and the device will be zeroed |
| 6002H | Rainfall zeroing register | 0x06 | Write 0x5A, and the rainfall value will be zeroed |
3. Communication protocol example and explanation
3.1. Read the wind speed value of a single register
Inquiry frame: Read value function code 0x03
| Address code | Function code | Register start address | Register length | Check code low bit | Check code high bit |
|---|---|---|---|---|---|
| 0x01 | 0x03 | 0x00 0xF4 | 0x00 0x01 | 0xC4 | 0x04 |
Response frame:
| Address code | Function code | Return valid bytes | Wind speed value | Check code low bit | Check code high bit |
|---|---|---|---|---|---|
| 0x01 | 0x03 | 0x02 | 0x00 0x7D | 0x78 | 0x65 |
Wind speed value:
007D (hexadecimal) = 125=> Wind speed value = 1.25m/s
3.2, read multiple register humidity and temperature values
Inquiry frame: read numerical function code 0x03
| Address code | Function code | Register start address | Register length | Check code low position | Check code high position |
|---|---|---|---|---|---|
| 0x01 | 0x03 | 0x01 0xF8 | 0x00 0x02 | 0x44 | 0x06 |
Response frame:
| Address code | Function code | Return valid bytes | Humidity value | Temperature value | Check code low position | Checksum high position |
|---|---|---|---|---|---|---|
| 0x01 | 0x03 | 0x04 | 0x02 0x92 | 0xFF 0x9B | 0x5A | 0x3D |
Humidity value:
0292 (hexadecimal) = 658=> Humidity value = 65.8%RH
Temperature value: When the temperature is lower than 0℃, upload in the form of complement
FF9B (hexadecimal) = -101=> Temperature value = -10.1°C
3.3, modify the current address
Inquiry frame: (modify the current address to 0x02)
| Address code | Function code | Register address | Modify value | Checksum low position | Checksum high position |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x07 0xD0 | 0x00 0x02 | 0x08 | 0x86 |
Response frame:
| Address code | Function code | Register address | Modify value | Check code low bit | Check code high bit |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x07 0xD0 | 0x00 0x02 | 0x08 | 0x86 |
3.4, Modify the current baud rate
Inquiry frame: (Modify the current baud rate to 9600)
| Address code | Function code | Register address | Modify value | Check code low bit | **Check code high ** |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x07 0xD1 | 0x00 0x02 | 0x59 | 0x46 |
Response frame:
| Address code | Function code | Register address | Modify value | **Check code low ** | **Check code high ** |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x07 0xD1 | 0x00 0x02 | 0x59 | 0x46 |
3.5. Query current address and baud rate
Inquiry frame:
| Address code | Function code | Register address | Data length | Check code low bit | Check code high bit |
|---|---|---|---|---|---|
| 0xFF | 0x03 | 0x07 0xD0 | 0x00 0x02 | 0xD1 | 0x58 |
Response frame:
| Address code | Function code | Return valid bytes | Address | Baud rate | Check code low bit | Check code high bit |
|---|---|---|---|---|---|---|
| 0x01 | 0x03 | 0x04 | 0x00 0x01 | 0x00 0x01 | 0x6A | 0x33 |
The real address of the device is 01, and the baud rate is 0x01, that is, 4800.
Other Supplementary Information
Installation Instructions
When measuring wind speed and direction, the N-shaped direction on the weather station sensor should be installed facing due north to avoid errors.
The applicable range of the bottom mounting bar: 46-51mm
The following installation methods are recommended (the bracket needs to be purchased or built by yourself)

Was this article helpful?
