Ag xtr 11: VP4 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 ATMOS 14 sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
----------- [Ag_xtr_11] - VP4 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
- Vapor pressure
10
- Humidity
11
- Temperature
12
- Atmospheric pressure in soil and air
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_VP4 mySensor(XTR_SOCKET_A);
57
58
void setup()
59
{
60
USB.println(F("VP4 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("VP4"));
82
USB.print(F("Vapor Pressure:"));
83
USB.printFloat(mySensor.sensorVP4.vaporPressure, 3);
84
USB.println(F(" kPa"));
85
USB.print(F("Temperature:"));
86
USB.printFloat(mySensor.sensorVP4.temperature, 1);
87
USB.println(F(" degrees Celsius"));
88
USB.print(F("Relative Humidity:"));
89
USB.printFloat(mySensor.sensorVP4.relativeHumidity, 1);
90
USB.println(F(" %RH"));
91
USB.print(F("Atmospheric Pressure:"));
92
USB.printFloat(mySensor.sensorVP4.atmosphericPressure, 2);
93
USB.println(F(" kPa"));
94
USB.println(F("---------------------------\n"));
95
96
delay(5000);
97
98
}
Copied!

Output

1
H#
2
VP4 example
3
---------------------------
4
VP4
5
Vapor Pressure:1.420 kPa
6
Temperature:25.4 degrees Celsius
7
Relative Humidity:44.0 %RH
8
Atmospheric Pressure:98.79 kPa
9
---------------------------
10
---------------------------
11
VP4
12
Vapor Pressure:1.430 kPa
13
Temperature:25.4 degrees Celsius
14
Relative Humidity:44.0 %RH
15
Atmospheric Pressure:98.79 kPa
16
---------------------------
Copied!
Last modified 6mo ago