Looking for advice on a pulse anemometer

Hello! This is my first post in this forum. I have recently been working on a project for a home weather station. I have some difficulty with the anemometer.

I bought a pulse NPN anemometer like this one HERE .
According to the specifications, it must supply 20 pulses of propeller rotation, which is equivalent to 1.75 m / s wind speed.

I connected it according to the instructions:

  • Brown: VCC (positive) power to 5V on Arduino Mega
  • Black: GND to GND on Arduino Mega
  • Blue: NPN Output (require pull up resistor to logic voltage, recommended 5.1K Ohm) to digital pin 2 on Arduino Mega

...and uploaded this sketch:

#define READ_TIME 1000                    // in ms
#define WIND_SENSOR_PIN 2                 // wind sensor pin
#define WIND_SPEED_20_PULSE_SECOND 1.75   // in m/s this value depend on the sensor type
#define ONE_ROTATION_SENSOR 20.0

volatile unsigned long Rotations;         //Cup rotation counter used in interrupt routine

float WindSpeed;                          //Speed meter per second

unsigned long gulStart_Read_Timer = 0;

void setup(){
  Serial.begin(9600);
  pinMode(WIND_SENSOR_PIN,INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(WIND_SENSOR_PIN),isr_rotation, CHANGE); //Set up the interrupt

  Serial.println("Pulses:\tm/s");
  sei();                                  //Enables interrupts
  gulStart_Read_Timer - millis();
}

void loop()
{
  if((millis() - gulStart_Read_Timer) >= READ_TIME)
  {
    cli();                                //Disable interrupts
   
    //convert rotation to wind speed in m/s
    WindSpeed = WIND_SPEED_20_PULSE_SECOND/ONE_ROTATION_SENSOR*(float)Rotations;
    Serial.print(Rotations); Serial.print("\t\t"); 
    Serial.println(WindSpeed); 
    
    sei(); //Enables interrupts

    Rotations = 0; //Set Rotations count to 0 ready for calculations
    gulStart_Read_Timer = millis();
  }
}

// This is the function that the interrupt calls to increment the rotation count
void isr_rotation()
{
    Rotations++;
}

Everything worked perfectly, except for one problem: the values ​​were doubled (rotations and m / s). I modified the sketch and found that for each full revolution of the propeller, Arduino counts 40 instead of the specified 20 pulses!
What I'm wondering now is, does the anemometer really make 40 pulses, or is there a problem with my circuit? Unfortunately, I do not have access to an oscilloscope to see exactly what the signal looks like. Isn't there a bounce effect or something?

Of course, I can also modify the sketch so that it works correctly with 40 pulses, but will they be real, or will they just be noise that will distort the results at higher speeds ?!

I will be glad to hear your advice!

I wouldn't be surprised if there is bounce, but it's odd that it's exactly double what you expect.

Note though that you should set rotations to zero when interrupts are off.

attachInterrupt(digitalPinToInterrupt(WIND_SENSOR_PIN),isr_rotation, CHANGE);

should be

attachInterrupt(digitalPinToInterrupt(WIND_SENSOR_PIN),isr_rotation, FALLING)
3 Likes

Yes, it nails them to 40 pulses each rotation. It even keeps 20 in half and 10 in a quarter rotation. But if it was a bounce, shouldn't it count 2, 4, 6, 8, etc.? Because I did an experiment, and when I turn very slowly, I get 1,2,3,4,5 ...

I will check this way too, thanks!

@PaulRB has nailed it - it's not bouncing at all, which is nice.

There are 20 pulses for each rotation. Each pulse consists of a rising edge and a falling edge. 40 edges per rotation. With CHANGE, the Arduino is counting the edges. With FALLING or RISING, it counts only the falling or rising edges of which there would be 20 per rotation. So it would be fine to use CHANGE and compensate in your code. That technique might in theory give a more precise result in low wind speeds, but in practice probably not more accurate unless you can accurately calibrate the sensor in a wind tunnel or something.

Yes, of course, things already seem absolutely logical! I did not think of this doubling effect when using CHANGE. Thanks again!

P.S. I have а calibrated hand-held anemometer. I will use it to check how reliable the data is from this one as well...

I would be interested to know the results.

Also interested in the quality of the device. Is it plastic/metal? How durable does it feel?

I currently use an old and very inexpensive anemometer. It is made of very thin plastic and, being exposed outdoors, that plastic is probably becoming increasingly fragile. I have replaced the bearing once and replacing that a second time may damage it because of the force required to remove the old bearing. So I am looking out for a suitable replacement when the time comes.

My old anemometer contains a very simple circuit, just a magnet and reed switch. This has enabled me to make a very low power circuit to measure and record wind speed, which can last for many months on batteries. I want to continue to power with batteries in future, so I would also be interested to know how much current your anemometer consumes at different wind speeds.

I’m

With a little delay - the results: Changing "CHANGE" with "FALLING" worked as expected! Thanks, PaulRB!

Now for the anemometer: The workmanship looks good. It is plastic, polycarbonate. It looks strong and durable. It is driven by a very light breeze - below 1 m/s. I like this anemometer because the pulse signal will be much more accurate than simple anemometers with a single reed switch. Unfortunately, it will require more power, but I will not use batteries anyway. I had found its consumption somewhere, but now I can't.

I have seen the same anemometers used on photovoltaic fields and stations without changing for years in bright sun and strong wind. This didn't seem to affect them much. I hope mine will last at least a few years. In this case, the price will be acceptable.

@stoyanoff78 Thanks for the "review" of your anemometer!

The accuracy of a pulse anemometer is related to the quality of the components and and precision of the engineering of the cups and bearings.

Pulses are simply pulses and indicate how many revolutions have been made in a given time. The method of creating the pulses has nothing to do with the accuracy of the anemometer.

We don't know what generates those pulses in your anemometer, but we can guess it is not a simple reed switch, otherwise there would be no need to supply power to it. It could be IR or Hall effect sensors for example. The advantage of those would be fewer moving parts to wear out or fail. The disadvantage is they use more power.