Ag v30 01: Temperature sensor
Turn on the Agriculture v30 board and read the temperature,humidity and pressure once every second

Required Materials

1 x Waspmote 1 x Agriculture Board v30 1 x BME sensor

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
* --[Ag_v30_01] - Temperature sensor reading
3
*
4
* Explanation: Turn on the Agriculture v30 board and read the
5
* temperature,humidity and pressure once every second
6
*
7
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
8
* http://www.libelium.com
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the GNU General Public License
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*
23
* Version: 3.0
24
* Design: David Gascón
25
* Implementation: Carlos Bello
26
*/
27
28
#include <WaspSensorAgr_v30.h>
29
30
// Variable to store the read value
31
float temp,humd,pres;
32
33
void setup()
34
{
35
// Turn on the USB and print a start message
36
USB.ON();
37
USB.println(F("Start program"));
38
// Turn on the sensor board
39
Agriculture.ON();
40
}
41
42
void loop()
43
{
44
///////////////////////////////////////
45
// 1. Read BME280: temp, hum, pressure
46
///////////////////////////////////////
47
48
temp = Agriculture.getTemperature();
49
humd = Agriculture.getHumidity();
50
pres = Agriculture.getPressure();
51
52
///////////////////////////////////////
53
// 2. Print BME280 Values
54
///////////////////////////////////////
55
USB.print(F("Temperature: "));
56
USB.print(temp);
57
USB.println(F(" Celsius"));
58
USB.print(F("Humidity: "));
59
USB.print(humd);
60
USB.println(F(" %"));
61
USB.print(F("Pressure: "));
62
USB.print(pres);
63
USB.println(F(" Pa"));
64
USB.println();
65
delay(1000);
66
}
Copied!

Output

1
H#
2
Start program
3
Temperature: 26.0100002288 Celsius
4
Humidity: 48.9228515625 %
5
Pressure: 99657.7656250000 Pa
6
7
Temperature: 26.0200004577 Celsius
8
Humidity: 48.8994140625 %
9
Pressure: 99656.1562500000 Pa
10
11
Temperature: 26.0100002288 Celsius
12
Humidity: 48.9345703125 %
13
Pressure: 99655.7500000000 Pa
14
15
Temperature: 26.0300006866 Celsius
16
Humidity: 49.0341796875 %
17
Pressure: 99657.7656250000 Pa
Copied!
Last modified 1yr ago