485通信 =================== .. figure:: /_static/products/ledong-module/static/图片/485通讯.png :width: 55% :align: center 概述 -------------------- 485通信模块,连接气象站套件(含风速、风向),将485信号通过串口发送到主控板中。 技术参数 ------------------- 工作电压: VCC 3.3V -5V 模块尺寸:32*48mm 固定安装:2个兼容塑料积木通孔 通讯方式:串口,波特率4800 引脚 定义 ------------------- ======= ======== 引脚 定义 ======= ======== 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