Development

» Ga v30 09: NO2 sensor

Turn on the Gases Board v30 and read the NO2 sensor every second, 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 NO2 sensor

Notes

- This example is valid only for Waspmote v15

Code

/*  
 *  ------ [Ga_v30_9] NO2 Sensor reading for v30  -------- 
 *  
 *  Explanation: Turn on the Gases Board v30 and read the NO2
 *  sensor every second, 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>

// NO2 Sensor must be connected physically in SOCKET_3
NO2SensorClass NO2Sensor; 

// Concentrations used in calibration process
#define POINT1_PPM_NO2 10.0   // <-- Normal concentration in air
#define POINT2_PPM_NO2 50.0   
#define POINT3_PPM_NO2 100.0 

// Calibration voltages obtained during calibration process (in KOHMs)
#define POINT1_RES_NO2 45.25  // <-- Rs at normal concentration in air
#define POINT2_RES_NO2 25.50
#define POINT3_RES_NO2 3.55

// Define the number of calibration points
#define numPoints 3

float concentrations[] = {POINT1_PPM_NO2, POINT2_PPM_NO2, POINT3_PPM_NO2};
float voltages[] =       {POINT1_RES_NO2, POINT2_RES_NO2, POINT3_RES_NO2};

char node_ID[] = "NO2_example";

void setup() 
{
  // Calculate the slope and the intersection of the logarithmic function
  NO2Sensor.setCalibrationPoints(voltages, concentrations, numPoints);
  // Configure the USB port
  USB.ON();
  USB.println(F("NO2 Sensor reading for v30..."));

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

void loop()
{  
  //////////////////////////////////////////
  // 2. Read sensors
  /////////////////////////////////////////
  
  // PPM value of NO2
  float NO2Vol = NO2Sensor.readVoltage();       // Voltage value of the sensor
  float NO2Res = NO2Sensor.readResistance();    // Resistance of the sensor
  float NO2PPM = NO2Sensor.readConcentration(); // PPM value of NO2

  // Print of the results
  USB.print(F("NO2 Sensor Voltage: "));
  USB.print(NO2Vol);
  USB.print(F(" V |"));
  
  // Print of the results
  USB.print(F(" NO2 Sensor Resistance: "));
  USB.print(NO2Res);
  USB.print(F(" Ohms |"));

  // Print of the results
  USB.print(F(" NO2 concentration Estimated: "));
  USB.print(NO2PPM);
  USB.println(F(" PPM"));

  ///////////////////////////////////////////
  // 3. Create ASCII frame
  /////////////////////////////////////////// 

  // Create new frame (ASCII)
  frame.createFrame(ASCII, node_ID);
  // Add VOC PPM value
  frame.addSensor(SENSOR_GASES_NO2, NO2PPM);
  // Show the frame
  frame.showFrame();
  
  delay(1000);  
}




Output

H#
NO2 Sensor reading for v30...
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652330234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#0#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652331234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#1#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652332234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#2#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652333234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#3#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652334234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#4#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652335234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#5#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652336234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#6#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652337234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#7#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652338234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#8#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 49
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C652339234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#9#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233130234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#10#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233131234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#11#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233132234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#12#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233133234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#13#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233134234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#14#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233135234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#15#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233136234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#16#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233137234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#17#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233138234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#18#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233139234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#19#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233230234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#20#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233231234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#21#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233232234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#22#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233233234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#23#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233234234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#24#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233235234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#25#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233236234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#26#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233237234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#27#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233238234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#28#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233239234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#29#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233330234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#30#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233331234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#31#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233332234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#32#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233333234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#33#NO2:122.973#
===============================
NO2 Sensor Voltage: 2.3680553436 V | NO2 Sensor Resistance: -2998.5332031250 Ohms | NO2 concentration Estimated: 122.9727172851 PPM
===============================
Current ASCII Frame:
Length: 50
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234E4F325F6578616D706C65233334234E4F323A3132322E39373323
frame (STR): <=>�#41187063D93742F4#NO2_example#34#NO2:122.973#
===============================

Quick Publish: