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

Discussion in 'Embedded Systems and Microcontrollers' started by astronaut71, Aug 4, 2015.

  1. astronaut71

    Thread Starter New Member

    Jun 11, 2015
    6
    0
    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.

    Code (C):
    1. /*
    2.  
    3. This code takes the output from an  anemometer and converts it into a wind speed.
    4.  
    5. */
    6. #include <Wire.h>
    7.  
    8.  
    9. //Setup Variables
    10.  
    11. const int sensorPin = A0; //Defines the pin that the anemometer output is connected to
    12. int sensorValue = 0; //Variable stores the value direct from the analog pin
    13. float sensorVoltage = 0; //Variable that stores the voltage (in Volts) from the anemometer being sent to the analog pin
    14. float windSpeed = 0; // Wind speed in meters per second (m/s)
    15.  
    16. float voltageConversionConstant = .004882814; //This constant maps the value provided from the analog read function,
    17. //which ranges from 0 to 1023, to actual voltage, which ranges from 0V to 5V
    18. int sensorDelay = 1000; //Delay between sensor readings, measured in milliseconds (ms)
    19.  
    20. //Anemometer Technical Variables
    21. //The following variables correspond to the anemometer sold by Adafruit, but could be modified to fit other anemometers.
    22.  
    23. float voltageMin = .4; // Mininum output voltage from anemometer in mV.
    24. float windSpeedMin = 0; // Wind speed in meters/sec corresponding to minimum voltage
    25.  
    26. float voltageMax = 2.0; // Maximum output voltage from anemometer in mV.
    27. float windSpeedMax = 32; // Wind speed in meters/sec corresponding to maximum voltage
    28.  
    29.  
    30. void setup()
    31. {            
    32.   Serial.begin(9600);  //Start the serial connection
    33. }
    34.  
    35.  
    36. void loop()
    37. {
    38. sensorValue = analogRead(A0); //Get a value between 0 and 1023 from the analog pin connected to the anemometer
    39.  
    40. sensorVoltage = sensorValue * voltageConversionConstant; //Convert sensor value to actual voltage
    41.  
    42. //Convert voltage value to wind speed using range of max and min voltages and wind speed for the anemometer
    43. if (sensorVoltage <= voltageMin){
    44. windSpeed = 0; //Check if voltage is below minimum value. If so, set wind speed to zero.
    45. }
    46.  
    47. else {
    48.   windSpeed = (sensorVoltage - voltageMin)*windSpeedMax/(voltageMax - voltageMin); //For voltages above minimum value, use the linear relationship to calculate wind speed.
    49.     }
    50. //Print voltage and windspeed to serial
    51.   Serial.print("Voltage: ");
    52.   Serial.print(sensorVoltage);
    53.   Serial.print("\t");
    54.   Serial.print("Wind speed: ");
    55.   Serial.println(windSpeed);
    56. delay(sensorDelay);
    57. }
    58.  
    moderators note : changed code mode from text to c
     
    Last edited by a moderator: Aug 4, 2015
  2. nerdegutta

    Moderator

    Dec 15, 2009
    2,517
    785
    Sorry, but I do not see any photos...

    Are you having trouble uploading?
     
  3. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,397
    497
    Where is anemometer datasheet?
     
  4. astronaut71

    Thread Starter New Member

    Jun 11, 2015
    6
    0
    Yes, here are the photos.
    f11.gif f22.gif
     
  5. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Without knowing more about the anemometer, it would be hard to give you any specific advice. Is there a model number on it?

    I found information for another anemometer, which may give you an idea of what the four wires are for.
     
  6. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,565
    2,379
    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.
     
  7. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,771
    971
  8. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    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...
     
  9. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    FYP:

     
  10. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,812
    834
    Hey! Not ALL programmers approach it that way. Some research the hardware, write a small test program before actually coding the desired program.
     
  11. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,397
    497
    Shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...
     
  12. pwdixon

    Member

    Oct 11, 2012
    488
    56
    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.
     
Loading...