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
/*
* ------------ [GP_v30_03] - Pellistor gas sensors --------------
*
* Explanation: This is the basic code to manage and read the
* pellistor sensor. These sensors include: methane (CH4)
* and other combustible gases. Cycle time: 5 minutes.
*
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 3.1
* Design: David Gascón
* Implementation: Alejandro Gállego
*/
#include <WaspSensorGas_Pro.h>
/*
* Define object for sensor: gas_PRO_sensor
* Input to choose board socket.
* Waspmote OEM. Possibilities for this sensor:
* - SOCKET_1
* P&S! Possibilities for this sensor:
* - SOCKET_A
* - SOCKET_B
* - SOCKET_C
* - SOCKET_F
*/
Gas gas_PRO_sensor(SOCKET_1);
float concentration; // Stores the concentration level in ppm
float temperature; // Stores the temperature in ºC
float humidity; // Stores the realitve humidity in %RH
float pressure; // Stores the pressure in Pa
void setup()
{
USB.println(F("Pellistor CH4 example"));
}
void loop()
{
///////////////////////////////////////////
// 1. Turn on the sensors
///////////////////////////////////////////
// Power on the pellistor sensor.
// If the gases PRO board is off, turn it on automatically.
gas_PRO_sensor.ON();
// The sensor needs time to warm up and get a response from gas
// To reduce the battery consumption, use deepSleep instead delay
// After 60 seconds, Waspmote wakes up thanks to the RTC Alarm
PWR.deepSleep("00:00:01:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);
///////////////////////////////////////////
// 2. Read sensors
///////////////////////////////////////////
// Read the pellistor sensor and compensate with the temperature internally
concentration = gas_PRO_sensor.getConc();
// Read enviromental variables
temperature = gas_PRO_sensor.getTemp();
humidity = gas_PRO_sensor.getHumidity();
pressure = gas_PRO_sensor.getPressure();
// And print the values via USB
USB.println(F("***************************************"));
USB.print(F("Gas concentration: "));
USB.print(concentration);
USB.println(F(" % LEL"));
USB.print(F("Temperature: "));
USB.print(temperature);
USB.println(F(" Celsius degrees"));
USB.print(F("RH: "));
USB.print(humidity);
USB.println(F(" %"));
USB.print(F("Pressure: "));
USB.print(pressure);
USB.println(F(" Pa"));
///////////////////////////////////////////
// 3. Power off sensors
///////////////////////////////////////////
// Power off the pellistor sensor.
// If there aren't more gas sensor powered, turn off the board automatically
gas_PRO_sensor.OFF();
///////////////////////////////////////////
// 5. Sleep
///////////////////////////////////////////
// Go to deepsleep
// After 4 minutes, Waspmote wakes up thanks to the RTC Alarm
PWR.deepSleep("00:00:04:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);
}
Output
H#
Pellistor CH4 example
***************************************
Gas concentration: 3.9870300292 % LEL
Temperature: 23.8199996948 Celsius degrees
RH: 43.7714843750 %
Pressure: 99773.6250000000 Pa
***************************************
Gas concentration: 39299316406 % LEL
Temperature: 23.8299999237 Celsius degrees
RH: 43.8017578125 %
Pressure: 99769.9531250000 Pa
***************************************
Gas concentration: 3.9109802246 % LEL
Temperature: 23.8099994659 Celsius degrees
RH: 43.8007812500 %
Pressure: 99775.3281250000 Pa
***************************************
Gas concentration: 3.9679870605 % LEL
Temperature: 23.8600006103 Celsius degrees
RH: 43.7880859375 %
Pressure: 99768.2500000000 Pa
Last updated