Grove Pi and wind sensor

Hi all,
I am new in the the community and my knowledge about grove Pi, Python, etc are very weak.
I bought a RPI ZERO WH and a grove Pi with BME680. Thank’s to a friend of my I could get correct value and record to a Mysql.

I also bought a wind sensor, for direction and anemometer. Connect the anemometer to the D3 and wind direction to AO, as if I understood the first one give a digital signal and the other one is analog.

My grove pi is update to Firmware 1.4.0.
Does anyone have a very easy python script to get the value from wind?
Thank you in advance.
Alessandro

1 Like

Welcome in!

My question would be "does the Grove Pi even support the Pi zero? (Since it is roughly the same as a Pi-1 on a smaller PCB.)

Hi, to be honest I guess grovepi support RPIzero.

1 Like

Yes it does. We even had a GrovePi0 at one point

For the wind sensor, do you have a link to the specific sensor ? I’m fairly certain we don’t have example code cause I don’t think we have this particular sensor.

1 Like

Hi, sure!

with this

1 Like
1 Like

Hi Cyclicalobsessive these are exactly the ones I bought together with the GrovePi0. The point is that I do not find any template to start with.
regards

1 Like

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

cd ~
cp /home/pi/Dexter/GrovePi/Software/Python .
python grove_analog_read.py

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:

cd ~
nano grove_digital_3_read.py
(copy below into file)
cntrl-x
y, return

 

then type:

python grove_digital_3_read.py

 

and slowly turn the anemometer. The printed value should bounce between 0 and 1.

 
 

grove_digital_3_read.py

import time
import grovepi

#Sensor connected to D3 Port 
sensor = 3		# Pin 3 is D3 Port.
grovepi.pinMode(sensor,"INPUT")
while True:
    try:
        sensor_value = grovepi.digitalRead(sensor)

        print ("sensor_value = %d" %sensor_value)
        time.sleep(.5)

    except IOError:
        print ("Error")

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!

CAUTION

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.

2 Likes

Waou, thank you for your help. Concerning the digital reading the value bounce between 1 and 0 as you said. Concernig the analog port I am confused because the values printed out at the monitor are random between 400 and 1013 or something like that. And this without move the wind vane. Any idea about this?

I go further with the anemometer. Actually I do not have a lot of other things to do :slight_smile:

thank you.

1 Like

Does this happen at every wind direction or only one?

(The reason I ask is that there might be a point where the value abruptly changes from the maximum to the minimum or vice versa.)

Another thing to try is to take five readings 0.1 second apart and print out the average reading - does the average jump around? Does the average value change smoothly with the direction of the vane?

One way to find average:

import numpy as np
.
.
.
try: 
    readings=[]
    for i in xrange(0,5):
        readings += [grovepi.analogRead(sensor)]
        sleep(0.1)
    sensor_value = np.mean(readings)
.
.
.
1 Like

at the moment I screenshot, the wind vane doesn’t move at all.
image and these are random value

1 Like

Perhaps try unplug, replug connectors
Perhaps try using different analog port? (change software “pin” to match new port)

1 Like

I am afraid I have a trouble with the image . I am going to check the weld I have done.
When I unplug wire from A1 (I changed as you suggest) value printed are roughly constant.
I check this and back to you by tomorrow.

1 Like

After a series of test I think my shield (the one in the last post) give me interference with analog and digital values.
I just bought some extra composer, and an analog/digital shield.
Once I get it, I will test this configuration directly on the RPI GPIO. So I think I will not give you any news, before getting my delivery. I will let you know.
Thanks

2 Likes