Go Down

### Topic: Anemometer Connection (Read 649 times)previous topic - next topic

#### mertdal77

#15
##### Dec 10, 2018, 03:06 pm
The analog inputs (pins A0 to A5) accept a 0 to 5V signal and convert that to an number between 0 and 1023 using the analogRead() function.  From there you would determine the voltage and apply a scale factor to convert to wind  speed.  Does your manual define the scale factor, maybe in volts per mile per hour or volts per kilometer per hour?

An analog to digital conversion tutorial.
Yes sir, in order find the wind speed (m/s), I have to multiply the volt value with 6.

#### groundFungus

#16
##### Dec 10, 2018, 04:28 pmLast Edit: Dec 10, 2018, 04:31 pm by groundFungus
Here is an example sketch to read the anemometer 0 to 5V output.  You can adjust the reading interval to suit.  Measure the actual analog reference voltage (5V Vcc) and enter where indicated for better accuracy.

Code: [Select]
`// anemometer reading sketch for forum member.  By C. Gouldingconst byte analogInPin = A0;// measure the actual 5V supply voltage// and enter hereconst float analogReferenceVoltage = 5.00;unsigned long windReadingInterval = 1000;  // read wind speed 1 per secondfloat windSpeed = 0;void setup(){   Serial.begin(115200);}void loop(){   static unsigned long windReadingTimer = 0;      if (millis() - windReadingTimer >= windReadingInterval)   {      windReadingTimer = millis();      int adcReading = analogRead(analogInPin);      float voltage = analogReferenceVoltage / 1023.0 * adcReading;      windSpeed = voltage * 6.0;      Serial.print("Wind Speed = ");      Serial.print(windSpeed, 1);  // print wind speed with 1 decimal      Serial.println(" kph");   }}`

Connect as shown.  The 1K resistor adds some protection for the analog input and the capacitor will filter out higher frequency noise for a more stable reading.

#### mertdal77

#17
##### Dec 10, 2018, 05:22 pm
Here is an example sketch to read the anemometer 0 to 5V output.  You can adjust the reading interval to suit.  Measure the actual analog reference voltage (5V Vcc) and enter where indicated for better accuracy.

Code: [Select]
`// anemometer reading sketch for forum member.  By C. Gouldingconst byte analogInPin = A0;// measure the actual 5V supply voltage// and enter hereconst float analogReferenceVoltage = 5.00;unsigned long windReadingInterval = 1000;  // read wind speed 1 per secondfloat windSpeed = 0;void setup(){   Serial.begin(115200);}void loop(){   static unsigned long windReadingTimer = 0;      if (millis() - windReadingTimer >= windReadingInterval)   {      windReadingTimer = millis();      int adcReading = analogRead(analogInPin);      float voltage = analogReferenceVoltage / 1023.0 * adcReading;      windSpeed = voltage * 6.0;      Serial.print("Wind Speed = ");      Serial.print(windSpeed, 1);  // print wind speed with 1 decimal      Serial.println(" kph");   }}`

Connect as shown.  The 1K resistor adds some protection for the analog input and the capacitor will filter out higher frequency noise for a more stable reading.

I am going to try tomorrow and inform you sir, Thank you!

Go Up