GP v30 03: Pellistor gas sensors
This is the basic code to manage and read the pellistor sensor. These sensors include: methane (CH4) and other combustible gases.

Required Materials

1 x Waspmote 1 x Battery 1 x Gases PRO board v30 1 x Temperature, Humidity and Pressure sensor BME280 1 x Pellistor Gas Sensor [Calibrated]

Notes

- Remember to connect the battery to Waspmote for proper operation. - The connection of the sensor is described in the Gases PRO v30 technical guide. - Cycle time: 5 minutes

Code

1
/*
2
* ------------ [GP_v30_03] - Pellistor gas sensors --------------
3
*
4
* Explanation: This is the basic code to manage and read the
5
* pellistor sensor. These sensors include: methane (CH4)
6
* and other combustible gases. Cycle time: 5 minutes.
7
*
8
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
9
* http://www.libelium.com
10
*
11
* This program is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
20
*
21
* You should have received a copy of the GNU General Public License
22
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
*
24
* Version: 3.1
25
* Design: David Gascón
26
* Implementation: Alejandro Gállego
27
*/
28
29
#include <WaspSensorGas_Pro.h>
30
31
/*
32
* Define object for sensor: gas_PRO_sensor
33
* Input to choose board socket.
34
* Waspmote OEM. Possibilities for this sensor:
35
* - SOCKET_1
36
* P&S! Possibilities for this sensor:
37
* - SOCKET_A
38
* - SOCKET_B
39
* - SOCKET_C
40
* - SOCKET_F
41
*/
42
Gas gas_PRO_sensor(SOCKET_1);
43
44
float concentration; // Stores the concentration level in ppm
45
float temperature; // Stores the temperature in ºC
46
float humidity; // Stores the realitve humidity in %RH
47
float pressure; // Stores the pressure in Pa
48
49
void setup()
50
{
51
USB.println(F("Pellistor CH4 example"));
52
}
53
54
void loop()
55
{
56
///////////////////////////////////////////
57
// 1. Turn on the sensors
58
///////////////////////////////////////////
59
60
// Power on the pellistor sensor.
61
// If the gases PRO board is off, turn it on automatically.
62
gas_PRO_sensor.ON();
63
64
// The sensor needs time to warm up and get a response from gas
65
// To reduce the battery consumption, use deepSleep instead delay
66
// After 60 seconds, Waspmote wakes up thanks to the RTC Alarm
67
PWR.deepSleep("00:00:01:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);
68
69
///////////////////////////////////////////
70
// 2. Read sensors
71
///////////////////////////////////////////
72
73
// Read the pellistor sensor and compensate with the temperature internally
74
concentration = gas_PRO_sensor.getConc();
75
76
// Read enviromental variables
77
temperature = gas_PRO_sensor.getTemp();
78
humidity = gas_PRO_sensor.getHumidity();
79
pressure = gas_PRO_sensor.getPressure();
80
81
// And print the values via USB
82
USB.println(F("***************************************"));
83
USB.print(F("Gas concentration: "));
84
USB.print(concentration);
85
USB.println(F(" % LEL"));
86
USB.print(F("Temperature: "));
87
USB.print(temperature);
88
USB.println(F(" Celsius degrees"));
89
USB.print(F("RH: "));
90
USB.print(humidity);
91
USB.println(F(" %"));
92
USB.print(F("Pressure: "));
93
USB.print(pressure);
94
USB.println(F(" Pa"));
95
96
///////////////////////////////////////////
97
// 3. Power off sensors
98
///////////////////////////////////////////
99
100
// Power off the pellistor sensor.
101
// If there aren't more gas sensor powered, turn off the board automatically
102
gas_PRO_sensor.OFF();
103
104
///////////////////////////////////////////
105
// 5. Sleep
106
///////////////////////////////////////////
107
108
// Go to deepsleep
109
// After 4 minutes, Waspmote wakes up thanks to the RTC Alarm
110
PWR.deepSleep("00:00:04:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);
111
}
Copied!

Output

1
H#
2
Pellistor CH4 example
3
***************************************
4
Gas concentration: 3.9870300292 % LEL
5
Temperature: 23.8199996948 Celsius degrees
6
RH: 43.7714843750 %
7
Pressure: 99773.6250000000 Pa
8
***************************************
9
Gas concentration: 39299316406 % LEL
10
Temperature: 23.8299999237 Celsius degrees
11
RH: 43.8017578125 %
12
Pressure: 99769.9531250000 Pa
13
***************************************
14
Gas concentration: 3.9109802246 % LEL
15
Temperature: 23.8099994659 Celsius degrees
16
RH: 43.8007812500 %
17
Pressure: 99775.3281250000 Pa
18
***************************************
19
Gas concentration: 3.9679870605 % LEL
20
Temperature: 23.8600006103 Celsius degrees
21
RH: 43.7880859375 %
22
Pressure: 99768.2500000000 Pa
Copied!
Last modified 1yr ago