Ag xtr 09: 5TM sensor reading
Basic example that turns on, reads and turn off the sensor. Measured parameters are stored in the corresponding class variables and printed by the serial monitor.

Required Materials

- 1 Waspmote Plug & Sense! Smart Agriculture Xtreme - 1 5TM sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
----------- [Ag_xtr_09] - 5TM sensor reading --------------------
3
4
Explanation: Basic example that turns on, reads and turn off the
5
sensor. Measured parameters are stored in the corresponding class
6
variables and printed by the serial monitor.
7
8
Measured parameters:
9
- Volumetric water content
10
- Temperature of the soil
11
12
Copyright (C) 2018 Libelium Comunicaciones Distribuidas S.L.
13
http://www.libelium.com
14
15
This program is free software: you can redistribute it and/or modify
16
it under the terms of the GNU General Public License as published by
17
the Free Software Foundation, either version 3 of the License, or
18
(at your option) any later version.
19
20
This program is distributed in the hope that it will be useful,
21
but WITHOUT ANY WARRANTY; without even the implied warranty of
22
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
GNU General Public License for more details.
24
25
You should have received a copy of the GNU General Public License
26
along with this program. If not, see .
27
28
Version: 3.1
29
Design: David Gascón
30
Implementation: J.Siscart, V.Boria
31
*/
32
33
#include <WaspSensorXtr.h>
34
35
/*
36
SELECT THE RIGHT SOCKET FOR EACH SENSOR.
37
38
Possible sockets for this sensor are:
39
- XTR_SOCKET_A _________
40
- XTR_SOCKET_B |---------|
41
- XTR_SOCKET_C | A B C |
42
- XTR_SOCKET_D |_D__E__F_|
43
44
45
Example: a 5TM sensor on socket A will be
46
[Sensor Class] [Sensor Name] [Selected socket]
47
Decagon_5TM mySensor (XTR_SOCKET_A);
48
49
Refer to the technical guide for information about possible combinations.
50
www.libelium.com/downloads/documentation/smart_agriculture_xtreme_sensor_board.pdf
51
*/
52
53
// [Sensor Class] [Sensor Name] [Selected socket]
54
Decagon_5TM mySensor(XTR_SOCKET_A);
55
56
void setup()
57
{
58
USB.println(F("5TM example"));
59
}
60
61
void loop()
62
{
63
// 1. Turn ON the sensor
64
mySensor.ON();
65
66
// 2. Read the sensor
67
/*
68
Note: read() function does not directly return sensor values.
69
They are stored in the class vector variables defined for that purpose.
70
Values are available as a float value
71
*/
72
mySensor.read();
73
74
// 3. Turn off the sensor
75
mySensor.OFF();
76
77
// 4. Conversion of dielectric permittivity into Volumetric Water Content (VWC)
78
// for mineral soil using Topp equation
79
float VWC = ((4.3 * pow(10, -6) * pow(mySensor.sensor5TM.dielectricPermittivity, 3))
80
- (5.5 * pow(10, -4) * pow(mySensor.sensor5TM.dielectricPermittivity, 2))
81
+ (2.92 * pow(10, -2) * mySensor.sensor5TM.dielectricPermittivity)
82
- (5.3 * pow(10, -2))) * 100 ;
83
84
85
// 5. Print information
86
USB.println(F("---------------------------"));
87
USB.println(F("5TM"));
88
USB.print(F("Dielectric Permittivity: "));
89
USB.printFloat(mySensor.sensor5TM.dielectricPermittivity, 2);
90
USB.println();
91
USB.print(F("Volumetric Water Content: "));
92
USB.printFloat(VWC, 2);
93
USB.println(F(" %VWC"));
94
USB.print(F("Soil temperature: "));
95
USB.printFloat(mySensor.sensor5TM.temperature, 1);
96
USB.println(F(" degrees Celsius"));
97
USB.println(F("---------------------------\n"));
98
99
delay(5000);
100
101
}
Copied!

Output

1
H#
2
5TM example
3
---------------------------
4
5TM
5
Dielectric Permittivity: 14.60
6
Volumetric Water Content: 26.94 %VWC
7
Soil temperature: 26.2 degrees Celsius
8
---------------------------
9
---------------------------
10
5TM
11
Dielectric Permittivity: 14.60
12
Volumetric Water Content: 26.94 %VWC
13
Soil temperature: 26.2 degrees Celsius
14
---------------------------
Copied!
Last modified 1yr ago