Ag xtr 10: MPS6 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. Note: The Meter TEROS 21 sensor was previously named as Decagon MPS-6

Required Materials

- 1 Waspmote Plug & Sense! Smart Agriculture Xtreme - 1 TEROS 21 sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
----------- [Ag_xtr_10] - MPS6 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
Note: The Meter TEROS 21 sensor was previously named as Decagon MPS-6
9
10
Measured parameters:
11
- Soil water potential
12
- Soil temperature
13
14
Copyright (C) 2018 Libelium Comunicaciones Distribuidas S.L.
15
http://www.libelium.com
16
17
This program is free software: you can redistribute it and/or modify
18
it under the terms of the GNU General Public License as published by
19
the Free Software Foundation, either version 3 of the License, or
20
(at your option) any later version.
21
22
This program is distributed in the hope that it will be useful,
23
but WITHOUT ANY WARRANTY; without even the implied warranty of
24
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
GNU General Public License for more details.
26
27
You should have received a copy of the GNU General Public License
28
along with this program. If not, see .
29
30
Version: 3.1
31
Design: David Gascón
32
Implementation: J.Siscart, V.Boria
33
*/
34
35
#include <WaspSensorXtr.h>
36
37
/*
38
SELECT THE RIGHT SOCKET FOR EACH SENSOR.
39
40
Possible sockets for this sensor are:
41
- XTR_SOCKET_A _________
42
- XTR_SOCKET_B |---------|
43
- XTR_SOCKET_C | A B C |
44
- XTR_SOCKET_D |_D__E__F_|
45
46
47
Example: a 5TM sensor on socket A will be
48
[Sensor Class] [Sensor Name] [Selected socket]
49
Decagon_5TM mySensor (XTR_SOCKET_A);
50
51
Refer to the technical guide for information about possible combinations.
52
www.libelium.com/downloads/documentation/smart_agriculture_xtreme_sensor_board.pdf
53
*/
54
55
// [Sensor Class] [Sensor Name] [Selected socket]
56
Decagon_MPS6 mySensor(XTR_SOCKET_A);
57
58
void setup()
59
{
60
USB.println(F("TEROS 21 (MPS6) example"));
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
// 4. Print information
80
USB.println(F("---------------------------"));
81
USB.println(F("MPS6"));
82
USB.print(F("Soil water potential: "));
83
USB.printFloat(mySensor.sensorMPS6.waterPotential, 1);
84
USB.println(F(" kPa"));
85
USB.print(F("Soil temperature: "));
86
USB.printFloat(mySensor.sensorMPS6.temperature, 1);
87
USB.println(F(" degrees Celsius"));
88
USB.println(F("---------------------------\n"));
89
90
delay(5000);
91
92
}
Copied!

Output

1
H#
2
MPS6 example
3
---------------------------
4
MPS6
5
Soil water potential: -3162.4 kPa
6
Soil temperature: 26.1 degrees Celsius
7
---------------------------
8
---------------------------
9
MPS6
10
Soil water potential: -3162.4 kPa
11
Soil temperature: 26.1 degrees Celsius
12
---------------------------
Copied!
Last modified 1yr ago