Development

Sensors / Gases Board v30:

» Ga v30 11: LPG sensor

Turn on the Gases Board v30 and read the LPG sensor every five seconds, printing the result through the USB

Required Materials

1 x Waspmote
1 x Battery
1 x MiniUSB wire
1 x Gases Board v30
1 x LPG sensor

Notes

- This example is valid only for Waspmote v15

Code

/*  
 *  ------ [Ga_v30_11] LPG Sensor reading for v30  -------- 
 *  
 *  Explanation: Turn on the Gases Board v30 and read the LPG
 *  sensor every five seconds, printing the result through the USB
 *  
 *  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.0
 *  Design:            David Gascón 
 *  Implementation:    Ahmad Saad
 */

// Library include
#include <WaspSensorGas_v30.h>
#include <WaspFrame.h>


// LPG Sensor can be connected in SOCKET6 or SOCKET7
LPGSensorClass LPGSensor(SOCKET_7);

// Concentratios used in calibration process (PPM VALUE)
#define POINT1_PPM_LPG 10.0   //  <-- Normal concentration in air
#define POINT2_PPM_LPG 50.0   
#define POINT3_PPM_LPG 100.0
  
// Calibration voltages obtained during calibration process (in KOHMs)
#define POINT1_RES_LPG 45.25  // <-- Rs at normal concentration in air
#define POINT2_RES_LPG 25.50
#define POINT3_RES_LPG 3.55
  
// Define the number of calibration points
#define numPoints 3
  
float concentrations[] = {POINT1_PPM_LPG, POINT2_PPM_LPG, POINT3_PPM_LPG};
float resValues[] =      {POINT1_RES_LPG, POINT2_RES_LPG, POINT3_RES_LPG};

char node_ID[] = "LPG_example";

void setup() 
{
  // Configure the USB port
  USB.ON();  
  USB.println(F("LPG Sensor reading for v30..."));

  // Calculate the slope and the intersection of the logarithmic function
  LPGSensor.setCalibrationPoints(resValues, concentrations, numPoints);

  ///////////////////////////////////////////
  // 1. Turn on the board and the SOCKET
  /////////////////////////////////////////// 
  
  // Switch ON and configure the Gases Board
  Gases.ON();  
  // Switch ON the sensor socket
  LPGSensor.ON();
}

void loop()
{
  ///////////////////////////////////////////
  // 2. Read sensors
  /////////////////////////////////////////// 

  float LPGVol = LPGSensor.readVoltage();         // Voltage value of the sensor
  float LPGRes = LPGSensor.readResistance();      // Resistance of the sensor
  float LPGPPM = LPGSensor.readConcentration();   // PPM value of LPG

  // Print of the results
  USB.print(F("LPG Sensor Voltage: "));
  USB.print(LPGVol);
  USB.print(F(" V |"));

  // Print of the results
  USB.print(F(" LPG Sensor Resistance: "));
  USB.print(LPGRes);
  USB.print(F(" Ohms |"));

  USB.print(F(" LPG concentration Estimated: "));
  USB.print(LPGPPM);
  USB.println(F(" ppm"));
    
  ///////////////////////////////////////////
  // 3. Create ASCII frame
  /////////////////////////////////////////// 
  
  // Create new frame (ASCII)
  frame.createFrame(ASCII, node_ID);
  // Add LPG PPM value
  frame.addSensor(SENSOR_GASES_LPG, LPGPPM);
  // Show the frame
  frame.showFrame();
  
  delay(5000);

}

Output

H#
LPG Sensor reading for v30...
LPG Sensor Voltage: 0.4040971755 V | LPG Sensor Resistance: 32319.5078125000 Ohms | LPG concentration Estimated: 65.9921035766 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652330234C50473A36352E39393223
frame (STR): <=>�#41187063D93742F4#LPG_example#0#LPG:65.992#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652331234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#1#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652332234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#2#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652333234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#3#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652334234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#4#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652335234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#5#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652336234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#6#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652337234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#7#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652338234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#8#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C652339234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#9#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C65233130234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#10#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C65233131234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#11#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C65233132234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#12#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C65233133234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#13#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C65233134234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#14#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C65233135234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#15#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C65233136234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#16#LPG:92.388#
===============================
LPG Sensor Voltage: 2.3680553436 V | LPG Sensor Resistance: 6057.3320312500 Ohms | LPG concentration Estimated: 92.3876037597 ppm
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234C50475F6578616D706C65233137234C50473A39322E33383823
frame (STR): <=>�#41187063D93742F4#LPG_example#17#LPG:92.388#
===============================
...

Quick Publish: