Hopefully, someone will be able to help you. It is an interesting application. You seem to be the first to ask about it.
You state you have connected the wind direction to A0, so suggest you run
cp /home/pi/Dexter/GrovePi/Software/Python .
and point the wind vane in each of eight directions and record the output value:
- North value=
- North East value=
- East value=
- South East value=
- South value=
- South West value=
- West value=
- North West value=
Then you can design a script to output the closest direction from an unknown value, using a concept similar to the Bloxter example given in the details section of the website.
The anemometer will be more challenging primarily because the information provided does not tell how many revolutions per second correspond to any wind speeds, and second, because your script will need to count revolutions per second.
To test that you are actually reading the anemometer you could try:
(copy below into file)
and slowly turn the anemometer. The printed value should bounce between 0 and 1.
#Sensor connected to D3 Port
sensor = 3 # Pin 3 is D3 Port.
sensor_value = grovepi.digitalRead(sensor)
print ("sensor_value = %d" %sensor_value)
BTW, I do not own a grovepi nor your sensor so I have no idea if this advice will work.
After you figure out the code to count and output revolutions per second (or better per 15 seconds), you will need to take your setup “mobile” (grovepi, anemometer, and laptop to display revolutions).
Have someone drive you on a straight street at a steady, slow speed so you can record the speed and the revolutions value output by your system. Next have them drive at half the top wind speed you want to measure, and lastly have them drive at the top wind speed you want to be able to measure.
With three wind speeds, slow, medium, fast, you can calculate coefficients (a,b,c) for a second-degree curve fit to your data ( windspeed = aRev**2 + bRev + c ).
Program that function, and you are ready to report the current weather conditions!
Now that I think about you hanging out a window trying to hold on to the sensor - NO, NO, NO - don’t do that. Find someone who has a handheld anemometer. No, no, not safe social distancing. Perhaps just indicate that the wind is blowing or not.