Wind Speed test counts 2 on interrupt instead of 1

Hi everyone, I have stripped a weather station code to test wind speed only, and it counts not one increment but two. Obviously a line missing, but have no idea what it should be…if anyone has any suggestions or another simple interrupt counter I could use to work it out that would be great.
Using LoraWan, and the interface extension board. Code below…

#define WIND_SPEED_SENSOR WB_IO1

int windSpeedCount;
int windSpeedSensorPrev;
unsigned long lastWindSpeedTime;

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ SETUP
void setup()
{

Serial.begin(115200);
pinMode(WIND_SPEED_SENSOR, INPUT_PULLUP);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ LOOP
void loop(){

unsigned long timeNow = millis();

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Do all the time +++++++++++++++++++++++++++++++++++++++++++++++++++++++++

// ++++++++++++++++++++++++ Measure Wind Speed ++++++++++++++++++++++++++++++++++
// Time to check wind speed sensor?
if (timeNow - lastWindSpeedTime >= 1) {
lastWindSpeedTime += 1;
}
// Check wind speed sensor
int windSpeedSensor = digitalRead(WIND_SPEED_SENSOR);
if (windSpeedSensor != windSpeedSensorPrev) {
// Sensor has changed
windSpeedCount++;
windSpeedSensorPrev = windSpeedSensor;
}
Serial.println(windSpeedCount);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

}

HI @Andy ,

How fast is the WIND_SPEED_SENSOR pin changing?

I suggest you print these variables windSpeedSensor and windSpeedSensorPrev then see how their values are changing.

Hi @carlrowan, not fast at all, I’m just testing. I have also tried on a rainfall counter (tipping bucket), and get exactly the same result. When I tip the bucket down, it counts 1 and then release, it counts two…it’s at though it’s counting pullup and pulldown…even though the pinmode is as follows…

pinMode(WIND_SPEED_SENSOR, INPUT_PULLUP);

Actually, I think it’s behaving as expected, as it is looking for a change of state, which does happen twice. Apologies. I’ll do more testing.