3D Printed Sensor For Finding Wind Direction And Likely Much More

3d printed windvane

Have you ever wondered how an electronic wind vane translates a direction into a unique signal? It seems as though it might be very complicated, and indeed some of them are. [martinm] over at yoctopuce.com has an excellent writeup about measuring wind direction using just a single, easily printed disk and some phototransistors.

Commercial weather vanes often use complicated multi-tracked disks with magnets and reed switches, conductive traces and brushes, or some other means of getting a fine resolution. Unfortunately some of these are prone to wear or are otherwise more complicated than they need to be.

What makes [martinm]’s solution unique is that they have applied previous research on the subject to a simple and durable 3d printed wind vane that looks like it’ll be able to handle whatever global warming can throw at it. The encoder’s simplicity means that it could likely be used in a large number of applications where low resolution position sensing is more than enough- the definition of a great hack!

Adding more tracks or even more disks would enable higher resolution, but the 12 degree resolution seems quite good for the purpose. Such a neat wind vane design will surely be welcome if you want to 3d print your own weather station. Thanks to [Adrian] for the great tip!

35 thoughts on “3D Printed Sensor For Finding Wind Direction And Likely Much More

  1. Yeah, Gray Code! (not grey code) And with an honorable pedigree too (see references).

    It’s like quadrature coding, but with 5 instead of 2 bits.
    But only 30 discernable positions (not 32), for reasons (see above noted pedigree).

    So: trīgintāture coding!

    1. The Gray code is just one of many possible monostrophic codes. It’s easy to configure one to use all the available bit combinations: 0, 1, 3, 2, 6, 7, 5, 4, 0 for a 3-bit example.

  2. “Single-track Gray Code”
    From the Wikipedia article:

    “Norman B. Spedding, however, registered a patent in 1994 with several examples showing that it was possible.[69] Although it is not possible to distinguish 2n positions with n sensors on a single track, it is possible to distinguish close to that many. Etzion and Paterson conjecture that when n is itself a power of 2, n sensors can distinguish at most 2n − 2n positions and that for prime n the limit is 2n − 2 positions.[75] The authors went on to generate a 504-position single track code of length 9 which they believe is optimal. Since this number is larger than 28 = 256, more than 8 sensors are required by any code, although a BRGC could distinguish 512 positions with 9 sensors.”

  3. Nice design!

    I made such wind vane a few years ago, but instead of using optical sensors, which are not very reliable once full of bugs (!), I used magnets and Hall effect FETs. The FETs handled 24V, so no outside electronics was required, only a few wires: 24V allows to have longs wires without problem.

    I used a pseudo-Gray code (only I bit changed at a time, but not in a true Gray sequence). Magnets/sensors arrangement was computed by a Python script (kind of brute force!). With 4 sensors I had 16 positions. I don’t remember how many magnets I used, but the Python script was checking if the arrangement was symetrical, in order to keep the rotor balanced (even if it does not turn at 1000rpm).

    I never really used it, as my 3D printed design was not great. Your project motivates me to reboot mine ;o)

    I will make a web page of what I did so far…

    Thanks for sharing!

    1. Reed Switches may be an alternative to Hall Effect FETS. They would probable need to be perpendicular to the magnet path. I can’t think of how you arranged the magnets. Perhaps on magnet and a cut up piece of a tin can can extend the range of magnetic influence.

      Less problems with wetware bugs to lol.

  4. Could you add a 1:30 gear to a second shaft, put a 2nd 30-way encoder on that, and get 10 bits of measurement? I know, that’s a steep ratio to do in one step. Multi stage gears would suffer increased backlash and backlash undoubtedly would degrade resolution. Not to mention of the main shaft did even 30RPM, the secondary would spin North of 900, so balance issues there. Maybe just paint the pattern on the secondary shaft and use reflective sensors, to keep the moment of inertia and centrifugal forces down?

    Also seems like you could go low-tec, and use a copper track, and replace the sensors with simple brush contacts .. although denouncing that would be probably be challenging.

    1. It’s a wind sensor, so most of the issues mentioned shouldn’t really apply. I mean, if you’re applying it to a different type of sensor, maybe (wheel position?). You’re probably better off just making your encoder bigger than trying to step down and do two of the same 5 bit encoder. Same concept with 10 bits would get you something like 1020 positions, which is more than doing 2 5-bit encoders, and simplifies your life (don’t have to worry about balancing so much, everything moves much slower). You just need to end up making a bigger encoder wheel.

    2. why bother with all that rigamarole?

      If you don’t want to use optics, just use a rotary variable differential transformer: one chunk of iron, two coils, four wires, and easily better than 1 part per thousand resolution.

  5. Another possibility is a magnetic rotary encoder. I used to sell breakout boards for the austrian microsystems AS5045 and associated family of chips. You stick a magnet on the end of a shaft, and put this chip near the magnet, and it gives you 8 or 10 or 12 (depending on the chip) bits of resolution, so you can easily get sub-degree accuracy. It’ll output quadrature encoding if you’re into that or you can read it via an SPI-like interface, and there are a bunch of other options if you work harder. (And it’s fast: it’ll update readings faster than the SPI interface can transmit them.) No contact, no moving parts, nothing to get blocked by bugs or dusty, other than if your dust has a lot of iron oxide in it. There are also other magnetic rotary encoders out there. I just happen to know the AS50xx series best.

          1. My current version is all 3D printed of clear abs, but is not wireless. The new version adds a propeller and hall sensor for wind speed and has slip rings for RS422 data/ power . It retains the hall rotary sensor but uses 3D printed gears to rotate the direction sensor magnet 1:1 geared to the airplane like body.

  6. The wind instrument from the Nexus Marine instrument system, originally by Silva and now by Garmin, has a propeller with a rotating sphere mounted on the prop shaft. The prop and wind vane head rotate on a vertical shaft to orient the prop into the wind. A half-black and half-white sine wave mapped on the sphere’s surface is observed by two quadrature IR transceivers mounted 90 degrees apart that provide simultaneous information about wind speed and wind direction in one instrument. The transceivers each output a 0/5V pulse train of variable frequency and duty cycle. The frequency of the pulse train is proportional to wind speed and atan2() of the two duty cycles determines the wind direction. Very simple and elegant. I provided some documentation for it here: https://hackaday.io/project/179262-logging-sailboat-instrument-data/details.

    1. True! Well caught!
      A typical RVDT is only ratiometric (measures a ratio of amplitude only), and so has a 180 degree ambiguity.
      You need the phase-sensitive cousin, more commonly known as a resolver. Though it’s possible to run them on only 4 wires (common, drive, sin, cos), you’ll most often see them will all six wires brought out. (and, yes, that’s three coils: you do need a drive coil)

  7. I want to build a bluetooth (lower power) weather unit with a wind speed for wind speed and a wind speed for charging the battery, a solar cell for sunlight intensity and a solar cell for charging the battery and a wind direction for wind direction – though if could also charge in a cyclone :)

    Then I have no remote wires to worry about.

    The only thing I worry about with the design here is that the shaft is held by a pressure fit to the wind vane. I worry that this will ware prematurely because the back of the wind vane is not symmetrical height-wize is is going to exert torque on the pressure fits.

Leave a Reply to EwaldCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.