Ag xtr 01: SI-411 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 SI-411 sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
----------- [Ag_xtr_01] - SI-411 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
- Target temperature
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 <http://www.gnu.org/licenses/>.
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
/*
38
Possible sockets 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
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] [Selected socket]
53
Apogee_SI411 mySensor(XTR_SOCKET_A);
54
55
void setup()
56
{
57
USB.println(F("SI-411 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("SI-411:"));
79
USB.print(F("Target Temperature: "));
80
USB.printFloat(mySensor.sensorSI411.targetTemperature, 4);
81
USB.println(F(" degrees Celsius"));
82
USB.println(F("---------------------------\n"));
83
84
delay(5000);
85
86
}
Copied!

Output

1
H#
2
SI-411 example
3
---------------------------
4
SI-411:
5
Target Temperature: 25.9601 degrees Celsius
6
---------------------------
7
---------------------------
8
SI-411:
9
Target Temperature: 28.4388 degrees Celsius
10
---------------------------
11
---------------------------
12
SI-411:
13
Target Temperature: 26.3855 degrees Celsius
14
---------------------------
Copied!
Last modified 1yr ago