Ag xtr 30: SO-421 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 SO-421 sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
----------- [Ag_xtr_30] - SO-421 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
- Calibreted oxigen
10
- Body temperature
11
- Sensor millivolts
12
13
Copyright (C) 2021 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: J.Siscart, V.Boria
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
Apogee_SO421 mySensor(XTR_SOCKET_A);
56
57
void setup()
58
{
59
USB.println(F("SO-421 example"));
60
}
61
62
void loop()
63
{
64
// 1. Turn ON the sensor
65
/*
66
ON() function turns on the sensor and the heater before take a read.
67
Sensor response time is 15 seconds.
68
Dont forget to turn it off after read it.
69
*/
70
mySensor.ON();
71
delay(15000);
72
73
// 2. Read the sensor
74
/*
75
Note: read() function does not directly return sensor values.
76
They are stored in the class vector variables defined for that purpose.
77
Values are available as a float value
78
*/
79
mySensor.read();
80
81
// 3. Turn off the sensor and the heater
82
mySensor.OFF();
83
84
// 4. Print information
85
USB.println(F("---------------------------"));
86
USB.println(F("SO-421"));
87
USB.print(F("Calibrated Oxigen: "));
88
USB.printFloat(mySensor.sensorSO421.calibratedOxygen, 3);
89
USB.println(F(" %"));
90
USB.print(F("Body temperature: "));
91
USB.printFloat(mySensor.sensorSO421.bodyTemperature, 1);
92
USB.println(F(" degrees Celsius"));
93
USB.print(F("Sensor millivolts: "));
94
USB.printFloat(mySensor.sensorSO421.milliVolts, 4);
95
USB.println(F(" mV"));
96
USB.println(F("---------------------------\n"));
97
98
/*
99
Note: To send the SO-421 sensor values with the FRAME library,
100
please use the SO-411 tags. There are not specific tags for the SO-421 due
101
to memory limitations.
102
103
This is an example for the socket A:
104
105
frame.addSensor(AGRX_SO411_CO_A, mySensor.sensorSO421.calibratedOxygen);
106
frame.addSensor(AGRX_SO411_TC2_A, mySensor.sensorSO421.bodyTemperature);
107
frame.addSensor(AGRX_SO411_MV2_A, mySensor.sensorSO421.milliVolts);
108
109
*/
110
111
delay(5000);
112
113
}
Copied!

Output

1
H#
2
SO-421 example
3
---------------------------
4
SO-421
5
Calibrated Oxigen: 26.156 %
6
Body temperature: 24.1 degrees Celsius
7
Sensor millivolts: 11.5795 mV
8
---------------------------
9
10
---------------------------
11
SO-421
12
Calibrated Oxigen: 26.149 %
13
Body temperature: 24.1 degrees Celsius
14
Sensor millivolts: 11.5772 mV
15
---------------------------
16
17
---------------------------
18
SO-421
19
Calibrated Oxigen: 26.140 %
20
Body temperature: 24.2 degrees Celsius
21
Sensor millivolts: 11.5742 mV
22
---------------------------
23
24
---------------------------
25
SO-421
26
Calibrated Oxigen: 26.152 %
27
Body temperature: 24.2 degrees Celsius
28
Sensor millivolts: 11.5784 mV
29
---------------------------
30
31
---------------------------
32
SO-421
33
Calibrated Oxigen: 26.153 %
34
Body temperature: 24.2 degrees Celsius
35
Sensor millivolts: 11.5786 mV
36
---------------------------
Copied!
Last modified 7mo ago