How does ultrasonic wind measurement work #26
thezenox
started this conversation in
General Dev
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
From time to time people ask me how the ultrasonic measurement of Ecowitts WS actually work. In theory there are a few different approaches to measure wind speed by ultrasonic waves.
The one chosen by ecowitt is time of flight (TOF) and looks like this:
Each transducer is directly connected to two GPIO of the µC for excitation and also wired to a analog multiplexer to select wich transducer is connected to an opamp.

In a measurement, the pins are switched alternating, generating a 40kHz square signal with 8 pulses. Each transducer is drive at a time.
across the transducer the signal looks like this
When hooking up 3 transducers an the output of the opamp, it looks like this:

and a closeup to one response signal. In theory the signal should have a delay of 140µs (~5cm @ 343m/s)

To be able to measure a wind speed of 1 m/s, the system needs to resolve propagation time differences of approximately 420 ns over the 5 cm acoustic path. Achieving this directly with a timer would require a clock frequency in the multi-megahertz range and still provide only limited resolution. A much more elegant approach is to measure the phase shift of the received ultrasonic signal.
At 40 kHz, one period corresponds to 25 µs, so a time difference of 420 ns translates into a phase shift of about 6°. This is well within the resolution that can be achieved by comparing the received waveform against a reference derived from the same oscillator that generated the transmit burst. Rather than detecting the absolute arrival time of the acoustic pulse, the receiver measures the relative phase of the 40 kHz carrier after the signal has propagated through the air.
The oscilloscope traces show a short burst excitation followed by a slowly decaying sinusoidal response. This ringing is caused by the high-Q resonance of the piezoelectric transducers and the narrow-band amplification stage. While the envelope itself contains little timing information, the phase of the individual 40 kHz cycles can be measured with sub-microsecond precision. A common implementation is I/Q demodulation, where the received signal is correlated with both an in-phase and a quadrature-phase version of the local 40 kHz reference. From these two components, the controller can calculate the carrier phase with a resolution far exceeding the system clock period. By transmitting alternately in both directions along each acoustic path and comparing the resulting phase shifts, the controller can determine the wind-induced change in propagation time and calculate the corresponding wind velocity component.
The serial debug output provides some additional insight into the signal processing performed by the firmware. Each acoustic path reports a value labeled Vol_CHx_y, which remains relatively stable and appears to represent the received signal amplitude. The firmware also records minimum and maximum ADC values and performs a simple signal quality check (CH_x mag. normal), likely to detect weak transducers, contamination, or degraded acoustic coupling.
More interesting are the Source_CHx_y and g_UltTimeVxx_y values. These measurements cluster around a nominal value of 3200 counts, with only a few counts of variation between opposite transmission directions. This strongly suggests that the firmware does not operate on absolute time-of-flight values but on a calibrated timing or phase representation. The small differences between channels are then used to derive the wind-induced propagation delay. Additional fields such as datCnt1_3 and datCnt4_2 appear to contain the deviation from a calibration reference, allowing the algorithm to compensate for manufacturing tolerances and mechanical asymmetries between the individual transducer pairs.
Taken together, the debug data indicates a measurement chain consisting of three layers: signal quality monitoring through amplitude measurements, phase or timing estimation for each acoustic path, and a calibration stage that removes static offsets before the final wind vector is calculated.
All reactions