Ag xtr 28: Teros 12 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 Teros 12

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
---------- - [Ag_xtr_28] - Teros 12 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
- Electrical conductivity
10
- Volumetric water content
11
- Temperature of the soil
12
13
Copyright (C) 2020 Libelium Comunicaciones Distribuidas S.L.
14
http://www.libelium.com
15
16
This program is free software: you can redistribute it and / or modify
17
it under the terms of the GNU General Public License as published by
18
the Free Software Foundation, either version 3 of the License, or
19
(at your option) any later version.
20
21
This program is distributed in the hope that it will be useful,
22
but WITHOUT ANY WARRANTY; without even the implied warranty of
23
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
GNU General Public License for more details.
25
26
You should have received a copy of the GNU General Public License
27
along with this program. If not, see < http : //www.gnu.org/licenses/>.
28
29
Version : 3.1
30
Design : David Gascón
31
Implementation : A.Falo
32
*/
33
34
#include <WaspSensorXtr.h>
35
36
/*
37
SELECT THE RIGHT SOCKET FOR EACH SENSOR.
38
39
Possible sockets for this sensor are:
40
- XTR_SOCKET_A _________
41
- XTR_SOCKET_B |---------|
42
- XTR_SOCKET_C | A B C |
43
- XTR_SOCKET_D |_D__E__F_|
44
45
46
Example: a 5TM sensor on socket A will be
47
[Sensor Class] [Sensor Name] [Selected socket]
48
Decagon_5TM mySensor (XTR_SOCKET_A);
49
50
Refer to the technical guide for information about possible combinations.
51
www.libelium.com/downloads/documentation/smart_agriculture_xtreme_sensor_board.pdf
52
*/
53
54
// [Sensor Class] [Sensor Name] [Selected socket]
55
Meter_TEROS12 mySensor(XTR_SOCKET_A);
56
57
void setup()
58
{
59
USB.println(F("Teros 12 example"));
60
61
}
62
63
void loop()
64
{
65
// 1. Turn ON the sensor
66
mySensor.ON();
67
68
// 2. Read the sensor
69
/*
70
Note: read() function does not directly return sensor values.
71
They are stored in the class vector variables defined for that purpose.
72
Values are available as a float value
73
*/
74
mySensor.read();
75
76
// 3. Turn off the sensor
77
mySensor.OFF();
78
79
80
// 4.1 Conversion of the RAW output sensor value into Volumetric Water Content (VWC)
81
// for mineral soil using calibration equation
82
float VWC = ((3.879 * pow(10, -4) * mySensor.sensorTEROS12.calibratedCountsVWC)) - 0.6956;
83
84
// for soilless media using calibration equation
85
// float VWC = ((6.771 * pow(10, -10) * pow(mySensor.sensorTEROS12.calibratedCountsVWC, 3))
86
// - (5.105 * pow(10, -6) * pow(mySensor.sensorTEROS12.calibratedCountsVWC, 2))
87
// + (1.302 * pow(10, -2) * mySensor.sensorTEROS12.calibratedCountsVWC))
88
// - 10.848;
89
90
// 4.2 Conversion of the RAW output sensor value into Volumetric Water Content (VWC)
91
// for mineral soil using calibration equation
92
float DP = pow(((2.887 * pow(10, -9) * pow(mySensor.sensorTEROS12.calibratedCountsVWC, 3))
93
- (2.080 * pow(10, -5) * pow(mySensor.sensorTEROS12.calibratedCountsVWC, 2))
94
+ (5.276 * pow(10, -2) * mySensor.sensorTEROS12.calibratedCountsVWC)
95
- 43.39), 2);
96
97
98
// 5. Print information
99
USB.println(F("---------------------------"));
100
USB.println(F("Teros-12"));
101
USB.print(F("Dielectric Permittivity: "));
102
USB.printFloat(DP, 2);
103
USB.println();
104
USB.print(F("Volumetric Water Content: "));
105
USB.printFloat(VWC, 2);
106
USB.println(F(" m3/m3"));
107
USB.print(F("Electrical Conductivity: "));
108
USB.printFloat(mySensor.sensorTEROS12.electricalConductivity, 0);
109
USB.println(F(" dS/m"));
110
USB.print(F("Soil temperature: "));
111
USB.printFloat(mySensor.sensorTEROS12.temperature, 1);
112
USB.println(F(" degrees Celsius"));
113
USB.println(F("---------------------------\n"));
114
115
delay(5000);
116
117
}
Copied!
Last modified 1yr ago