Interfacing Anemometer

Hello,

I purchased a weather station from spark fun and am having difficulty getting consistent readings. I figured the best way to explain the issues I am having would be to make a quick video. I am using Zitron's code from the following post:

http://www.arduino.cc/playground/Main/ReadingRPM

Weather station from Sparkfun:

And the code:

//-----------------------------------------------

 volatile byte rpmcount;

 unsigned int rpm;

 unsigned long timeold;

 void setup()
 {
   Serial.begin(9600);
   attachInterrupt(0, rpm_fun, RISING);

   rpmcount = 0;
   rpm = 0;
   timeold = 0;
 }

 void loop()
 {
   if (rpmcount >= 20) { 
     //Update RPM every 20 counts, increase this for better RPM resolution,
     //decrease for faster update
     rpm = 30*1000/(millis() - timeold)*rpmcount;
     timeold = millis();
     rpmcount = 0;
     Serial.println(rpm,DEC);
   }
 }

 void rpm_fun()
 {
   rpmcount++;
   //Each rotation, this interrupt function is run twice
 }

//-----------------------------------------------

Thank you!!!

Reed switch contacts bounce. Sometimes a lot.

Rather than using fan RPM code as your example, you should look for projects like home-made bicycle computers, that are also likely to use reed switch inputs, and have periods more like that of the anemometer.

Also do some googling for "switch debounce circuit" to get some ideas for cleaning up your anemometer input. You may still decide to do it all in software, but there are some cheap and simple ways of getting rid of nearly all the "bogus" pulses in hardware.

Ran

You may also want to consider adding some 1-Wire chips to your weather set up. Not "trivial", but not impossible, either.

There are some very nice temperature sensor chips.

But what made me think of 1-Wire is that there is a 1-Wire counter chip which would take a LOT of work out of monitoring that anemometer.

Once you have one 1-Wire chip in your setup, adding more is easy... they all share one pair of wires.

There are many weather recording enthusiasts on the web using 1-Wire at the heart of their systems. A starting point...

As for bounce: It is a real problem, but I've had several reed switch based anemometers connect directly to the 1-Wire counter over the years (and to rain tipper reed switches, for that matter) without having to do anything special about bounce. Maybe the counter has bounce-ignoring circuits. Not sure. But I know I can connect reed switches to that counter without hassle.

The problem is the 1-wire chip you are referring to has been discontinued. I have the same setup and using interrupts for both the speed and rain and at higher speeds seeing some really odd high readings for wind speed and was wondering what was going on.

... chip has been discontinued...

All the more reason to buy a counter module quickly!

http://www.hobby-boards.com/catalog/product_info.php?products_id=43

(The extra charge for assembled and tested is worth it in my opinion... but isn't it nice to have a choice! Support this supplier... with whom I am not connected, by the way.)

Thanks for all the help everyone.

The anemometer is working great! The debouncing circuit solved my issues:

Here is my current schematic:

And the code:

volatile byte count;

unsigned int duration;

unsigned long timePrevious;

float windSpeed = 0;

int windVein = 0; 

void setup()
{
  Serial.begin(9600);
  attachInterrupt(0, arduino_anemometer, RISING);

  count = 0;
  duration = 0;
  timePrevious = 0;
}

void loop()
{
  
  windVein = (analogRead(windVein));
  if (count >= 1) { 
    duration = (millis() - timePrevious);
    timePrevious = millis();
    count = 0;
    windSpeed = (1492/duration);
    Serial.print(windSpeed,DEC);
    Serial.print(" MPH");
    Serial.print(",");
    Serial.println(windVein);
  }
}

void arduino_anemometer()
{
  count++;
}