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.

» Ga 15: Frame Class Utility

This is the basic code to create a frame with some Gases Sensor Board sensors

Required Materials

1 x Waspmote
1 x Battery
1 x Gases 2.0 board


* This example can only be executed in Waspmote v12


 *  ------------  [Ga_15] - Frame Class Utility  -------------- 
 *  Explanation: This is the basic code to create a frame with some
 * 	Gases Sensor Board sensors
 *  Copyright (C) 2015 Libelium Comunicaciones Distribuidas S.L. 
 *  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
 *  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 <>.
 *  Version:		    0.1
 *  Design:             David Gascón
 *  Implementation:     Luis Miguel Marti

#include <WaspSensorGas_v20.h>
#include <WaspFrame.h>

#define GAINCO2  7  //GAIN of the sensor stage
#define GAINO2  100 //GAIN of the sensor stage
#define GAINSOCKET2A  1      //GAIN of the sensor stage
#define RESISTOR2A 20  //LOAD RESISTOR of the sensor stage
#define GAINSOCKET2B  1      //GAIN of the sensor stage
#define RESISTOR2B 20  //LOAD RESISTOR of the sensor stage
#define GAINSOCKET3A  1      //GAIN of the sensor stage
#define RESISTOR3A 20  //LOAD RESISTOR of the sensor stage
#define GAINSOCKET3B  1      //GAIN of the sensor stage
#define RESISTOR3B 20  //LOAD RESISTOR of the sensor stage
#define GAINSOCKET4A  1      //GAIN of the sensor stage
#define RESISTOR4A 20  //LOAD RESISTOR of the sensor stage
#define GAINCO  1      // GAIN of the sensor stage
#define RESISTORCO 100  // LOAD RESISTOR of the sensor stage
#define GAINNH3  1      // GAIN of the sensor stage
#define RESISTORNH3 10  // LOAD RESISTOR of the sensor stage

float temperature; 
float humidity; 
float pressure;
float co2Val;
float o2Val;
float socket2AVal;
float socket2BVal;
float socket3AVal;
float socket3BVal;
float socket4AVal;
float socketCOVal;
float socketNH3Val;
float coVal;

char node_ID[] = "Node_01";

void setup() 
  USB.println(F("Frame Utility Example for Gases Sensor Board"));

  // Set the Waspmote ID
  //Power gases board and wait for stabilization and sensor response time

void loop()
  // 1. Turn on and configure sensors and wait for stabilization 
  //	and sensor response time

  // Power on the atmospheric pressure sensor
  SensorGasv20.setSensorMode(SENS_ON, SENS_PRESSURE);
  // Configure the CO2 sensor socket
  SensorGasv20.configureSensor(SENS_CO2, GAINCO2);
  // Power on the CO2 sensor
  SensorGasv20.setSensorMode(SENS_ON, SENS_CO2);
  // Configure the O2 sensor socket
  SensorGasv20.configureSensor(SENS_O2, GAINO2);
  // Power on the O2 sensor
  SensorGasv20.setSensorMode(SENS_ON, SENS_O2);
  // Configure the 2A sensor socket
  SensorGasv20.configureSensor(SENS_SOCKET2A, GAINSOCKET2A, RESISTOR2A);
  // Power on the 2A sensor socket
  SensorGasv20.setSensorMode(SENS_ON, SENS_SOCKET2A);
  // Configure the 2B sensor socket
  SensorGasv20.configureSensor(SENS_SOCKET2B, GAINSOCKET2B, RESISTOR2B);
  // Power on the 2B sensor socket
  SensorGasv20.setSensorMode(SENS_ON, SENS_SOCKET2B);
  // Configure the 3B sensor socket
  SensorGasv20.configureSensor(SENS_SOCKET3B, GAINSOCKET3B, RESISTOR3B);
  // Power on the 3B sensor socket
  SensorGasv20.setSensorMode(SENS_ON, SENS_SOCKET3B);
  // Configure the CO sensor socket
  SensorGasv20.configureSensor(SENS_SOCKET4CO, GAINCO, RESISTORCO);
  // Power on the 3A sensor socket
  SensorGasv20.setSensorMode(SENS_ON, SENS_SOCKET3A);
  // Configure the NH3 sensor on socket 3
  SensorGasv20.configureSensor(SENS_SOCKET3NH3, GAINNH3, RESISTORNH3);

  // 2. Read sensors

  // Read the temperature sensor
  temperature = SensorGasv20.readValue(SENS_TEMPERATURE);
  // Read the humidity sensor
  humidity = SensorGasv20.readValue(SENS_HUMIDITY);
  // Read the pressure sensor
  pressure = SensorGasv20.readValue(SENS_PRESSURE);
  // Read the CO2 sensor 
  co2Val = SensorGasv20.readValue(SENS_CO2);
  // Read the sensor 
  o2Val = SensorGasv20.readValue(SENS_O2);
  // Read the 2A sensor socket
  socket2AVal = SensorGasv20.readValue(SENS_SOCKET2A);
  // Conversion from voltage into kiloohms
  socket2AVal = SensorGasv20.calculateResistance(	SENS_SOCKET2A, 
  // Read the 2B sensor socket
  socket2BVal = SensorGasv20.readValue(SENS_SOCKET2B);
  // Conversion from voltage into kiloohms
  socket2BVal = SensorGasv20.calculateResistance(	SENS_SOCKET2B, 
  // Read the 3B sensor socket
  socket3BVal = SensorGasv20.readValue(SENS_SOCKET3B);
  // Conversion from voltage into kiloohms
  socket3BVal = SensorGasv20.calculateResistance(	SENS_SOCKET3B, 
  // Read the CO sensor socket
  socketCOVal = SensorGasv20.readValue(SENS_SOCKET4CO);
  // Conversion from voltage into kiloohms
  socketCOVal = SensorGasv20.calculateResistance(	SENS_SOCKET4CO, 
  // Read the NH3 sensor socket
  socketNH3Val = SensorGasv20.readValue(SENS_SOCKET3NH3);
  // Conversion from voltage into kiloohms
  socketNH3Val = SensorGasv20.calculateResistance(	SENS_SOCKET3NH3, 

  // 3. Turn off the sensors

  // Power off the atmospheric pressure sensor
  SensorGasv20.setSensorMode(SENS_OFF, SENS_PRESSURE);
  // Power off the CO2 sensor
  SensorGasv20.setSensorMode(SENS_OFF, SENS_CO2);
  // Power off the O2 sensor
  SensorGasv20.setSensorMode(SENS_OFF, SENS_O2);
  // Power off the 2A sensor socket
  SensorGasv20.setSensorMode(SENS_OFF, SENS_SOCKET2A);
  // Power off the 2B sensor socket
  SensorGasv20.setSensorMode(SENS_OFF, SENS_SOCKET2B);
  // Power off the 3B sensor socket
  SensorGasv20.setSensorMode(SENS_OFF, SENS_SOCKET3B);

  // 4. Create ASCII frame

  // Create new frame (ASCII)

  // Add temperature
  frame.addSensor(SENSOR_TCA, temperature);
  // Add humidity
  frame.addSensor(SENSOR_HUMA, humidity);
  // Add pressure value
  frame.addSensor(SENSOR_PA, pressure);
  // Add CO2 value
  frame.addSensor(SENSOR_CO2, co2Val);
  // Add O2 value
  frame.addSensor(SENSOR_O2, o2Val);
  // Add CO value
  frame.addSensor(SENSOR_CO, socketCOVal);
  // Add NH3 value
  frame.addSensor(SENSOR_NH3, socketNH3Val);
  // Add NO2 value
  frame.addSensor(SENSOR_NO2, socket3BVal);
  // Add CO2 value
  frame.addSensor(SENSOR_O3, socket2BVal);
  // Add NH4 value
  frame.addSensor(SENSOR_CH4, socket2AVal);

  // Show the frame

  //wait 2 seconds

Quick Publish: