Ag v30 09: Wind vane
Turn on the Agriculture v30 board and read the Wind Vane Sensor calling the special 'getVaneFiltered' function in order to calculate the mean value of sucesive measurement of the wind vane direction sensor. The Wind Vane value will be stored in the inner attribute: 'vaneDirection'

Required Materials

1 x Waspmote 1 x Agriculture Board v30 1 x Wind vane sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
* --[Ag_v30_09] - Wind Vane filtered sensor reading
3
*
4
* Explanation: Turn on the Agriculture v30 board and read the
5
* Wind Vane Sensor calling the special 'getVaneFiltered' function
6
* in order to calculate the mean value of sucesive measurement of
7
* the wind vane direction sensor. The Wind Vane value will be stored
8
* in the inner attribute: 'vaneDirection'
9
*
10
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
11
* http://www.libelium.com
12
*
13
* This program is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation, either version 3 of the License, or
16
* (at your option) any later version.
17
*
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License
24
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
*
26
* Version: 3.0
27
* Design: David Gascón
28
* Implementation: Carlos Bello
29
*/
30
31
#include <WaspSensorAgr_v30.h>
32
33
//Instance object
34
weatherStationClass vaneSensor;
35
36
void setup()
37
{
38
// Turn on the USB and print a start message
39
USB.ON();
40
USB.println(F("Start program"));
41
42
// Turn on the sensor board
43
Agriculture.ON();
44
}
45
46
void loop()
47
{
48
// Part 1: Sensor reading
49
// Read the Wind Vane sensor calling the special 'getVaneFiltered'
50
// function in order to calculate the mean value of sucesive
51
// measurement of the wind vane direction sensor. The Wind Vane
52
// value will be stored in the inner attribute: 'vaneSensor.vaneDirection'
53
vaneSensor.getVaneFiltered();
54
55
56
// Part 2: USB printing
57
switch(vaneSensor.vaneDirection)
58
{
59
case SENS_AGR_VANE_N : USB.println("N");
60
break;
61
case SENS_AGR_VANE_NNE : USB.println("NNE");
62
break;
63
case SENS_AGR_VANE_NE : USB.println("NE");
64
break;
65
case SENS_AGR_VANE_ENE : USB.println("ENE");
66
break;
67
case SENS_AGR_VANE_E : USB.println("E");
68
break;
69
case SENS_AGR_VANE_ESE : USB.println("ESE");
70
break;
71
case SENS_AGR_VANE_SE : USB.println("SE");
72
break;
73
case SENS_AGR_VANE_SSE : USB.println("SSE");
74
break;
75
case SENS_AGR_VANE_S : USB.println("S");
76
break;
77
case SENS_AGR_VANE_SSW : USB.println("SSW");
78
break;
79
case SENS_AGR_VANE_SW : USB.println("SW");
80
break;
81
case SENS_AGR_VANE_WSW : USB.println("WSW");
82
break;
83
case SENS_AGR_VANE_W : USB.println("W");
84
break;
85
case SENS_AGR_VANE_WNW : USB.println("WNW");
86
break;
87
case SENS_AGR_VANE_NW : USB.println("WN");
88
break;
89
case SENS_AGR_VANE_NNW : USB.println("NNW");
90
break;
91
}
92
delay(1000);
93
}
Copied!

Output

1
H#
2
Start program
3
NW
4
NW
5
NW
6
N
7
N
8
....
Copied!
Last modified 1yr ago