UPDATE2: yeah ignore the drivel in this post and check this post for correct equation for the anemometer.
UPDATE: So it turns out that I haven’t a clue about how you measure wind speed with an anemometer. I found the datasheet for the sensors, which gives 1.492mph per pulse on the anemometer over 1 second, so I have had to rework the equation and procedure below. So the screen shot below gives wrong values, but is an example of the scripts output.
Just started testing with the Anemometer N96FY. I have the anemometer connected to GPIO pin 18 and 3.3 volt supply. This wind sensor is like a switch and it’s default state is closed, meaning electricity with flow through the anemometer except for two opposing points during a full revolution where the voltage will briefly fall to zero.
I work out the equation to be
wind speed = half the circumference / time taken Wind speed will be in metre per second. Half the circumference is 0.21994 metres.
from time import sleep
import RPi.GPIO as GPIO, os, time
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #pin that the anemometer is connected to
GPIO.setup(25, GPIO.OUT) # pin that the LED is connected to
timer = time.time() # initialise the timer
fast_time = -1 # TODO: future use
cur_time = (time.time() - timer) # time for half a revolution
wind_speed = 0.667 / cur_time # reworked from the datasheet
if wind_speed < 200: # add bounce detection here
if cur_time < fast_time:
fast_time = cur_time
wind_str = "%10.4f" % wind_speed # convert the float number to a string
wind_speed = wind_speed * 2.236936 # apply the multiplier to calculate miles per hour
windmph_str = "%10.4f" % wind_speed
cur_str = "%10.4f" % cur_time
# will print the measurements to screen for each pulse detected
print "Wind Speed: " + wind_str + " m/s, " + windmph_str + " mph, time: " + cur_str
timer = time.time() #reset the timer for the next revolution
GPIO.output(25, not GPIO.input(25)) # alternate the LED state
GPIO.add_event_detect(18,GPIO.FALLING, bouncetime=30) #threaded event, to detect the
# voltage falling on anemometer (pin 18)
GPIO.add_event_callback(18,wind_ping) # tell the event to call procedure above
while True: # loop to keep the program alive
GPIO.cleanup() # reset the GPIO pins when you press ctrl+c