Wind vane calibration with compass

So I have this wind vane that I am using:

It is connected to the Arduino via an analogue pin. It gives different number for the directions it is pointing at.

This wind vane is connected to a weather station that I am working on. I have a compass (HMC5883L) in the station. this is a drawing of the station I have

What I want to do is to get where each value is pointing at like north/south/east/west.

How can I do that?

Thanks in advnace

First figure out the direction of North, from the wind vane location. It is easier to use a magnetic needle compass than an electronic compass for this.

Note which values are output when the wind vane is pointing N, E, S and W.

Write some if statements that cause the appropriate character string to be output when a particular value is read.

Wow I have been looking everywhere for cheap windvane and anemometer components!!! That link is fantastic! Thanks. I also have that compass module but haven't had a chance to start to tie it all together yet. I'll have a play over the weekend and see if I can figure it out.

Have a look at this article about the Maplin wind sensor, and also this one by Max Oberberger.

They both use sensors with the same value resistors fitted, and Max has supplied a link to the datasheet for the weather station sensors.

The datasheet has a table giving resistance values and voltages expected for the 16 different wind directions.

Using the data from the table, you should be able to experiment to find out how it works.

I'd test it indoors first, with no wind, and manually position the vane at the 16 possible directions,

Finding the position that gives you 1kΩ (which is the lowest value when a single resistor is switched in) should help get the orientation correct.

Because of the way the sensor works, the resistance values and voltages change in a complex manner so I think you will need a look-up table to convert voltages to directions.