Weather Garden Practice2: Wind anemometer test

YouTube Preview Image

These days, I am keen on the selection of wind speed sensor due to the previous one always out of stock. I wrote to Timothy Shaw to give me some advise to choose and test the wind anemometer. He suggested me to use wind anemometer for N96GY  as backup option. I bought one form Maplin and started to test it. Firstly, I need to connect it with Arduino then get a reading every time it spins. Secondly, I have to do some maths to work out how many times it spins in a give timeframe.

The test method is very simple, operator just needs to have a fan with 3 or more speed options and blowing wind anemometer in different speed option respectively.

22    23

During the process of wind anemometer test, I became successful after many failures. For instance, I have tried many test code but could not get the right spins speed value from Arduino’s serial monitor.

Version 1

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}

void loop() {
// put your main code here, to run repeatedly:
int val = analogRead(A4);
Serial.println(val, DEC);
delay(1000);
}

Outcome:

1023

1023

1009

1023

1023

1023

974

……

Version 2

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(2000);

pinMode(2, INPUT);
attachInterrupt(0, count, CHANGE);
}

int i = 0;

void count() {
i++;
}
void loop() {
Serial.println(i);
i = 0;
delay(5000);
}

Outcome:

0

0

0

0

0

……

Finally, I got the right spins speed value by modifying  the electric circuit(add a 10K resistance) and Arduino code.

20         21

Code:
uint16_t start = 0;
volatile uint16_t rev = 0;

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(2000);

start = millis();
pinMode(2, INPUT_PULLUP);
attachInterrupt(0, count, CHANGE);
}
void count() {
rev++;
}
void loop() {
Serial.println(rev);
rev = 0;
delay(5000);
}

Outcome:

First gear

44

64

55

53

41

36

26

33

42

……

Second gear:

122

105

95

105

111

113

……

Third gear:

164

168

160

167

185

164

……

In the next step, I will try to figure out how many times the wind sensor spins in a give timeframe.