Common Wind Speed and Direction sensors.

marks

Senior Member
Recently my weatherstation gave up, I do miss knowing the wind direction.
The schematic shows how to interface commonly found Anemometer and Wind Vane.
Always interesting to doing some testing you get to find out how good things are lol.
These sensors use glass reed switches they work quite well with no problem of contact bounce.
The Anemometer has two magnets and hence the contact will close twice in one revolution.
The Wind Vane has eight reed switches each contact will close over 45 degrees as the magnet passes over,
although their are 16 possible values these mid positions are a waste the magnet has to be precisely between the
two reed switches for both contacts to close so only operate over 1 degree so its only worth bothering with the eight postions.
Code:
#terminal 19200
SETFREQ M16

SYMBOL WindDirection      = W2 'b4,b5
SYMBOL WindSpeed          = W3 'b6,b7
SYMBOL Character1         = b8
SYMBOL Character2         = b9
SYMBOL Character3         = b10
SYMBOL Character4         = b11
SYMBOL Character5         = b12

                  '  ohms     ADCvalues         ||ohms
EEPROM  10,("W ") ' 120   K   070 
EEPROM  20,("NW") '  64.9 K   123        Wnw  42.2  K   178
EEPROM  30,("N ") '  33   K   217        Nnw  21.88 K   295
EEPROM  40,("SW") '  16   K   365        Wsw  14.12 K   395
EEPROM  60,("NE") '   8.2 K   532        Nne   6.57 K   588
EEPROM  80,("S ") '   3.9 K   710        Ssw   3.14 K   755
EEPROM  90,("SE") '   2.2 K   820        Sse   1.4  K   883
EEPROM 100,("E ") '   1   K   918        Ene     891    929   
                  '                      Ese     688    958
                  
Main:
 ReadADC10 C.0,WindDirection 
 WindDirection = WindDirection/100+1*10
              
 	  READ WindDirection, Character1                              
 	   INC WindDirection
 	  READ WindDirection, Character2

COUNT C.1,24000, WindSpeed ' count pulses in 6secs (at 16MHz)
WindSpeed = WindSpeed *4   ' one pulse per second  =  2.4km/h

'COUNT C.1,24000, WindSpeed ' count pulses in 6secs (at 16MHz)
'WindSpeed = WindSpeed *2**36409 '(*1.1111) one pulse per second = 0.66667m/s

'COUNT C.1,20000, WindSpeed ' count pulses in 5secs (at 16MHz)
'WindSpeed = WindSpeed *8**24445 '(*2.984) one pulse per second = 1.492mph

BinTOASCII WindSpeed,Character3,Character4,Character5 
 IF  Character3 = "0" THEN : Character3 = " " : ENDIF ' leading zero blanking  
  Sertxd (13,10, "winds    ",Character1,Character2,32,Character3,Character4,".",Character5," km/h") ' 0.4 resolution

GOTO main
 

Attachments

marks

Senior Member
Code added so we can test the ADCvalues of our WindDirection Sensor.
Will be displayed on both the Terminal and Oled Display!
Code:
	#picaxe 18m2 'Test WindDirection ADCvalues   							
	#terminal 19200   	
       '          DB7  = B.7	
       '          DB6  = B.6	
       '          DB5  = B.5	
       '          DB4  = B.4	
       '          DB3  = B.3	
       '          DB2  = B.2	
       '          DB1  = B.1		
       '          DB0  = B.0
       SYMBOL Rx       = C.5
	 SYMBOL E        = C.6			                  
 	 SYMBOL RS       = C.7			                  
	 SYMBOL senddata = pinsB	 
	 SYMBOL index    = b0
	 
	 SYMBOL WindDirection      = W1 'b2,b3
       SYMBOL Character1         = b6
       SYMBOL Character2         = b7
       SYMBOL Character3         = b8
                                                         
                  '  ohms     ADCvalues         ||ohms
'EEPROM  00,("W ") ' 120   K   070 
'EEPROM  10,("NW") '  64.9 K   123        Wnw  42.2  K   178
'EEPROM  20,("N ") '  33   K   217        Nnw  21.88 K   295
'EEPROM  30,("SW") '  16   K   365        Wsw  14.12 K   395
'EEPROM  50,("NE") '   8.2 K   532        Nne   6.57 K   588
'EEPROM  70,("S ") '   3.9 K   710        Ssw   3.14 K   755
'EEPROM  80,("SE") '   2.2 K   820        Sse   1.4  K   883
'EEPROM  90,("E ") '   1   K   918        Ene     891    929   
                  '                      Ese     688    958         
      
 	DirsB = %11111111  'Configure pins 0-7 as outputs		
      DirsC = %11000000  'Configure pins 6,7 as outputs
   	SETFREQ M16	      
InitialiseOLED_LCD: 	
 	FOR  index = 0 TO 6
LOOKUP index,($38,$38,$38,$C,$1,$2,$6),senddata : PULSOUT E,1'(Function 8bit/2line/5x8)*3(Display On)(Clear Display)(Return Home)(Entry Mode Set) 	             
      NEXT index : PAUSE 10        	
Main:
 ReadADC10 C.0,WindDirection 
 BinTOASCII    WindDirection,Character1,Character2,Character3
    
Display:  Sertxd (13,10," ADCvalue  ",Character1,Character2,Character3) ' send characters to #terminal
 LOW RS  :senddata = 192 : PULSOUT E,1 : HIGH RS  '(192-211) Line 2 Cursor Position
      FOR  index = 0 TO 13
 	    LOOKUP index,(" ADCvalue  ",Character1,Character2,Character3),senddata : PULSOUT E,1 ' send characters  
      NEXT index
 PAUSE 1000
GOTO main
And here we Display the WindSpeed and WindDirection.
Code:
	#picaxe 18m2    							
	#terminal 19200   	
       '          DB7  = B.7	
       '          DB6  = B.6	
       '          DB5  = B.5	
       '          DB4  = B.4	
       '          DB3  = B.3	
       '          DB2  = B.2	
       '          DB1  = B.1		
       '          DB0  = B.0
       SYMBOL Rx       = C.5
	 SYMBOL E        = C.6			                  
 	 SYMBOL RS       = C.7			                  
	 SYMBOL senddata = pinsB	 
	 SYMBOL index    = b0
	 
	 SYMBOL WindDirection      = W1 'b2,b3
       SYMBOL WindSpeed          = W2 'b4,b5
       SYMBOL Character1         = b6
       SYMBOL Character2         = b7
       SYMBOL Character3         = b8
       SYMBOL Character4         = b9
                                                         
                  '  ohms     ADCvalues         ||ohms
EEPROM  00,("W ") ' 120   K   070 
EEPROM  10,("NW") '  64.9 K   123        Wnw  42.2  K   178
EEPROM  20,("N ") '  33   K   217        Nnw  21.88 K   295
EEPROM  30,("SW") '  16   K   365        Wsw  14.12 K   395
EEPROM  50,("NE") '   8.2 K   532        Nne   6.57 K   588
EEPROM  70,("S ") '   3.9 K   710        Ssw   3.14 K   755
EEPROM  80,("SE") '   2.2 K   820        Sse   1.4  K   883
EEPROM  90,("E ") '   1   K   918        Ene     891    929   
                  '                      Ese     688    958         
      
 	DirsB = %11111111  'Configure pins 0-7 as outputs		
      DirsC = %11000000  'Configure pins 6,7 as outputs
   	SETFREQ M16	      
InitialiseOLED_LCD: 	
 	FOR  index = 0 TO 6
LOOKUP index,($38,$38,$38,$C,$1,$2,$6),senddata : PULSOUT E,1'(Function 8bit/2line/5x8)*3(Display On)(Clear Display)(Return Home)(Entry Mode Set) 	             
      NEXT index : PAUSE 10        	
Main:
 ReadADC10 C.0,WindDirection 
 WindDirection = WindDirection/100*10      
 	READ WindDirection, Character1                              
 	  INC WindDirection
      READ WindDirection, Character2
'COUNT C.1,17904, WindSpeed :  WindSpeed=WindSpeed/3 ' count pulses in 1.492*3 secs (at 16MHz) ' one pulse per second = 1.492mp
COUNT C.1,19200, WindSpeed  :  WindSpeed=WindSpeed/2 ' count pulses in 2.4*2   secs (at 16MHz) ' one pulse per second = 2.4km/h
 Character3 = WindSpeed  /10 +48 : IF  Character3 = "0" THEN : Character3 = " " : ENDIF ' leading zero blanking
 Character4 = WindSpeed //10 +48
    
Display:  Sertxd (13,10,"Winds  ",Character1,Character2," ",Character3,Character4," km/h") ' send characters to #terminal
 LOW RS  :senddata = 192 : PULSOUT E,1 : HIGH RS  '(192-211) Line 2 Cursor Position
      FOR  index = 0 TO 16
 	    LOOKUP index,("Winds  ",Character1,Character2," ",Character3,Character4," km/h"),senddata : PULSOUT E,1 ' send characters  
      NEXT index

GOTO main
 
Last edited:

BCJKiwi

Senior Member
As discussed elsewhere here and on weather forums, fine tuning of the magnet strength / position can achieve more reliable 16 position sensing.
 

john2051

New Member
What actually happened to your weather station? reason I ask is that mine suddenly stopped receiving the data from the wireless
wind speed detector. I cured it by leaving the batteries out of the main unit for 30secs and then thankfully it now works again.
I still like your idea, I think i'll have a go as a second detector.
regards john
 

marks

Senior Member
It would be interesting to know what accuracy has been achieved by others modifying their sensor ?

I'm happy with 8 accurate positions as wind seems to fluctuate quite a bit here even with just 8 indicating positions.

Originaly one of the mid position did not work ( I could never get both contacts to close simultaneously) after inspection
noticed glass reed switch was on a slight angle resoldering upright corrected this problem so best to test all positions work!

The weather staion I had was 2081 worked for about 5 months, the temperature and humidity readings first showed strange values
(this unit had the solar cell recharging alkaline batteries)Wind speed and direction worked ok
the batteries went flat I suspect after a while the temperature and humidity readings went blank
The batteries went reverse polarity and damaged the electronics(I should have changed them sooner lol).
My Dad has the earlier model working for years on normal batteries without any problem I gave him my base station
so he has two working of the same transmitter .
cheers marks
 
Top