Wind speed measurement via pulse counter


I would like to measure the wind speed with an anemometer, which outputs one pulse per revolution with the pulse counter.

If the anemometer delivers one pulse per second, the wind speed is 2.4km/h.

From this you can calculate the radius, which is 0.106133 mm.

Therefore I thought that I am correct with the following code:

  - platform: pulse_counter
      number: GPIO13
      mode: INPUT_PULLUP
    unit_of_measurement: 'km/h'
    name: "${friendly_name} Windgeschwindigkeit"
    icon: 'mdi:weather-windy'
      rising_edge: DISABLE
      falling_edge: INCREMENT
    internal_filter: 13us
    update_interval: 60s
    - lambda: >-
         return 2 * 3.14 * 0.106133 * x / 60 *3.6;

I had actually expected the wind speed in km/h. However, this results in the following:

[D][pulse_counter:160]: 'Wetterstation Windgeschwindigkeit': Retrieved counter: 358.00 pulses/mine
[D][sensor:113]: 'Wetterstation Windgeschwindigkeit': Sending state 3.58145 km/h with 2 decimals of accuracye

The correct result would have been 15.4 km/h.
Can someone help me out and tell me what I’m doing wrong?

Thanks in advance

I get 14.3 km/h - but read this link:

You should start by making sure all your values are interpreted as floating point, otherwise you will get rounding errors when the results are converted internally to integers. i.e.:

    - lambda: >-
         return ( x * 2.0 * 3.14 * 0.106133 ) / 60.0 * 3.6;

But other than that I can’t see any error (that’s obvious to me at least :slight_smile: )


This should be a radius of 6.366 mm

So your lambda should be:

- lambda: >-
         return ( x * 2.0 * 3.14 * 6.366 ) / ( 60.0 * 3.6 );

Or better, to reduce the overhead (why would you do all these calculations every time):

- lambda: >-
         return x * 0.1852;
1 Like

Thank you very much for your answers.

but i think something is wrong. Now I get the following result:

[D][pulse_counter:160]:  'Wetterstation Windgeschwindigkeit': Retrieved counter: 124.00 pulses/mine
[D][sensor:113]: 'Wetterstation Windgeschwindigkeit': Sending state 1.24050 km/h with 2 decimals of accuracy

and this again not correct.

Guys, I found the problem. After a reflash via USB the calculation works. Really strange. Thanks a lot for your support!

Many greetings

Just to be sure: I originally missed this, but the retrieved counter is shown as “pulses/mine” in your results. So do I understand it correctly that the input is pulses per minute?
At first I understood it to be pulses per second, so with one pulse per rotation this would be revolutions per second.
But for an input of pulses per minute with one pulse per rotation and calculating the wind speed in km/h I now think the formula is:


So in that case the lambda should be:

- lambda: >-
         return x * 0.003086;

Or even more simple (you don’t need a lambda with only one multiplication):

      - multiply: 0.003086

Does this give a realistic result?

Thanks for your support!
Maybe I should stop programming my stuff at 3 in the morning. I think I was not quite up to speed.
In the manual of the anemometer was actually the solution.
It said:

“The cup-type anemometer measures wind speed by closing a contact as a magnet moves past a switch. A wind speed of 1.492 MPH (2.4 km/h) causes the switch to close once per second.”

What finally means, if the pulse counter counts for 60s, you only need to divide the 2.4km/h / 60s and get 0.04 as multiplier for the number of pulses.
With this it should fit in my opinion.

Somit ist die Lösung die ich jetzt umgesetzt habe:

   - multiply: 0.04

Greetings & Thanks

1 Like