Ag v30 05b: Dendrometer sensor with reference
Turn on the Agriculture v30 board and read the dendrometer on it once every second

Required Materials

1 x Waspmote 1 x Agriculture Board v30 1 x Dendrometer sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
* --[Ag_v30_05b] - Dendrometer sensor reading with reference
3
*
4
* Explanation: Turn on the Agriculture v30 board and read the
5
* dendrometer on it once every second
6
*
7
* Copyright (C) 2017 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: Luis Miguel Martí
26
*/
27
28
#include <WaspSensorAgr_v30.h>
29
30
// Variable to store the read value
31
float value;
32
33
/*
34
* Define object for sensor: dendSensor
35
* Input to choose type of dendrometer.
36
* Possibilities for this sensor:
37
* - SENS_SA_DF
38
* - SENS_SA_DD
39
* - SENS_SA_DC3
40
* - SENS_SA_DC2 (old)
41
*/
42
dendrometerClass dendSensor(SENS_SA_DF);
43
44
void setup()
45
{
46
// Turn on the USB and print a start message
47
USB.ON();
48
USB.println(F("Start program"));
49
50
// Turn on the sensor board
51
Agriculture.ON();
52
53
// This function reads the dendrometer value
54
// and sets it as zero millimeters reference
55
USB.print(F("Reference captured at: "));
56
dendSensor.setReference();
57
USB.printFloat(dendSensor._reference,3);
58
USB.println(F(" mm .The following samples will be relatives to this"));
59
}
60
61
void loop()
62
{
63
// Part 1: Read the dendrometer value and returns
64
// the difference between this value and reference
65
value = dendSensor.readGrowth();
66
67
// Part 2: USB printing
68
// Print the Dendrometer value through the USB
69
USB.print(F("Dendrometer: "));
70
USB.printFloat(value,3);
71
USB.println(F(" mm"));
72
delay(1000);
73
}
Copied!

Output

1
H#
2
Start program
3
Reference captured at: 3.906 mm .The following samples will be relatives to this
4
Dendrometer: 0.000 mm
5
Dendrometer: 0.000 mm
6
Dendrometer: 0.000 mm
7
Dendrometer: 0.000 mm
8
Dendrometer: 0.000 mm
Copied!
Last modified 1yr ago