wind direction sensor is a key component because the sail settings as well as the sailing strategy rely on the direction of the wind. We have chosen an affordable simple and easy to waterproof solution based on a magnetometer (we are actually using a complete IMU, but only u the magnetometer part) and magnets.
wind vane so they rotate with the wind vane over the magnetometer
to be trimmed so that the magnetometer doesn't saturate but the magnetic field created by the magnets is large enough to overpower the earth one.
couple another magnetometer attached to the boat to subtract the magnetic field of the earth.