RS485 Wind Direction Sensor/Transmitter V2 Wiki - DFRobot

Introduction

The wind direction sensor is a professional meteorological instrument used to measure horizontal wind direction. It integrates a hall sensor inside. The shell and weather vane are made of aluminum alloy material and use special mold precision die casting process, featuring small dimension tolerance and high surface accuracy. The sensor internal circuit is protected, which makes the sensor have the properties of high strength, weather resistance, anti-corrosion, and waterproof. The cable connector adopts corrosion-resistant military plug that ensures the long service life of the product.
A low-inertia wind vane is used to sense the wind direction. When the wind direction changes, the tail wing rotates to drive the axle magnet to rotate through the shaft, thereby obtaining accurate wind direction information. It can detect the 16 natural wind directions. This sensor with high cost performance can be widely used in meteorology, ocean, environment, airports, ports, laboratories, industry, agriculture and transportation.

Features

Specification

Dimension

User Guide

1. Wire Color Description

Color Function
Red Positive
Black Negative
Yellow RS485+/A/T+
Green RS485-/B/T-

2. Installation Instruction

The white dot on the sensor must face true north in installation.

3. Modbus Protocol

Parameter Register Add. Function Type Function No. Parameter Range & Description Default Value
Wind Direction of 360° 0x0000 INT16 RO 0x03/reading 0x00-0xE10 (hexadecimal) None
16 Wind Directions 0x0001 INT16 RO 0x03/reading 0x00-0x0F (hexadecimal) None
Modbus Slave Address 0x1000 INT16 reading-and-writing 0x03/reading
0x10/writing
0x00-0xFF (hexadecimal) 2
Wind Direction of 360°
Parameter Range 0x00-0xE10 (hexadecimal) Default Value: none
Parameter Storage None

Indication: the wind direction measured in degrees (°) from 0° to 360°
Example: If the returned value is 02 8F (hexadecimal) = 655 (decimal) ÷ 10 = 65.5°, the degree is the angle with the true north (i.e. 0°).

16 Wind Directions
Parameter Range 0x00-0x0F (hexadecimal) Default Value: none
Parameter Storage None

Indication: the wind value of 16 directions
Example: If the returned value is 00 04 (hexadecimal, true form), the high byte of the first byte is 00, the low byte of the second byte is 04, and the measured wind direction value is (00*256+04)=4, 0 for true north and clockwise 4 for true east.

Modbus Slave Add. (ADDRESS)
Parameter Range 0-255 Default Value: 2
Parameter Storage Immediate storage

Modbus address can be set to 0-255. You can use 0 address to set any address.

  1. Read the 360° wind direction angle (Modbus slave address 0x02)

Host query frame (hexadecimal): 02 03 00 00 00 01 84 39 (8byt)

Slave Add. Function Code Register Start Add. Length of Register High Bits of Check Code Low Bits 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 02 8F BC 80 (7byt)

Slave Add. Function Code Number of Valid Bytes Data Aera High Bits of Check Code Low Bits of Check Code
1byt 1byt 1byt 2byt 1byt 1byt
0×02 0x03 0x02 0x02 0x8F 0xBC 0x80

Wind angle value = 02 8F (hex) = 655 (decimal) ÷ 10 = 65.5°, which is the angle with the true north (i.e. 0°).

  1. Read the 16 wind directions (Modbus slave address 0x02)

Host query frame (hexadecimal): 02 03 00 01 00 01 D5 F9(8byt)

Slave Add. Function Code Register Start Add. Length of Register High Bits of Check Code Low Bits of Check Code
1byt 1byt 2byt 2byt 1byt 1byt
0x02 0x03 0x00 0x01 0x00 0x01 0xD5 0xF9

Slave response frame (hexadecimal): 02 03 02 00 03 BC 45 (7byt)

Slave Add. Function Code Number of Valid Bytes Data Aera High Bits of Check Code Low Bits of Check Code
1byt 1byt 1byt 2byt 1byt 1byt
0×02 0x03 0x02 0x00 0x03 0xBC 0x45

16 directions value = 00 03 = 3, the direction is east-northeast according to the table below.

Correspondence Table

Direction 16 Directions Value 360°
North 0 0° - 11.2°
North-northeast 1 11.3° - 33.7°
Northeast 2 33.8° - 56.2°
East-northeast 3 56.3° - 78.7°
East 4 78.8° - 101.2°
East-southeast 5 101.3° - 123.7°
Southeast 6 123.8° - 146.2°
South-southeast 7 146.3° - 168.7°
South 8 168.8° - 191.2°
South-southwest 9 191.3° - 213.7°
Southwest 10 213.8° - 236.2°
West-southwest 11 236.3° - 258.7°
West 12 258.8° - 281.2°
West-northwest 13 281.3° - 303.7°
Northwest 14 303.8° - 326.2°
North-northwest 15 326.3° - 348.7°
North 16 348.8° - 360°
  1. Read device Modbus slave address

You can query the devices at any address using 0x00 address (broadcast address).
Host query frame (hexadecimal): 00 03 10 00 00 01 81 1B (8byt)

Slave Add. Function Code Register Start Add. Length of Register High Bits of Check Code Low Bits of Check Code
1byt 1byt 2byt 2byt 1byt 1byt
0x00 0x03 0x10 0x00 0x00 0x01 0x81 0x1B

Slave response frame (hexadecimal): 00 03 02 00 15 8C D8 (7byt)

Slave Add. Function Code Number of Valid Bytes Data Aera High Bits of Check Code Low Bits of Check Code
1byt 1byt 1byt 2byt 1byt 1byt
0×00 0x03 0x02 0x00 0x15 0x8C 0xD8

Current device Modbus slave address = 00 15 (hex), i.e. the current device Modbus slave address is 0x15.

  1. Change register 0x1000, i.e. change Modbus slave address (ADDRESS)

Change Modbus slave address to 03
You can set the devices at any address using the 0x00 address (broadcast address).
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 Add. to Be Written High Bits of Check Code Low Bits 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), and that indicates the modification is successful.

Slave Add. Function Code Register Add. Length of Register High Bits of Check Code Low Bits of Check Code
1byt 1byt 2byt 2byt 1byt 1byt
0x00 0x10 0x10 0x00 0x00 0x01 0x04 0xD8

Tutorial

Requirements

Connection Diagram

Sample Code

Copy the following code and paste it to your Arduino IDE and upload it.

#include "RS485_Wind_Direction_Transmitter_V2.h"


/**
   @brief RS485_Wind_Direction_Transmitter_V2 constructor
   @param serial - serial ports for communication, supporting hard and soft serial ports
   @param rx - UART the pin for receiving data
   @param tx - UART the pin for transmitting data
*/
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)   // use soft serial port
SoftwareSerial softSerial(/*rx =*/2, /*tx =*/3);
RS485_Wind_Direction_Transmitter_V2 windDirection(/*softSerial =*/&softSerial);
#elif defined(ESP32)   // use the hard serial port with remapping pin : Serial1
RS485_Wind_Direction_Transmitter_V2 windDirection(/*hardSerial =*/&Serial1, /*rx =*/D3, /*tx =*/D2);
#else   // use the hard serial port : Serial1
RS485_Wind_Direction_Transmitter_V2 windDirection(/*hardSerial =*/&Serial1);
#endif

uint8_t Address = 0x02;

const char* Orientation[17] = {
  "North", "North-northeast", "Northeast", "East-northeast", "East", "East-southeast", "Southeast", "South-southeast", "South",
  "South-southwest", "Southwest", "West-southwest", "West", "West-northwest", "Northwest", "North-northwest", "North"
};

void setup()
{
  Serial.begin(115200);

  // Init the sensor
  while ( !( windDirection.begin() ) ) {
    Serial.println("Communication with device failed, please check connection");
    delay(3000);
  }
  Serial.println("Begin ok!");
//Change modbus slave address, and you can use 0x00 broadcast address to change it if you forgot the current address.
//  windDirection.SetSlaveAddress(/*the current modbus slave address*/0x00, /*the address after the change*/0x02);
//Get modbus slave address
//  Address = windDirection.GetSlaveAddress();
}

void loop()
{
  //Get 16 wind directions
  int Direction = windDirection.GetWindDirection(/*modbus slave address*/Address);
  //Get 360° wind direction
  float Angle = windDirection.GetWindAngle(/*modbus slave address*/Address);
  Serial.println(Orientation[Direction]);
  Serial.print(Angle); Serial.println("°");
  Serial.println();
  delay(1000);
}

Result

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents