Ag v30 07: Watermark sensor
Turn on the Agriculture v30 board and read the Watermark sensors every second

Required Materials

1 x Waspmote 1 x Agriculture Board v30 3 x Watermark sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
* --[Ag_v30_07] - Watermark sensor reading
3
*
4
* Explanation: Turn on the Agriculture v30 board and read the
5
* Watermark sensors every second
6
*
7
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
8
* http://www.libelium.com
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the GNU General Public License
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*
23
* Version: 3.0
24
* Design: David Gascón
25
* Implementation: Carlos Bello
26
*/
27
28
#include <WaspSensorAgr_v30.h>
29
30
// Variable to store the read value
31
float watermark1, watermark2, watermark3;
32
//Instance objects
33
watermarkClass wmSensor1(SOCKET_1);
34
watermarkClass wmSensor2(SOCKET_2);
35
watermarkClass wmSensor3(SOCKET_3);
36
37
void setup()
38
{
39
// Turn on the USB and print a start message
40
USB.ON();
41
USB.println(F("Start program"));
42
43
// Turn on the sensor board
44
Agriculture.ON();
45
}
46
47
void loop()
48
{
49
// Part 1: Read the Watermarks sensors one by one
50
USB.println(F("Wait for Watermark 1..."));
51
watermark1 = wmSensor1.readWatermark();
52
53
USB.println(F("Wait for Watermark 2..."));
54
watermark2 = wmSensor2.readWatermark();
55
56
USB.println(F("Wait for Watermark 3..."));
57
watermark3 = wmSensor3.readWatermark();
58
59
// Part 2: USB printing
60
// Print the watermark measures
61
USB.print(F("Watermark 1 - Frequency: "));
62
USB.print(watermark1);
63
USB.println(F(" Hz"));
64
USB.print(F("Watermark 2 - Frequency: "));
65
USB.print(watermark2);
66
USB.println(F(" Hz"));
67
USB.print(F("Watermark 3 - Frequency: "));
68
USB.print(watermark3);
69
USB.println(F(" Hz"));
70
USB.println();
71
72
delay(1000);
73
}
Copied!

Output

1
H#
2
Start program
3
Wait for Watermark 1...
4
Wait for Watermark 2...
5
Wait for Watermark 3...
6
Watermark 1 - Frequency: 8849.5576171875 Hz
7
Watermark 2 - Frequency: 6944.4443359375 Hz
8
Watermark 3 - Frequency: 3891.0505371093 Hz
9
10
Wait for Watermark 1...
11
Wait for Watermark 2...
12
Wait for Watermark 3...
13
Watermark 1 - Frequency: 8771.9296875000 Hz
14
Watermark 2 - Frequency: 6993.0068359375 Hz
15
Watermark 3 - Frequency: 3906.2500000000 Hz
16
17
...
Copied!
Last modified 1yr ago