Wind speed measurements

Wind speed measurements

Today we present an application for the Yocto-RS485-V2, for which we provided assistance to one of our customers. The aim is to collect data measured by a Gill WindSonic ultrasonic wind sensor, and extract key values in accordance with World Meteorological Organization (WMO) standards.

The wind sensor provides wind speed and direction measurements at 4 Hz. These are read out in real time via an RS-485 bus by a specialized device, an Observator OMC-139 display.

The aim of this application is to add to the RS-485 bus, in parallel with the display, a Yoctopuce module that listens to the measurements and stores them in its internal memory. Once a day, a small script downloads the measurements from the data logger and calculates the relevant averages and maxima. The script produces a CSV file that can be opened in Excel, for example, including all measured and calculated values to attest to the figures produced.

LOur customer's wind sensor, atop a 17m50 mast
LOur customer's wind sensor, atop a 17m50 mast


Recording measurements

For meteorological statistics, the values of interest are the sliding averages of wind speed and direction, according to different averaging periods: three seconds, 2 minutes, 10 minutes. We want to calculate all these averages over a measuring window that moves with a granularity of 0.25 seconds, in order to precisely identify the daily maximum for each of these periods. We'll therefore ask the module to record at a frequency of 4 Hz, and we'll calculate the sliding averages in the Python script that will retrieve them from the data logger.

To activate data logging on the RS485 bus, we'll use the job system described in the documentation and in some previous articles.

The format of the data produced by the ultrasonic wind sensor is as follows:

Q,226,006.60,M,00,<ETX>18,61872,07/09/2024 16:15:46 Q,239,008.26,M,00,<ETX>1A,61874,07/09/2024 16:15:47 Q,240,008.69,M,00,<ETX>1F,61875,07/09/2024 16:15:47


The numbers we're interested in are the first two: wind direction and wind speed. So we'll be able to put on the Yocto-RS485-V2 an automatic RS-485 stream decoding job that looks like this:

expect "Q,($direction:INT),($speed:FLOAT),M,00,.*"



But there's a subtlety: if the speed is less than 0.05 m/s, the direction is not provided:

Q,182,000.06,M,00,<ETX>13,254,14/10/2024 10:34:19 Q,,000.04,M,00,<ETX>2A,254,14/10/2024 10:34:20 Q,099,000.13,M,00,<ETX>1C,254,14/10/2024 10:34:20


So we'll add a second rule to our job to deal with this case:

expect  "Q,,($speed:FLOAT),M,00,.*"
compute "$direction = -1"



You'll have noticed that in the rules above, we haven't assigned the measured values directly to genericSensor1 and genericSensor2, but have stored them temporarily in direction and speed variables. Indeed, one difficulty encountered in this application is that the wind sensor sends measurements at around 4 Hz, with a small tolerance that depends on its own clock. However, if the Yoctopuce module records the last measurement received at exactly 4 Hz according to its own clock, the very slight (variable) offset of a few tens of ppm between the two clocks sooner or later leads to a duplication of measurements. Indeed, if the new measurement has not arrived on time, the previous measurement is recorded twice. This can significantly distort the calculation of maximum bursts. We therefore use a synchronous task to store the measurements, ensuring that each value read is only used once:

assert  "isset($speed)"
compute "$1 = $direction"
compute "$2 = $speed"
assert  "$speed >= 0"
compute "$direction = -1"
compute "$speed= -1"
sync    250



You can load the complete job file here.

Of course, you also need to activate the recording of genericSensor1 and 2 at the 4/s frequency. At this frequency, the recorder can keep a history of around 3 days for both measurements, after which the oldest data will be deleted.

Measurement analysis script

The small program that retrieves the recorded measurements and calculates all the rolling averages is written in Python, based on the example Prog-Datalogger in our library. Compared with the basic example, this version has the advantage of first indicating at start-up for which days data are available in the logger, and then offering to select a particular day for export:

Search for available data...
Data available from 13-10-2024 20:00:00 to 16-10-2024 09:40:16.25
- Type 1 to export data for day D-1
- Type 2 to export data for day D-2
- Type 3 to export data for day D-3
- Type Q to quit
Your choice:


After selecting a day, the program downloads the data progressively and then performs the calculations:

Loading speed measurements     : 345600 measurements loaded
Loading direction measurements : 345600 measurements loaded
Wind speed data available from 00:00:00 to 23:59:59
Direction data available from 00:00:00 to 23:59:59
Calculation of rolling averages: completed
(...)
Max over 3.0s: 12.345 m/s (44.442 km/h) at 68.0 deg on 13-10-2024 10:23:12
(...)
File Wind Gill 13-10-2024.csv created


The program for calculating rolling averages is a bit tricky, as it takes care to handle any missing data at any time (e.g. in the event of transmission loss), but on the basic principle, it's just a matter of calculating several averages in parallel with different periods. To calculate the average wind direction over a given period, we calculate a vector average of the wind speed vector, breaking it down along the North/South and East/West axes. You can view the program's source code and download it directly from GitHub.

Conclusion

In this application, the Yocto-RS485-V2 added a data logging function to a system that didn't have one. Post-processing in Python then made it possible to present the data in the optimum form for the application.

And if you're interested, you can find the real-time data from this wind sensor on Twitch via the Meteo17aunis website.

Add a comment No comment yet Back to blog












Yoctopuce, get your stuff connected.