Reference
This article guides users through the setup and use of RS485 Wind Speed Transmitter with Modbus Protocol, including driver installation, library usage, and communication protocol details for effective wind speed measurement and address modification.
Communication Protocol Description
Modbus Protocol
-
The default communication parameters are: baud rate 9600bps, one start bit, 8 data bits, no parity, and one stop bit.
-
Modbus Register
Parameter Register Add Function Type Function No. Parameter Range & Description Default Value Wind Direction Value 0x0000 INT16 RO 0x03/reading 0-324 None Modbus Slave Address 0x1000 INT16 reading-and-writing 0x03/reading0x10/writing 0-255 2 -
Modbus Register Parameter Instruction
Wind Direction Value Parameter Range 0-324 Default Value: none Parameter Storage None Meaning: wind direction measuring value
Example: If the returned value is 00 25 (hexadecimal, original code) = 0x0025 = 37, then the wind speed measuring value is 37/10=3.7m/s
Modbus Slave Add (ADDRESS) Parameter Range 0-255 Default Value: 2 Parameter Storage Save immediately -
Example
-
Read register 0x0000, that is the measuring value of the wind direction
Host query frame (hexadecimal): 02 03 02 00 00 00 01 84 39 (8byt)
Slave Add Function Code Register Start Add Length of Register High Bit of Check Code Low Bit of Check Code 1byt 1byt 2byt 2byt 1byt 1byt 0×02 0x03 0x00 0x00 0x00 0x01 0x84 0x39 Slave response frame (hexadecimal): 02 03 02 00 25 3D 9F (7byt)
Slave Add Function Code Number of Valid Bytes Data Aera High Bit of Check Code Low Bit of Check Code 1byt 1byt 1byt 2byt 1byt 1byt 0×02 0x03 0x02 0x00 0x25 0x3D 0x9F The wind speed value is (hexadecimal, original code) 00 25 = 0x0025 = 37, then the wind speed measuring value is 37/10 = 3.7m/s
-
Modify register 0x1000, which is the Modbus slave address (ADDRESS)
Modify the Modbus slave address to 03
Host query frame (hexadecimal): 00 10 10 00 00 01 02 00 03 FA 00 (11byt)Slave Add Function Code Register Start Add Length of Register Number of Valid Bytes Slave Address Written-in High Bit of Check Code Low Bit of Check Code 1byt 1byt 2byt 2byt 1byt 2byt 1byt 1byt 0x00 0x10 0x10 0x00 0x00 0x01 0x02 0x00 0x03 FA 00 Slave response frame (hexadecimal): 00 10 10 00 00 01 04 D8 (7byt), that is, the modification is successful. After setting, you need to re-power on and restart the transmitter to make this address take effect.
-
API Description
/**
@brief initialize serial port
@param device Address of serial port,In Linux, it is the directory where the device is located.
@return Return 1 for initialization failure, and return 0 for initialization success
*/
unsigned char Init(char *device);
/**
@brief Modify address
@param Address1 For the current address, you can set any address with 0 address
@param Address2 The modified address.
@return A return value of 1 indicates success, and a return value of 0 indicates failure
*/
unsigned char ModifyAddress(unsigned char Address1, unsigned char Address2);
/**
@brief Read wind speed
@param Address The address where you want to read the data
@return The return value ≥0 indicates successful reading, the return value is wind speed, and the return value -1 indicates failed reading
*/
float readWindSpeed(unsigned char Address);
Other Supplementary Information

Was this article helpful?
