Getting wind speed from an anemometer

Anemometer - Whole setup

Getting Started

This tutorial shows how to use an Ardunio and an Adafruit anemometer to measure wind speed.

Parts List

  • Arduino board (we use an Arduino Uno in this tutorial)
  • Breadboard
  • Wires and alligator clips
  • Anemometer Wind Speed Sensor – Adafruit (product ID: 1733)
  • Wall adaptor power supply 9 volts (or other power source that can provide between 7 and 24 volts)

Hooking it up

The anemometer connects to the rest of the circuits through a single waterproof cable that bundles three wires. These three wires stick out of the end of the cable, each a different color: brown, black, and blue. The brown wire should be connected to the positive power source. The black should be connected to ground, and the blue is the output for the anemometer.

To more easily connect to the Arduino, wrap each wire from the anemometer around the male terminal of a jumper wire. Secure with an alligator clip (Figure 1).

Anemometer - Anemo wiring
Figure 1: Connecting the anemometer wires

Using the jumper wire, connect the brown wire to the Vin pin (called 9V on some boards). Connect the black wire to one of the ground pins. Connect the blue output wire to one of the analog pins. For this tutorial we used pin A0. Figure 2 shows the circuit diagram for the entire assembly. Figure 3 shows the connections on an actual Arduino Uno.

Anemometer - Wiring Diagram
Figure 2: Arduino attachments for anemometer

 

Anemometer - Arduino wiring
Figure 3: Arduino wiring

The anemometer requires a power source between 7V and 24V to produce a measurement. Arduinos use a lower voltage, between 3V and 5V, so the power coming to an Arduino through a USB connection isn’t enough to power the anemometer.

Instead, we’ll use another the external power supply on the board, sometimes labeled X1. This port accepts a female coaxial cable and is appropriate for ranges between 9V and 12V. To use this power source without damaging itself, the Arduino board uses a linear voltage reducer to bring it into the 3V-5V range. However, out anemometer can still access the full voltage if we connect it to the Vin pin (this is why this pin is labeled 9V on some boards).

You can use several sources for the external power supply. One option is to use a standard rectangular 9V battery. However, these batteries are designed for very low current uses for long periods of time (in smoke detectors, for example). The Arduino and anemometer will quickly use up the charge in the battery, leading to fluctuating voltages and bad readings from the sensor. The better option is to buy a wall adapter that produces 9V of steady, higher current power.

Once the wiring is complete and the external power source is connected, the hardware is ready to go. Lets get the software side up and running and measure some wind!

Software

The code for this tutorial takes the voltage output from the anemometer and uses the technical specs from Adafruit to convert the voltage into a wind speed. The anemometer is designed to output voltage between 0.4V and 2V. A value of 0.4V represents no wind and 2V represents a wind speed of 32.4 m/s. The relationship between voltage and wind speed is linear, meaning that each increase of 0.1V represents an increase of 2.025 m/s in wind speed. The following code maps the output values from the anemometer to wind speed using these values.

The Script

Thanks!

Thanks to the rest of the Particle Wave team for their review of the wiring and code for this tutorial. Special thanks to Adafruit forum users shirad and adafruit_support_mike for help in trouble shooting code and hardward, including provided code of their own for comparison and inspiration.

16 thoughts on “Getting wind speed from an anemometer”

  1. Thanks for the write up on this anemometer. I am hoping to use this same anemometer in our corn dryer. What I would like to do is use this set up but have a readout on a small lcd display. Perhaps something like this https://learn.adafruit.com/rgb-lcd-shield. Do you know if it is possible to run this anemometer through the Arduino to an lcd display that will read in mph? I am a beginner when it comes to all this stuff so if you have any advice please explain it to me like I’m 5. 🙂

    1. I think it’s caused by a quirk in HTML showing the ‘less than’ symbol character codes rather than the symbol ‘<' itself. There's probably a system of escape characters that should have been used.
      Have you managed to get the anemometer to work? I haven't with mine. i get the minimum voltage of .40 in the serial monitor but no detection or change when the cups are rotated.

    1. I had to comment out that ‘if’ to get things going, and I never received an answer from the author about the ‘&lt’ reference.

  2. Thanks for that suggestion Chuck about commenting out the if statement. Were you having problems getting output from the device before that?
    I will definitely give it a try. The typo took me a bit to work out as the less than sign but if it works without the line of code, even better.

      1. Thanks, Chuck. I took out the if statement and started to get readings. I think the error is in ‘hard-coding’ voltageMin at 0.4. On my rig, the voltage is measuring 0.38 when the anemometer is at rest so the is will never resolve properly, of course; wind speed will always be zero. The original values were probably worked out against different power supply ratings.
        The next thing I’ll try to think about is calibration against the new voltageMIn value.
        Your thoughts were much appreciated.
        Paul

    1. Hey there Paul. Mind if you share the coding that you have modified here? I do not know how to exclude the ‘If’ statement like you said.

      1. /*

        Anemometer Tutorial

        This code takes the output from an Adafruit anemometer (product ID 1733) and converts it into a wind speed.

        The circuit:

        Created 11 November 2014
        By Joe Burg
        Modified 11 November 2014
        By Joe Burg

        Modified 04 June 17
        By Paul Mckillop
        If statement out and threshold stated for standstill on my sensor

        Hardware instructions and background information can be found at: http://www.hackerscapes.com/2014/11/anemometer/

        Special thanks to Adafruit forum users shirad and adafruit_support_mike for help in trouble shooting code and hardward, including provided code of their own for comparison and inspiration.
        */

        //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(sensorPin); //Get a value between 0 and 1023 from the analog pin connected to the anemometer

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

        windSpeed = (sensorVoltage – voltageMin)*windSpeedMax/(voltageMax – voltageMin) + .38; //For voltages above minimum value, use the linear relationship to calculate wind speed
        /*
        //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);
        }

  3. hi friends

    Its very useful to me. i purchased adafruit wind speed sensor. I want to monitor the wind speed on my location.

    Is there any restriction in using length of wire for this application?

    If installed it on the rooftop, where could be kept the arduino board.

    how much length can be used from sensor to board.? is there any electrical drawback on using lengthy wire?

  4. Hello to Everyone,
    A little help please, I am designing a hot wire anemometer based on arduino. (using a NTC [as temp increases, resistance decreases] thermistor and a another precision resistor as a hot wire source) How do I convert the different voltage values into wind speed of metres per second? Can the above program be adapted? I’m rather new to all this and will be using Arduino Uno. I only need to read from 0 – 10 metres per second, but need to do this accurately in increments of 0.1 metres per second. Any help or comments greatly appreciated

    regards
    Andrew

  5. Can this sensor be used with a Raspberry Pi instead of an Arduino? I have a doubt because this sensor provides Analog voltage output and GPIO pins in Raspberry Pi are digital

Leave a Reply

Your email address will not be published. Required fields are marked *