Ag xtr 04: SU-100 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 SU-100 sensor

Notes

- This example is only valid for Waspmote v15

Code

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

Output

1
H#
2
SU-100 example
3
---------------------------
4
SU-100
5
Ultraviolet Radiation: 48.49 umol*m-2*s-1
6
Sensor voltage: 0.0097 V
7
---------------------------
8
---------------------------
9
SU-100
10
Ultraviolet Radiation: 48.44 umol*m-2*s-1
11
Sensor voltage: 0.0097 V
12
---------------------------
Copied!
Last modified 1yr ago