Measuring wind speed

Hi, why do you calibrate with this value on multiply?

Hi, this code is under pulse_counter/total and converts total number of pulses (1pulse per sec =1.492mile/hour) into km:
1.492mph=0.66698368m/s /1000m (km) gives multiplier value.

1 Like

what u think about this anemometer ? should the formula be 1/60 * 1.75 * 3.6 ( for km /h )

ā€˜you can use pulse_counter too since 20 pulses in one second means 1,75 m/sā€™

I am recycling an old Somfy EOLIS / SOLIRIS wind sensor for my DiY-project; this wind sensor still runs smoothly but off course I am still clueless what the wind speed is of one rotation (equal to two pulses). Does anyone knows this value by any change?

nice specs but what is the link?

Iā€™ve read this thread over and over and gained a lot of insight from it - thanks everyone who contributed.

I also have the same issue with a lot of generated noise leading the very high readings (apparently we peaked at 1500mph one day. I must say Iā€™m surprised I didnā€™t notice the wind being that strong!)

Iā€™ve tried the 1uf trick too, but it didnā€™t work. (Didnā€™t make things worse, just not better)

In my case, I think Iā€™ve finally figured out the reason.

First, an example of spurious readings.
image
t

My (generic 4-pulse-per-rotation anenometer from aliexpress) is connected to a nodemcu board and esp8366 that is mounted in a garage. The esp also runs a 12v PIR, rain-tip gauge and three door sensors via esphome. Theyā€™ve worked great for years.

My specific issue is in the timings of that graph. Yesterday I was working in the garage, thus triggering the PIR and door sensors a lot, but I donā€™t think theyā€™re the problem. What I do think affects it is that I had the garage lights on - four cheap LED battens. I also had drills/grinders and saws going. Looking back, I can see I get high readings only when I myself am active in that area.

My belief is that electrical interference is playing merry hell with these readings. Something about pulse_meter, the high number of reads this generates or the wiring is my problem. (itā€™s only 2m of solid copper bell wire)

So Iā€™m going to move the reading to a different esp8266, in a different outbuilding and see if that helps!

@digdilem How is your wind vane required to be wired? ADC or binary? If binary do you have a pull up resistor?

No idea - I just measured it with an ohmeter and I can see it closes 4 times a revolution.

I am using INPUT_PULLUP in my code, because I copied a chunk from earlier in this thread. It IS working perfectly now, however - weā€™re in the middle of a storm and itā€™s producing lots of sensible data.

1 Like

A follow up to this: I set up a new nodemcu and copied the same code block to it for the anenometer. I then moved it to a different shed and set it going.

For the first time ever, Iā€™ve had over 48h without any massive spikes of hundreds of a mile an hour and can now actually read the chart in HA without those spikes throwing the scale out so much.

So for me at least, I think my problem was electrical interference, even with a relatively short 2m wire run.

image

Can you share your code in 1 file, hard to copy from the forums.

Iā€™m surprised and flattered to see this thread continuing, however I just wanted to say somehow I am only just seeing your post, and I will be implementing this fix on my weather station as soon as possible. As fate would have it, I ordered a bag of 0.1ĀµF capacitors off AliExpress just yesterday!

Thank you for sharing this research!

hi, I also use a wh-sp-w01 anemometer (aliexpress) and the datasheet says:
1 turn = 2 pulses (2hz)
m/s=wind speed hz * 0.34

How should I write the code to get the speed in km/h?
Thank you

p.s.: can the condenser also be useful for the rain gauge?

@acuplush

If you read the thread, the code is all located within the first several posts, as well as in my linked GitHub. Nik71git posted the following formula for km/h:

So the code would be:

  - platform: pulse_meter
    pin: 
      number: GPIO14
      mode: INPUT_PULLUP
    name: '${loc} Windspeed Meter'
    icon: 'mdi:weather-windy'
    id: wind_meter
    unit_of_measurement: 'mph'
    accuracy_decimals: 1
    timeout: 5s
    filters:
      - multiply: 0.02 #2.4km/h per rotation so 1 / 60 / 2 * 2.4
      - sliding_window_moving_average: # Helps prevent too many datapoints
          window_size: 15
          send_every: 15
1 Like

thanks, I see someone uses pulse_meter and other pulse_counters, which one works better? Iā€™m using pulse_counter now, is the calibration formula the same?

Hi everyone! I have recently made some significant improvements to both of my personal weather stations (one roof mounted at 27 feet above ground reporting wind speed, direction, and rainfall, and one garden mounted ~5 feet above ground reporting temperature, humidity, pressure, ground moisture, and UV), and I wanted to make my updated code available to everyone.

These updates were spurred as a result of my desire to contribute my weather data through the Citizen Weather Observer Program, or CWOP, which you can read more about here: Citizen Weather Observer Program (wxqa.com)

My full project is located here: esphome-weatherstation/weatherstation-roof.yaml (github.com)

Improvements include:

  • Sensor measurements and statistics compliant with generally accepted scientific standards
    • Wind speed reported from sensor every 2 seconds as an average of the past 2 seconds, which is then used to calculate a 10 minute average.
    • Wind direction calculated as a 10 minute circular mean of the direction reported from the sensor every 5 seconds.
    • Wind gust calculated as the 10 minute max of the windspeed 2 second average.
    • Rainfall statistics as inches during the following periods (required by CWOP):
      • Since local midnight
      • The past 1 hour
      • The past 24 hours

I have also added the code for my garden station, which has hardware based on this project: [Solar Powered WiFi Weather Station V3.0 - Open Green Energy](Solar Powered WiFi Weather Station V3.0 - Open Green Energy but software converted for ESPHome including additional power-saving optimizations.

While I am using the ubiquitous BME280 board for temperature, pressure, and humidity, I am using an LTR390 for UV sensing, which I am very happy with. Read more about that here: Overview | Adafruit LTR390 UV Sensor | Adafruit Learning System

I am updating this thread as these changes relate to wind speed, but I am planning to make a new post when I have time including pictures and additional details including calibration, maintenance, and more. Thank you all for reading!

1 Like

Thank you for the updates and for the shared code!

I see that you send from ESPHome just a few values and the majority of sensors are calculated (in sensosrs.yaml) in Home Assistant.
In my past attempts I always done all the sensors calculation directly on the ESPHome device and sent them to HA (Average wind speed, Gust, etc).

Iā€™ll be glad if you can share your reasoning behind this choiceā€¦ thank you! :slight_smile:
(and sorry for my bad English)

The primary reason is ease of use - it is more difficult to handle time-based statistics on an esp device due to the fact that the device does not keep a history of past values. So, for example, it would be difficult to implement a sensor reporting rain over the past hour when the device does not know what the value was an hour ago. There are methods of tracking to get around this, but given statistics sensors already handle some of this in Home Assistant, I went with that method. I will also grant that wind speed is easier to handle as it is mostly running averages, and I probably could have implemented some of those on the device, but this too was easier as I had already set up statistics in Home Asisstant for the rain sensors.

Just as an fyi, I am currently dealing with an issue where the wind speed spikes during restart or sometimes randomly during the day, this is a known issue here: Statistics sensor logs bad data right after HA restart Ā· Issue #98262 Ā· home-assistant/core (github.com)

Thank you!
Yes I agree that using Statistics in HA is easier.
Iā€™ll go with that route too. :slight_smile:

I have another question, if you donā€™t mindā€¦
What is
ā€˜total_daily_rainfall_adjustmentā€™ and how do you use it?

My code:

globals:
 - id: g_wind_count
   type: int
 - id: g_wind_speed
   type: float
 - id: g_wind_gust
   type: float

sensor:
 - platform: pulse_meter
   pin: D7
   id: wind_speed
   internal_filter: 7ms # max ~25m/s
   timeout: 60s
   filters:
    - multiply: 0.005890486225 # <circumference=0.353> / 60
    - multiply: 3 # the anemometer factor, depends on the dimensions of the cups and arms, and can have a value between 2 and a little over 3
   on_value:
    - lambda: |-
         if (x > 0)
            id(g_wind_count)++;
         if (x > id(g_wind_gust))
            id(g_wind_gust) = x;
         ESP_LOGI ("sensor", "wind_speed = %.3f, cnt = %d", x, id(g_wind_count));

 - platform: template
   name: wind gust
   device_class: wind_speed
   unit_of_measurement: m/s
   accuracy_decimals: 1
   icon: mdi:weather-windy
   update_interval: 60s
   lambda: return id(g_wind_gust);
   on_value:
    - lambda: |-
         ESP_LOGI ("sensor", "wind_gust = %.3f", x);
         id(g_wind_gust) = 0;

 - platform: template
   name: wind speed
   device_class: wind_speed
   unit_of_measurement: m/s
   accuracy_decimals: 1
   icon: mdi:weather-windy
   update_interval: 60s
   lambda: return id(g_wind_count);
   filters:
    - multiply: 0.005890486225 # <circumference=0.353> / 60
    - multiply: 3 # the anemometer factor, depends on the dimensions of the cups and arms, and can have a value between 2 and a little over 3
   on_value:
    - lambda: |-
         ESP_LOGI ("sensor", "wind_avarage = %.3f", x);
         id(g_wind_count) = 0;