How to Measure Wind Speed from a Pulsed Output Anemometer with a Microcontroller
Share
Part 1 of Anabit's Portable IoT Weather Station Series
Measuring wind speed is one of the most common measurements when doing environmental monitoring or building a weather station. Fortunately, many commercial anemometers on the market today make this easy to measure wind speed by providing a simple pulsed output that can be measured with nearly any microcontroller. The key is to measure the timing between pulses and translate that into wind speed.
In this tutorial, we'll show you how to interface a pulsed-output anemometer to a microcontroller, explain how the hardware works, and demonstrate the software used to calculate wind speed.
Understanding Anemometer Output Types
Not all anemometers communicate the same way. The most common output types include:
- Pulse Output (most common)
- Analog Voltage (0-5 V)
- Analog Current (4-20 mA)
- Digital Interfaces (RS485, Modbus, etc.)
This tutorial focuses on pulse-output anemometers.
Types of Pulse-Output Anemometers
There are different types of pulsed output anemometer architecture, below is a list of the four most common:
- Transistor/MOSFET switched output
- Mechanical switch (reed relay)
- Hall-effect sensor
- Optical encoder
Although the method these anemometers use to generate a pulsed output may differ, they all work off the same principle: calculated wind speed by measuring the timing between pulses. Next we will look at two of the pulsed output anemometer architectures in more detail.
How an NPN Pulse Output Anemometer Works
An NPN pulsed output anemometer contains an internal control circuit that drives an NPN transistor. Referring to the NPN pulsed output anemometer schematic below, an external power supply is used to power the anemometer's control circuit. The job of the control circuit is to turn mechanical motion into an equally spaced "switch" that turns the NPN transistor "on" (closed switch, current flows) and "off" (open switch, no current flow). The drain of the transistor is pulled high so that when it is off the output amplitude is high. When the transistor is on the amplitude at the drain is low since the transistor is essentially a short to ground. The frequency of the pulse caused by the transistor being switch on and off is directly related to the wind speed.
There are a couple options for pulling the output pin high. One way is to use a pull up resistor that is connected between the power supply and the drain of the transistor. But with this approach you need to make sure that what ever you use to measure the pulses can handle the power supply voltage. For our demo setup, we use an ESP32-S3 microcontroller which has digital or GPIO pins that can handle logic levels up to 3.3 V. As shown figure 1, we used a pull up resistor to pull the anemometer's transistor's drain to 3.3V. We then used a separate 5V power supply to power its control circuit.
ESP32 microcontrollers have the option to configure their GPIO pins with internal pull-up resistors. To simplify our hardware setup our GPIO pulse measurement pin was configured as an input with an internal pullup so we did not need an external pullup resistor. If you are working with a microcontroller that does not have internal pullup resistors you can also add an external one to your setup, 10kohms will work fine.
As the cups rotate:
- the transistor repeatedly turns ON and OFF
- the output alternates between LOW and HIGH
- every transition produces a digital pulse
Figure 1. Schematic of transistor NPN pulsed output Anemometer
Note that there are also PNP transistor based anemometers. PNP based pulsed output anemometers have the transistor on the high side so the pulse is essentially reversed in polarity compared to the NPN version. When the switch is off or open the output is pulled low and when the switch is on or closed the output is pulled high.
If you are using the same RS-FSJT-NPN Pulse Output Anemometer that I am, below is a table for the wiring.
| Wire | Connection |
|---|---|
| Brown | +5 V Supply |
| Black | Ground |
| Blue | Digital Input |
| Yellow | Not Used |
Mechanical Switch Based Anemometers Need Debouncing
Mechanical switch based anemometers are another common type of pulsed output anemometer. As the cups of the anemometer rotate, the mechanical switch is open and closed. Typically one full cycle of the anemometer translate to one open / close cycle of the switch. Mechanical switch based anemometers are typically two wire, where you apply a voltage source to one end and measure the pulsed output signal at the other wire (often with a pull down resistor connected to the output).
The issue with mechanical switch based anemometers is switch bounce. When a mechanical switch closes or opens its contacts do not transition cleanly. Instead, they "bounce," producing multiple rapid pulses from a single switch closure. These extra pulses can cause significant wind-speed measurement errors. To deal with the issue of switch bounce you can implement a debounce circuit like the one shown in figure 2.
The diode in the circuit serves to protect the signal path from negative voltage swings. The RC network smooths out any bouncing since it resists sudden changes in voltage. You may need to adjust the resistor and capacitor values based on the rise and fall rate of your pulsed signal. From the RC network we get a smoothed out pulse (like a hump) with large rise and fall times. The purpose of the Schmitt Trigger is to reshape the pulse with fast rise and fall times to get predictable edge timing measurements from the microcontroller's GPIO pin.

Figure 2. Schematic of a mechanical switch debounce circuit
A minimal approach to switch bounce is to just employ a RC network, this approach creates smoothed out pulses with large rise and fall times. This approach will work to remove debounce but you risk small timing errors in your wind measurements. These timing errors are due to noise on the edge of the pulse or if your microcontroller's voltage trigger point is not repeatable. As the rise and fall time of the pulse increases these sources of timing error become smaller and smaller.
What the Pulse Signal Looks Like
Depending on the anemometer you are using and how it is configured, with no wind its output will be either be pulled high or low to some constant DC level. But once the wind starts to blow the anemometer will output a pulsed waveform, like the one shown in the Oscilloscope screen capture below in figure 3.
Depending how big the screen is that you are viewing this on, you can see the pulse widths slowly change in size in figure 3. The red arrow points to a pulse that just fits inside two vertical grid lines representing time on the Oscilloscope. The blue arrow points to a pulse later in time that perfectly matches the width of two vertical grid lines. This means the width of the pulse under the blue arrow is slightly larger than the width of the pulse under the red arrow. This shows that the anemometer is slowing down (wind speed is dropping).
Figure 3. Anemometer output waveform captured on an Oscilloscope
The anemometer's pulsed output in figure 3 show us to measure wind speed we need to capture the time between pulses, or more precisely, the time between pulse edges. This time measurement can be done either from the rising or falling edges of the pulses. This is one of the reasons pulsed output anemometers are the most common because all you need to measure wind speed is a single digital pin on a microcontroller or microprocessor to make an accurate wind measurement.
Calculating Wind Speed
To calculate wind speed from an anemometer we need to know its pulse timing to wind speed specification provided by the manufacturer. As an example, the RS-FSJT-NPN anemometer has the following wind speed specifications:
- 20 pulses = one complete revolution of the anemometer's cups
- 20 pulse or one complete revolution in one second equals a wind speed of 1.75 m/sec
There are different wind speed calculations and each one has a specific name. For instance there is average wind speed which is the wind speed over a certain time period like 1 min or 10 min. There is also gust wind speed which is the highest wind speed in a 3 second averaged window over a given time period like 1 min. Refer to the IEC standard linked at the end of this tutorial for more information on different wind speed calculations.
For this tutorial, we will walk through an instantaneous wind speed calculation. Instantaneous wind speed is the wind speed averaged over 1 second of time. Using the wind speed specifications for the RS-FSJT-NPN anemometer, here is how we would calculate instantaneous wind speed:
- Count the number of pulses that occur in a 1 second time interval, let's call this "pulseCount."
- Determine the number of cycles in that 1 second time interval --> cycles = pulseCount / 20
- Calculate wind speed in meters per second: windSpeed (m/sec) = cycles x 1.75 m/sec
- Convert to miles per hour: windSpeed (MPH) = windSpeed (m/sec) x
2.23694
Let's say our anemometer measures 32 pulses in a 1 second time period, the instantaneous wind speed would be:
- Convert pulses to cycles: 32 pulses / 20 pulses per cycle = 1.6 cycles
- Wind speed meter per second: 1.6 cycles x 1.75 m/sec = 2.8 m/sec
- Wind speed in miles per hour: 2.8 m/sec x 2.23694 = 6.26 MPH
Anemometer Wind Measurement Demonstration
Below is a video showing the concepts from this tutorial in action to measure instantaneous, average, and gust wind speeds. You can access the Arduino code used in the video from Github using the link at the end of this tutorial. The following is the hardware setup used in the video:
- Anemometer part number: RS-FSJT-NPN
- Anabit's AIoT SenseNode which features the ESP32-S3 microcontroller
- Single cell Li-ion battery and solar panel to power everything.
- The Serial Bluetooth Terminal Android app was used to read wind speed data via Bluetooth. Note that the code also prints wind speed data to the serial monitor.
How the RS-FSJT-NPN was wired to the AIoT SenseNode:
- Brown wire to the SenseNode's 5V supply.
- Blue wire, which is the pulse output connection, to GPIO pin 11 on the SenseNode. In software GPIO 11 on the ESP32-S3 is configured as an input with a internal pullup resistor to the 3.3V rail.
- Black wire is the ground wire and is connected to the SenseNode's ground plane (GND)
- The Yellow is not used.
Conclusion
Pulse-output anemometers provide an accurate and reliable way to make wind speed measurements. They can be measured with almost any microcontroller or microprocessor because all they require is a single GPIO pin and possibly an external pull down or up resistor. When working with a mechanical switch based pulsed output anemometer, there is some extra hardware setup to prevent false measurements due to switch bounce.
This tutorial is the first installment in our open-source weather station series. Future articles will cover additional environmental sensors including temperature, humidity, pressure, UV intensity, soil moisture, and more.
Additional Resources
- YouTube video of this tutorial which covers in the Arduino code in more detail: https://youtu.be/kDb5f1kYHmo
- Download the Arduino source code from our GitHub repository: https://github.com/anabit-LLC/AnemometerWindMeasBLE
- Link to IEC standard on calculating wind speed: https://webstore.iec.ch/en/publication/69216
-
Learn more about Anabit's AIoT SenseNode: https://anabit.co/products/aiot-sensenode