There’s something wrong with the wind speed on myWeather Shield. I can see the anemometer turning, but the speed is reported as zero. Then it will suddenly jump to 3.9 or 7.2 (always one of those two numbers) and then back to 0, even though the anemometer itself is turning at about the same speed. And I can’t figure it out.
I’m using the Sparkfun code in Photon_Weather_Shield-master. In fact looking at the code, it seems like it should work. Any help with this would be most appreciated. Here’s the relevant code:
void wspeedIRQ()
// Activated by the magnet in the anemometer (2 ticks per rotation), attached to input D3
{
if (millis() - lastWindIRQ > 10) // Ignore switch-bounce glitches less than 10ms (142MPH max reading) after the reed switch closes
{
lastWindIRQ = millis(); //Grab the current time in ms. since th4e device booted.
windClicks++; //There is 1.492MPH for each click per second.
}
} // end wspeedIRQ
float get_wind_speed()
{
float deltaTime = millis() - lastWindCheck; //750ms
deltaTime /= 1000.0; //Covert to seconds
float windSpeed = (float)windClicks / deltaTime; //3 / 0.750s = 4
windClicks = 0; //Reset and start watching for new wind
lastWindCheck = millis();
windSpeed *= 1.492; //4 * 1.492 = 5.968MPH
/* Serial.println();
Serial.print("Windspeed:");
Serial.println(windSpeed);*/
return(windSpeed);
} // end get_wind_speed