How to connect Anemometer with Arduino Uno and small program code?

Thread Starter

astronaut71

Joined Jun 11, 2015
6
Hi Im using Anemometer as in the photo . It has 4 wires (black , blue, yellow and red one). I measured the DC Voltage with multimeter and shows that black is the Ground and yellow as output. So according to that connect the yellow to Analog output AO of Arduino and black one to the Arduino GND. I include the sample code that should shows the with speed and output Voltage. The voltage will range from 0.4V (0 m/s wind) up to 2.0V (for 32.4m/s wind speed).

I dont know why there are 4 wires from the Anemometer . I have doubt if I connect good and if the code is ok? Any help? Enclose some photos of the Anemometer and wires.

C:
/*

This code takes the output from an  anemometer and converts it into a wind speed.

*/
#include <Wire.h>


//Setup Variables

const int sensorPin = A0; //Defines the pin that the anemometer output is connected to
int sensorValue = 0; //Variable stores the value direct from the analog pin
float sensorVoltage = 0; //Variable that stores the voltage (in Volts) from the anemometer being sent to the analog pin
float windSpeed = 0; // Wind speed in meters per second (m/s)

float voltageConversionConstant = .004882814; //This constant maps the value provided from the analog read function,
//which ranges from 0 to 1023, to actual voltage, which ranges from 0V to 5V
int sensorDelay = 1000; //Delay between sensor readings, measured in milliseconds (ms)

//Anemometer Technical Variables
//The following variables correspond to the anemometer sold by Adafruit, but could be modified to fit other anemometers.

float voltageMin = .4; // Mininum output voltage from anemometer in mV.
float windSpeedMin = 0; // Wind speed in meters/sec corresponding to minimum voltage

float voltageMax = 2.0; // Maximum output voltage from anemometer in mV.
float windSpeedMax = 32; // Wind speed in meters/sec corresponding to maximum voltage


void setup()
{            
  Serial.begin(9600);  //Start the serial connection
}


void loop()
{
sensorValue = analogRead(A0); //Get a value between 0 and 1023 from the analog pin connected to the anemometer

sensorVoltage = sensorValue * voltageConversionConstant; //Convert sensor value to actual voltage

//Convert voltage value to wind speed using range of max and min voltages and wind speed for the anemometer
if (sensorVoltage <= voltageMin){
windSpeed = 0; //Check if voltage is below minimum value. If so, set wind speed to zero.
}

else {
  windSpeed = (sensorVoltage - voltageMin)*windSpeedMax/(voltageMax - voltageMin); //For voltages above minimum value, use the linear relationship to calculate wind speed.
    }
//Print voltage and windspeed to serial
  Serial.print("Voltage: ");
  Serial.print(sensorVoltage);
  Serial.print("\t");
  Serial.print("Wind speed: ");
  Serial.println(windSpeed);
delay(sensorDelay);
}
moderators note : changed code mode from text to c
 
Last edited by a moderator:

MaxHeadRoom

Joined Jul 18, 2013
28,669
You need to qualify the actual output of the Anemometer, The one I put together I just used a small magnet and a Honeywell SS400 type H.E. sensor.
If you have one like the link by @tshuck you just need two conductors (red & blk).
Max.
 

MikeML

Joined Oct 2, 2009
5,444
Never ceases to amaze me that programmers jump right to writing code before they have a clue as to how their hardware is supposed to work...
 

djsfantasi

Joined Apr 11, 2010
9,160
Never ceases to amaze me that programmers jump right to writing code before they have a clue as to how their hardware is supposed to work...
Hey! Not ALL programmers approach it that way. Some research the hardware, write a small test program before actually coding the desired program.
 

pwdixon

Joined Oct 11, 2012
488
I used and anemometer years ago and it had a chopper disk inside with an optical pickup, ie. an LED and a photo-transistor that was 4 wires.
 
Top