RS485 Wind Direction Transmitter

简介

风向传感器是用于测量风的水平风向的专业气象仪器。其内部采用霍尔角度传感器,传感器壳体和风向标采用铝合金材料,使用特种模具精密压铸工艺,尺寸公差甚小表面精度甚高,内部电路均经过防护处理,整个传感器具有很高的强度、耐候性、防腐蚀和防水性。电缆接插件为军工插头,具有良好的防腐、防侵蚀性能,能够保证仪器长期使用。选用低惯性风向标感应风向,当风向发生变化,尾翼转动通过轴杆带动轴芯磁铁转动,从而得到准确的风向信息。可以测量以标签北为起点的16个方位的自然界风向,具有很高的性价比,可广泛用于气象、海洋、环境、机场、港口、实验室、工农业及交通等领域。

特性

技术规格

尺寸

使用说明书

1、线色说明

颜色 功能
红色 电源正
黑色 电源负
黄色 RS485+/A/T+
绿色 RS485-/B/T-

2、安装说明

安装时传感器上白点必须朝向正北。

3、Modbus协议

参数名称 寄存器地址 功能类型 功能号 参数范围及说明 默认值
风向值 0x0000 INT16
只读
0x03/读 0-15
Modbus从机地址 0x1000 INT16
读写
0x03/读
0x10/写
0-255 2
风向值
参数范围 0-15 默认值:无
参数存储

意义:风向测量值

举例:如果返回的值是00 04 (16进制,原码),则第一字节高字节为00,第二字节低字节为04,那么风向测量值为(00*256+04)=4,0对应的是正北方向,顺时针4表示正东。

Modbus从机地址(ADDRESS)
参数范围 0-255 默认值:2
参数存储 立即存储

Modbus地址,可设置为0-255。使用0地址可以设置任何地址。

  1. 读寄存器0x0000,即风向的测量值

    主机查询帧(16进制):02 03 00 00 00 01 84 39(8byt)

    从机地址 功能码 寄存器起始地址 寄存器长度 校验码高位 校验码低位
    1byt 1byt 2byt 2byt 1byt 1byt
    0x02 0x03 0x00 0x00 0x00 0x01 0x84 0x39

    从机应答帧(16进制):02 03 02 00 03 BC 45(7byt)

    从机地址 功能码 有效字节数 数据区 校验码高位 校验码低位
    1byt 1byt 1byt 2byt 1byt 1byt
    0x02 0x03 0x02 0x00 0x03 0xBC 0x45

    16方位值=00 03=3,对应下表得到方位为东北偏东。

    数值 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    方位 东北偏北 东北 东北偏东 东南偏东 东南 东南偏南 西南偏南 西南 西南偏西 西 西北偏西 西北 西北偏北
  2. 修改寄存器0x1000,即Modbus从机地址(ADDRESS)

    将即Modbus从机地址修改为03

    主机查询帧(16进制):00 10 10 00 00 01 02 00 03 FA 00(11byt)

    从机地址 功能码 寄存器起始地址 寄存器长度 有效字节数 写入的从机地址 校验码高位 校验码低位
    1byt 1byt 2byt 2byt 1byt 2byt 1byt 1byt
    0x00 0x10 0x10 0x00 0x00 0x01 0x02 0x00 0x03 FA 00

    从机应答帧(16进制):00 10 10 00 00 01 04 D8(7byt),即为修改成功。

在树莓派上使用

1、接线

这里需要用到USB转485模块

接线图

2、安装库和下载例程

在终端依次输入一下命令

cd /tmp
wget https://project-downloads.drogon.net/wiringpi-latest.deb   //下载wiringpi库
sudo dpkg -i wiringpi-latest.deb  //安装wiringpi库
cd .....                                                     //进入你想保存文件的目录
git clone https://github.com/DFRobotdl/RS485_Wind_Direction_Transmitter.git     //下载github上的程序
cd RS485_Wind_Direction_Transmitter/

3、主要API接口函数列表

/**
  @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 direction
  @param  Address The address where you want to read the data
  @return  The return value ≥0 indicates successful reading, the return value is the wind direction corresponding to the following table, and the return value is -1 indicates failed reading
                                                           Return the value to the direction correspondence table
  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  |   value   |   0   |     1     |     2     |     3     |  4   |     5     |     6     |     7     |   8   |     9     |     10    |     11    |  12  |    13     |     14    |     15    |
  |-----------|-------|-----------|-----------|-----------|------|-----------|-----------|-----------|-------|-----------|-----------|-----------|------|-----------|-----------|-----------|
  | Direction | North | Northeast | Northeast | Northeast | East | Southeast | Southeast | Southeast | South | Southwest | Southwest | Southwest | West | Northwest | Northwest | Northwest | 
  |           |       | by north  |           |  by east  |      |  by east  |           | by south  |       | by south  |           |  by west  |      |  by west  |           | by north  |
  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

*/
int readWindDirection(unsigned char Address);

4、查看设备

在终端输入:

sudo ls -l /dev

找到你刚刚接入的设备

5、打开之前下载的min.c文件,将程序中程序中设备端口与实际改为一致并保存。

6、使用终端打开程序所在的文件夹,编译并运行

gcc -Wall -lwiringPi -o Wind_Direction *.c
sudo ./Wind_Direction

就看到准确的风向信息了

如何在Arduino和microbit主控上使用风速仪与风向仪?

点击查看:如何在Arduino和microbit 主控上使用风速仪与风向仪? ————RS485转UART

常见问题

还没有客户对此产品有任何问题,欢迎通过 qq 或者论坛联系我们! 更多问题及有趣的应用,可以访问论坛进行查阅或发帖

更多

DFRobot 商城购买链接