# Weather Station Wind Vane

**URL:** <https://forum.core-electronics.com.au/t/weather-station-wind-vane/17238>\
**Category:** Uncategorized\
**Created:** [2 June 2023 06:02 UTC](https://forum.core-electronics.com.au/t/weather-station-wind-vane/17238 "2023-06-02T06:02:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![f0rml3ssf0rm](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/f0rml3ssf0rm/32/7643_2.png) [@f0rml3ssf0rm](https://forum.core-electronics.com.au/u/f0rml3ssf0rm)\
**Post date:** [2 June 2023 06:02 UTC](https://forum.core-electronics.com.au/t/weather-station-wind-vane/17238/1 "2023-06-02T06:02:02Z")

</div>

I bought one of these:

> **[Weather Station with Anemometer/Wind Vane/Rain Bucket](https://core-electronics.com.au/weather-station-with-anemometer-wind-vane-rain-bucket.html)**
>
> Have you ever had the urge to rush out into your shed and build your own weather station? Well, this weather station kit includes an anemometer (for wind speed measurements), wind vane (for wind direction) and rain bucket (for rainfall measurements).

And have got the wind speed working. I am currently trying to get the wind vane working to no avail. I am following this guide:

[https://projects.raspberrypi.org/en/projects/build-your-own-weather-station/7](https://projects.raspberrypi.org/en/projects/build-your-own-weather-station/7)

The wind vane I have also uses reid switches in combination with resistors to calculate wind direction, but the code in the tutorial im following only produces 2 results, when 16 should be coming through. This is the code:

```auto
from gpiozero import MCP3008
import time
adc = MCP3008(channel=0)
count = 0
values = []
while True:
	wind = round(adc.value*3.3,1)
	if not wind in values:
		values.append(wind)
		count+=1
		print(count)

```

I should be getting results:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16

But I am only getting result:

1  
2

I have tried changing the value of the resistor used on channel 0 of the MCP3008 and it does give closer results, but never upto the full 16 voltage combinations I should have.

Any ideas?

Thanks,

Jeroth

---

<div class="post-metadata">

**Author:** ![James](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/james/32/4400_2.png) [@James](https://forum.core-electronics.com.au/u/James)\
**Post date:** [4 June 2023 23:55 UTC](https://forum.core-electronics.com.au/t/weather-station-wind-vane/17238/2 "2023-06-04T23:55:26Z")

</div>

Hi Jeroth,

Great work on your project so far. While you may have done this already, I’d examine each step in the chain to make sure it’s working:

- Have you tested the output of the vane with a multimeter to confirm what voltages you get back?
- Have you tried printing the raw ADC values to make sure that’s working fine?

Keen to see your results from this so we can better debug your code 🙂

---

<div class="post-metadata">

**Author:** ![f0rml3ssf0rm](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/f0rml3ssf0rm/32/7643_2.png) [@f0rml3ssf0rm](https://forum.core-electronics.com.au/u/f0rml3ssf0rm)\
**Post date:** [5 June 2023 04:46 UTC](https://forum.core-electronics.com.au/t/weather-station-wind-vane/17238/3 "2023-06-05T04:46:17Z")

</div>

Dont have a multimeter, may have to buy one then. As for:

- Have you tried printing the raw ADC values to make sure that’s working fine?

How would I go about this? Running the code with nothing connected to the MCP3008 Analog in? If so ive done this and got the required 1 - 16 output from the code.

Thanks,

Jeroth

---

<div class="post-metadata">

**Author:** ![Jacob](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/jacob/32/8358_2.png) [@Jacob](https://forum.core-electronics.com.au/u/Jacob)\
**Post date:** [5 June 2023 06:00 UTC](https://forum.core-electronics.com.au/t/weather-station-wind-vane/17238/4 "2023-06-05T06:00:01Z")

</div>

Hi Jeroth,

To print the raw ADC you can try a script like the following, which will print both the raw ADC value and the scaled value between 0 and 3.3 volts, every 200 milliseconds.

```auto
from gpiozero import MCP3008
import time
adc = MCP3008(channel=0)
while True:
    raw_adc = adc.value
    scaled_adc = raw_adc * 3.3
    rounded_adc = round(scaled_adc, 1)
    
    print("Raw ADC", raw_adc) # Should be a number between 0 and 1, likely with a bit of noise
    print("Scaled ADC", scaled_adc) # Should be a number between 0 and 3.3, likely with a bit of noise
    print("Rounded ADC", rounded_adc) # Should be a number between 0 and 3.3, rounded to help reduce the noise
    time.sleep_ms(200)

```

If you run the script while slowly turning the vane 360 degrees you should be able to observe the change in raw readings - at each of the 16 steps of the vane you should see a distinct step/change in the ADC readings.

If you’re not getting 16 distinct readings - e.g. it’s maxing out at 3.3 after one or two positions - it will be helpful to see some pictures of how you have it all wired up, and also a report of the raw readings at each vane position.

Cheers,

Jacob

---

<div class="post-metadata">

**Author:** ![f0rml3ssf0rm](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/f0rml3ssf0rm/32/7643_2.png) [@f0rml3ssf0rm](https://forum.core-electronics.com.au/u/f0rml3ssf0rm)\
**Post date:** [6 June 2023 07:26 UTC](https://forum.core-electronics.com.au/t/weather-station-wind-vane/17238/5 "2023-06-06T07:26:54Z")

</div>

Thanks for the reply, Il give this a shot and report back.
