Wind Direction Sensor

Hi all.

I am in the process of making an Arduino powered Weather station, now it's time for Wind Direction.

I have what i think is a MAPLINS type Wind Vane which has 8 Reed switches, all with different resistor values, does anyone know how this works, i have had it on a DVM and there seems to be not only a signal from each Reed switch, but also from in between the switches, ie the magnet is making two switches simultaneously, can this be right?

Help would be appreciated.

Regards

Ray

Sensor in the wind vane diagram could be the same. It has 16 possible positions.
If it's highest resistance is ~40k (as in the editor table), then connect the sensor to an analogue input and ground, with a ~20k pull up resistor. And read the analogue values in all 16 directions.
map() or if() statements could translate those values into wind directions.
Leo..

Hi Wawa.

Many thanks for the info, it looks identical to me. Just one other thing, my weather vane has 4 wires, Red, Black, Green & Yellow,would i be right in saying to disregard the Red & Yellow, use the Black for Ground and the Green for signal, if thi is right would you put the resistor on the Ground or the Signal, i have uploaded a ping, this is how i have been connecting it.

Ray

This page seems to have the right documents for your sensor.
Leo..

Hi Wawa.

Many thanks for the info, i am slightly confused and would just like to clarify a couple of items -

  1. In the first link you gave me, it does indeed show a similar PCB with 16 positions with the highest resistor value of ~40k where the second link you gave me shows the highest value at ~ 120k.

  2. You mentioned using a ~ 20k pull up resistor, when actually the 2nd link you gave me shows a 10k pull up resistor, not being an expert on these things i just need a little clarification, my sketch now works about 80%, the problem i am having, i think, is that some of the voltage values given by the sensor are so close, i am getting strange readings on the LCD, can these resistor variables do that?

Regards

Ray

ps Maybe my sketch is c--p

I don't know what's inside YOUR sensor.
You should measure it's resistance in all wind directions.
Value of the pull up resistor is not critical, but you get the best separation in values from the A/D if the pull up resistor value is about half of the highest resistance of the sensor.

Then you have to use a test sketch to see the A/D values you're getting in all 16 directions, so you can use them in the if() statements of the final sketch.
Leo..

Hi Wawa

Thanks for taking time out to help me.

I have measured the resistor values on my sensor, 16 positions i have uploaded a comparison with what's on the internet, and what i am getting in reality, please see if you can see anything obvious.

Regards

Ray

Hi Ray,

I use the wind direction sensor from Maplin in my weather station also. You can find my code & schematic here. I used a 4K7 pull-up resistor fed from an Arduino pin so that I can enable the pull-up for an instant, take the analog reading & disable the pull-up, to save battery power.

When we need replacements in the future, I'm not sure where we can get them. Other eBay vendors offer them, but not at such a low price.

Thanks PaulRB.

Your sketch is well out of my league, as i am still learning this craft, i have tried your 4.7k resistor and Wawa's 50% of maximum installed Resistor (60k) neither has worked as each time i run the sketch with the different resistors the actual sensor does not point to where the LCD say's it is, would you kindly look at my sketch, and pick some holes in it please ?

Does your Maplin sensor have a NORTH position, mine is not marked?

Regards

Ray

Yes, I'll look at your code. You'll have to post it first, of course! See forum guidelines in sticky post for how to do that.

My sensor is marked with all 4 compass directions, at the top of the non rotating body. You can see "S" if you zoom in on this pic.

Hi Paul RB.

I must be going blind, yes mine's the same, i have never noticed that before, i am posting my sketch now.

Ray

Hi.

I need help with my Wind Vane sketch for my Weather Station, it is powered by Arduino UNO R3, the sensor is ex, MAPLIN, i have got i think 80% of the sketch, there is a 20,4 i2c LCD include in my weather station.

The sensor does pick up 16 positions as per the heading of a compass, my problem is the sensor does not seem very sensitive, some of the voltages are so close together, i think the sketch is not good enough to give an accurate read out.

eg, East gives me 0.5 volts and reads East, East North East gives me 0.41 volts, but the LCD still registers East ?

Thanks for your anticipated help.

Ray

//Include Libraries.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20,4);  
 

float rainfall = 0;
int rain_sensor = A0;                //set rainsensor to pin A0

void setup() {
  
digitalWrite(rain_sensor, LOW);     //set pin A0 low
pinMode(rain_sensor, INPUT);        //set pin A0 as an input

lcd.init();                         // initialize the lcd    // Print a message to the LCD.
lcd.begin(20,4);
lcd.backlight();
lcd.clear();
lcd.setCursor(0,3);
lcd.print("Rainfall      ");
lcd.setCursor(12,3);
lcd.print(rainfall);
lcd.print(" mls");

}

float get_rainfall()

{
 a:  if (digitalRead(rain_sensor) == HIGH)
          {
           return 2.8;
          }     
 delay(2000);         
 goto a;           
}

void loop() {
  
get_rainfall();
rainfall = rainfall + get_rainfall();
lcd.setCursor(12,3);
lcd.print(rainfall);
lcd.print(" mls");

delay (2000);

}

Need help with Wind Vane sketch?

Is this a question or a statement?

If it is a question, how are we supposed to know whether or not you need help?

If it is a statement, you really should fix your thread title to remove the incorrect punctuation.

the sensor is ex, MAPLIN

That link does not work. When you are using specific hardware, you should post a link to it.

digitalWrite(rain_sensor, LOW);     //set pin A0 low

Why do you need to do that? By default, pins are INPUT and LOW.

float get_rainfall()

{
 a:  if (digitalRead(rain_sensor) == HIGH)
          {
           return 2.8;
          }     
 delay(2000);         
 goto a;           
}

Get rid of the goto crap that is emulating a while statement. Look like a real programmer and use while, IF that is appropriate.

Nothing in your code reads anything expect a rainfall sensor. There is NOTHING in the code that relates to your question/statement.

Thanks for the reply.

Threads merged.