Development v12

Warning - Product Update

All the resources present on this section belong to Waspmote v12, Waspmote Plug & Sense! v12 and Meshlium v3.8.

If you have a Waspmote v15, Waspmote Plug & Sense! v15 or Meshlium v4.0 please go to the new Development Section.

Check what is your version and what are the differences between the old and the new one in this document.

» GP 12: HCl

This is the basic code to manage and read the hydrogen chloride (HCl) gas sensor. The concentration and the enviromental variables will be stored in a frame. Cycle time: 5 minutes

Required Materials

1 x Waspmote
1 x Battery
1 x Gases PRO board
1 x Temperature, Humidity and Pressure sensor BME280
1 x HCl 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 technical guide.
- Cycle time: 5 minutes
- This example can only be executed in Waspmote v12

Code

/*  
 *  ------------  [GP_12] - HCl  -------------- 
 *  
 *  Explanation: This is the basic code to manage and read the hydrogen 
 *  chloride (HCl) gas sensor. The concentration and the enviromental 
 *  variables will be stored in a frame. Cycle time: 5 minutes.
 *  
 *  Copyright (C) 2015 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:           0.1 
 *  Design:            David Gascón 
 *  Implementation:    Alejandro Gállego
 */

#include <WaspSensorGas_Pro.h>
#include <WaspFrame.h>

/*
 * Define object for sensor: HCl
 * Input to choose board socket. 
 * Waspmote OEM. Possibilities for this sensor:
 * 	- SOCKET_1 
 * 	- SOCKET_2
 * 	- SOCKET_3
 * 	- SOCKET_4
 * 	- SOCKET_5
 * 	- SOCKET_6
 * P&S! Possibilities for this sensor:
 * 	- SOCKET_A
 * 	- SOCKET_B
 * 	- SOCKET_C
 * 	- SOCKET_F
 */
Gas HCl(SOCKET_2);

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

char node_ID[] = "HCl_example";

void setup()
{
	USB.println(F("HCl example"));
	// Set the Waspmote ID
	frame.setID(node_ID);
}	


void loop()
{
	///////////////////////////////////////////
	// 1. Turn on the sensors
	/////////////////////////////////////////// 
	
	// Power on the HCl sensor. 
	// If the gases PRO board is off, turn it on automatically.
	HCl.ON();
	
	// The sensor needs time to warm up and get a response from gas
	// To reduce the battery consumption, use deepSleep instead delay
	// After 2 minutes, Waspmote wakes up thanks to the RTC Alarm
	PWR.deepSleep("00:00:02:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);
	
	
	///////////////////////////////////////////
	// 2. Read sensors
	///////////////////////////////////////////  
	
	// Read the HCl sensor and compensate with the temperature internally
	concentration = HCl.getConc();
	
	// Read enviromental variables
	temperature = HCl.getTemp();
	humidity = HCl.getHumidity();
	pressure = HCl.getPressure();
	
	
	///////////////////////////////////////////
	// 3. Turn off the sensors
	/////////////////////////////////////////// 
	
	// Power off the HCl sensor. If there aren't more gas sensors powered, 
	// turn off the board automatically
	HCl.OFF();
	
	
	///////////////////////////////////////////
	// 4. Create ASCII frame
	/////////////////////////////////////////// 
	
	// Create new frame (ASCII)
	frame.createFrame(ASCII);
	
	// Add HCl concentration
	frame.addSensor(SENSOR_GP_HCL, concentration);
	// Add temperature
	frame.addSensor(SENSOR_GP_TC, temperature);
	// Add humidity
	frame.addSensor(SENSOR_GP_HUM, humidity);
	// Add pressure
	frame.addSensor(SENSOR_GP_PRES, pressure);	
	
	// Show the frame
	frame.showFrame();
	
	
	///////////////////////////////////////////
	// 5. Sleep
	/////////////////////////////////////////// 
	
	// Go to deepsleep	
	// After 3 minutes, Waspmote wakes up thanks to the RTC Alarm
	PWR.deepSleep("00:00:03:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);
	
}

Output

E#
HCl example
===============================
Current ASCII Frame:
Length: 83
Frame Type: 128
frame (HEX): 3C3D3E8004233338323533373336382348436C5F6578616D706C6523302347505F48434C3A302E3033362347505F54433A32382E3730302347505F48554D3A34312E32332347505F505245533A393830373623
frame (STR): <=>€#382537368#HCl_example#0#GP_HCL:0.036#GP_TC:28.700#GP_HUM:41.23#GP_PRES:98076#
===============================
===============================
Current ASCII Frame:
Length: 83
Frame Type: 128
frame (HEX): 3C3D3E8004233338323533373336382348436C5F6578616D706C6523312347505F48434C3A302E3031322347505F54433A32382E3636302347505F48554D3A34312E33332347505F505245533A393830373123
frame (STR): <=>€#382537368#HCl_example#1#GP_HCL:0.012#GP_TC:28.660#GP_HUM:41.33#GP_PRES:98071#
===============================

Quick Publish: