Wind Speed and Direction Sensor
Overview
Dedicated weather station sensor for measuring wind speed and direction, RS-485 communication.
Technical Specifications
Operating voltage: 12V
Baud rate: 4800bps
Wind speed range: 0-35m/s (level 0-12)
Wind direction range: 8 directions
Dynamic response time: ≤2s
Accessories: 12V-DC power adapter, adapter cable, etc.
Pin Definition
Pin |
Definition |
|---|---|
GND |
Ground |
VCC |
Power |
TX |
Serial transmit |
RX |
Serial receive |
Example Code
Weather station code
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 "N"
elif(direction == 1):
return "NE"
elif(direction == 2):
return "E"
elif(direction == 3):
return "SE"
elif(direction == 4):
return "S"
elif(direction == 5):
return "SW"
elif(direction == 6):
return "W"
elif(direction == 7):
return "NW"
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('Wind direction: ' + str(get_wind_dir()))
time.sleep(0.5)
print('Wind speed: ' + str(get_wind_power(0)))
time.sleep(0.5)
print('Rainfall: ' + str(get_rainfall()))
print('===')
time.sleep(1)