Thank you so much for getting back with me! I may have gotten “who borrowed whose” code wrong as I was not paying attention to repository dates, but of course borrowed/forked code is the beauty of open source!
I believe I may have also taken your approach of assuming smarter people had figured out a better method, perhaps due to my own lack of confidence, but as I have been working on my station I have been learning a lot about these sensors and perhaps I can contribute some helpful solutions (or be proven wrong!) Over the next couple weeks I would like to get a repository of my full code up on my GitHub, but for now I will share some relevant snippets.
I am currently testing the following configuration for the wind speed:
sensor:
- 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: 0
timeout: 5s
filters:
- multiply: 0.02487
- sliding_window_moving_average:
window_size: 5
send_every: 5
You will notice I am using pulse_meter as opposed to pulse_counter. Based on this post, my understanding is that both these sensors operate very similarly, however pulse_meter offers much better resolution. Both pulse_meter and pulse_counter output data in pulses/minute (per the documentation), so to calibrate this sensor it is only necessary to divide the output by 60 to convert to pulses/second and multiply by the calibration value. I use a sliding_window_moving_average to smooth the data little.
I currently own this anemometer and this wind vane from MISOL Electric, which sells the MS-WH-SP-WS02 kit.
Now a little detective work on the common sparkfun weather station: A quick ImportYeti search revealed that sparkfun is a customer of Elektor. hugokernel on github has documented very well his use of the Elektor weather station (originally from here). This company owns a store where they sell this station, and the manufacturer is listed as “MiSol” so I think it is reasonable to assume that this is the same station as mine, simply imported and rebranded.
The most common datasheet floating around for this kit, which hugokernel provides, references “Argent Data Systems”, which also resells their own import of the station (here is the original Argent datasheet). Curiously, ImportYeti indicates that Argent is supplied by Fine Offset Electronics, and the similar Shenzhen Fine Offset Electronics A supplies sparkfun.
Per these datasheets, the anemometer is calibrated such that:
A wind speed of 2.4km/h (1.492mph) causes the switch to close once per second.
However, I also contacted the seller MISOL Electric on Ali, and they provided the following data:
A lot of times the verbiage in these documents is not great due to translation; if wind speed “data” is “5”, that would correspond to 5 pulses/second. According to this sheet, it appears that the calibration is 0.34 m/s (1.2km/h) at 1 pulse/second, which is half the previous datasheets.
I believe that “switch closing once per second” refers to pulses, which is why I did not divide by two. In sparkfun’s example weather station firmware here they use the following code:
//Returns the instataneous wind speed
float get_wind_speed()
{
float deltaTime = millis() - lastWindCheck; //750ms
deltaTime /= 1000.0; //Covert to seconds
float windSpeed = (float)windClicks / deltaTime; //3 / 0.750s = 4
windClicks = 0; //Reset and start watching for new wind
lastWindCheck = millis();
windSpeed *= 1.492; //4 * 1.492 = 5.968MPH
/* Serial.println();
Serial.print("Windspeed:");
Serial.println(windSpeed);*/
return(windSpeed);
}
They simply multiply pulses/second by the calibration.
I may do some field tests in my car to confirm this data.
Edit: Clarified calibration and added example from sparkfun.