Problems reading Anemometer


I’m triying to read values from an anemometer. I was using this code in UNO board, but I move my project to MKR. the problem is qhen I compiled the code but give me some errors in interrupts.

#include <math.h> 

#define WindSensorPin (5) // The pin location of the anemometer sensor 

volatile unsigned long Rotations; // cup rotation counter used in interrupt routine 
volatile unsigned long ContactBounceTime; // Timer to avoid contact bounce in interrupt routine 
float WindSpeed; // speed miles per hour 

void setup() { 
  pinMode(WindSensorPin, INPUT); 
  attachInterrupt(digitalPinToInterrupt(WindSensorPin), isr_rotation, FALLING); 
  Serial.println("Davis Wind Speed Test"); 

void loop() { 
  Rotations = 0;  // Set Rotations count to 0 ready for calculations 
  sei();          // Enables interrupts 
  delay (3000);   // Wait 3 seconds to average 
  cli();          // Disable interrupts 
  /* convert to mp/h using the formula V=P(2.25/T) 
     V = P(2.25/3) = P * 0.75 */
  WindSpeed = Rotations * 0.75;  
  Serial.print(Rotations); Serial.print("\t\t");Serial.println(WindSpeed); 

// This is the function that the interrupt calls to increment the rotation count 
void isr_rotation () { 
  if ((millis() - ContactBounceTime) > 15 ) { // debounce the switch contact. 
    ContactBounceTime = millis(); 

Does anybody played with anemometer and MKR boards? any idea what I’m doing wrong?



What are you actually using as the source of the anemometer ?

Some have a specific voltage requirement and the MKR is a 3.3 volt based board as opposed to the UNO which is a 5 volt board.

Readings need to be accounted for that difference and sensors need to be compliant in that area.