风速风向传感器 =================== .. figure:: /_static/products/ledong-module/static/图片/风速风向传感器.png :width: 55% :align: center 概述 -------------------- 气象站专用传感器,测量风速和风向,485信号通讯。 技术参数 ------------------- 工作电压:12V 波特率:4800bps 风速测量范围:0-35m/s(0-12级) 风向测量范围:八方位 动态响应时间:≤2秒 配件:12V-DC电源适配器、转接线等 引脚 定义 ------------------- ======= ======== 引脚 定义 ======= ======== GND 地 VCC 电源 TX 串口发送 RX 串口接收 ======= ======== 示例程序 ------------------- **气象站代码** .. code-block:: python from mpython import * from bluebit import WEATHER w = WEATHER(uart_num=1,pin_tx=Pin.P16,pin_rx=Pin.P15) import time def get_wind_dir(): try: direction = w.read_wind_direction()[0] if(direction == 0): return "北风" elif(direction == 1): return "东北风" elif(direction == 2): return "东风" elif(direction == 3): return "东南风" elif(direction == 4): return "南风" elif(direction == 5): return "西南风" elif(direction == 6): return "西风" elif(direction == 7): return "西北风" except: pass def get_wind_power(arg): try: wind_power = w.read_wind_power() if(arg==0): return wind_power[0] else: return wind_power[1] except: pass def get_rainfall(): try: rainfall = w.read_rainfall() return rainfall except: pass while True: print('风向:' + str(get_wind_dir())) time.sleep(0.5) print('风速:' + str(get_wind_power(0))) time.sleep(0.5) print('降雨量:' + str(get_rainfall())) print('===') time.sleep(1) .. figure:: /_static/products/ledong-module/static/examples/气象站.png :width: 100% :align: center