Ag xtr 24: Datasol Met 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 Solar radiation and temperature Datasol Met probe

Notes

- This example is only valid for Waspmote v15

Code

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

Output

1
I#
2
Datasol MET example
3
---------------------------
4
Datasol MET
5
Measured radiation: 18 W/m2
6
Semi-cell 1 radiation: 18 W/m2
7
Semi-cell 2 radiation: 0 W/m2
8
Environment temperature: 24.9 degrees Celsius
9
Panel temperature: 24.9 degrees Celsius
10
Peak sun hours: 1.00 hours
11
Necessary cleaning notice: 0
12
Wind speed: 5.0 m/s
13
---------------------------
14
---------------------------
15
Datasol MET
16
Measured radiation: 18 W/m2
17
Semi-cell 1 radiation: 18 W/m2
18
Semi-cell 2 radiation: 0 W/m2
19
Environment temperature: 24.9 degrees Celsius
20
Panel temperature: 24.9 degrees Celsius
21
Peak sun hours: 1.00 hours
22
Necessary cleaning notice: 0
23
Wind speed: 5.0 m/s
24
---------------------------
Copied!
Last modified 1yr ago