This is more a solution than a question. I have been using this anemometer for some time. Compared to an analog anemometer, there is no question that this anemometer is a pain you know where... this is a digital anemometer, every time it turns, it produces a pulse, dealing with this pulse is the story I will try to clarify.
So the Owner's Manual says the following.
V = P(2.25/T)
V = speed in mph
P = no. of pulses per sample period
T = sample period in seconds
To use the T, you must create some kind of timer. I am using Blynk, this app allows you to create timers very easily. If you don't use Blynk, you can use millis(), etc. DAVIS1 works very well, DAVIS2 is just to show you that no matter how much time you record the pulses, you will get the same wind speed. The key part is to divide 2.25 by the number of seconds you are recording the pulses.
Here is the entire code I am using to test it, but first, I debounce the wind pin:
const int WindPin = 4;
volatile int pulse1 = 0; // Davis Anemometer Pulse Tracking
volatile float mph = 0.0; // Davis MPH Variable
bool lastState = LOW; // Wind Pin previous state
bool currentState; // Wind Pin current reading
volatile int pulse2 = 0;
volatile float mph2 = 0.0;
/* Debounced the Wind Pin */
void Davis_ISR()
{
currentState = digitalRead(WindPin); // Read Wind Pin state
if (lastState == HIGH && currentState == LOW)
{
pulse1++;
pulse2++;
}
lastState = currentState; // Save Wind Pin last state
}
/* Per Davis Manual: 2.25 (2250 mS) seconds is the sample period */
void DAVIS1()
{
mph = pulse1 * 0.75; /* timer for 3 Seconds. */
Blynk.virtualWrite(V14, "Davis WS ", String(mph, 2), " (", pulse, ")", "\n");
Blynk.virtualWrite(V16, mph); // Super Chart
pulse1 = 0; // Clear tracking variable pulse1, and start all over again.
}
void DAVIS2()
{
mph2 = pulse2 * 0.375; /* timer for 6 Seconds. */
Blynk.virtualWrite(V20, "Davis WS ", String(mph2, 2), " (", pulse2, ")", "\n");
pulse2 = 0; // Clear tracking variable pulse2, and start all over again.
}
If we set timer 1 to 3 seconds (3000mS) for Davis1, and divide 2.25 by 3, we get 0.75
if we set timer 2 to 6 seconds (6000 mS) for Davis2, and divide 2.25 by 6, we get 0.375
These two functions should produce the same wind speed assuming the wind speed remains constant.
If the wind speed does not remain constant, the wind speed will be different, but is easy to see why, Davis1 will indicate the wind speed sooner than Davis2, right?
You attach the interrupt in setup like so:
pinMode(WindPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(WindPin), Davis_ISR, CHANGE);
Also in setup, here are my two timers:
timer.setInterval(3000, DAVIS1);
timer.setInterval(6000, DAVIS2);