Ag xtr 12: Phytos 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 Phytos 31 sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
----------- [Ag_xtr_12] - Pythos31 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
- Leaf wetness
10
11
Copyright (C) 2018 Libelium Comunicaciones Distribuidas S.L.
12
http://www.libelium.com
13
14
This program is free software: you can redistribute it and/or modify
15
it under the terms of the GNU General Public License as published by
16
the Free Software Foundation, either version 3 of the License, or
17
(at your option) any later version.
18
19
This program is distributed in the hope that it will be useful,
20
but WITHOUT ANY WARRANTY; without even the implied warranty of
21
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
GNU General Public License for more details.
23
24
You should have received a copy of the GNU General Public License
25
along with this program. If not, see .
26
27
Version: 3.1
28
Design: David Gascón
29
Implementation: J.Siscart, V.Boria
30
*/
31
32
#include <WaspSensorXtr.h>
33
34
/*
35
SELECT THE RIGHT SOCKET FOR EACH SENSOR.
36
37
Possible sockets for this sensor are:
38
- XTR_SOCKET_B _________
39
|---------|
40
| A B C |
41
|_D__E__F_|
42
43
44
Example: a 5TM sensor on socket A will be
45
[Sensor Class] [Sensor Name] [Selected socket]
46
Decagon_5TM mySensor (XTR_SOCKET_A);
47
48
Refer to the technical guide for information about possible combinations.
49
www.libelium.com/downloads/documentation/smart_agriculture_xtreme_sensor_board.pdf
50
*/
51
52
// [Sensor Class] [Sensor Name]
53
leafWetness mySensor;
54
55
void setup()
56
{
57
USB.println(F("Pythos31 example"));
58
}
59
60
void loop()
61
{
62
// 1. Turn ON the sensor
63
mySensor.ON();
64
65
// 2. Read the sensor
66
/*
67
Note: read() function does not directly return sensor values.
68
They are stored in the class vector variables defined for that purpose.
69
Values are available as a float value
70
*/
71
mySensor.read();
72
73
// 3. Turn off the sensor
74
mySensor.OFF();
75
76
// 4. Print information
77
USB.println(F("---------------------------"));
78
USB.println(F("Pythos31"));
79
USB.print(F("Leaf wetness:"));
80
USB.printFloat(mySensor.wetness, 4);
81
USB.println(F(" V"));
82
USB.println(F("---------------------------\n"));
83
84
delay(5000);
85
86
}
Copied!

Output

1
H#
2
Pythos31 example
3
---------------------------
4
Pythos31
5
Leaf wetness:0.3807 V
6
---------------------------
7
---------------------------
8
Pythos31
9
Leaf wetness:0.3597 V
10
---------------------------
Copied!
Last modified 1yr ago