Development

Sensors / Gases Board v30:

» Ga v30 12: AP1 sensor

Turn on the Gases Board v30 and read the Air Pollutans 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 Air Pollutants 1 sensor

Notes

- This example is valid only for Waspmote v15

Code

/*  
 *  ------ [Ga_v30_12] AP1 Sensor reading for v30  -------- 
 *  
 *  Explanation: Turn on the Gases Board v30 and read the Air Pollutans
 *  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>

// Air Pollutans Sensor can be connected in SOCKET6 or SOCKET7
APSensorClass APPSensor(SOCKET_7); // 

char node_ID[] = "APP_example";

void setup() 
{
  // Concentratios used in calibration process (in PPM)
  APPSensor.concentrations[POINT_1] = 10.0;  // <--- Ro value at this concentration
  APPSensor.concentrations[POINT_2] = 50.0 ;  
  APPSensor.concentrations[POINT_3] = 100.0; 
  
  // Calibration resistances obtained during calibration process (in Kohms)
  APPSensor.values[POINT_1] = 45.25; // <-- Ro Resistance at 100 ppm. Necessary value.
  APPSensor.values[POINT_2] = 25.665;  
  APPSensor.values[POINT_3] = 2.300;

  // Define the number of calibration points
  APPSensor.numPoints = 3;
  // Calculate the slope and the intersection of the logarithmic function
  APPSensor.setCalibrationPoints();

  // Configure the USB port
  USB.ON();  
  USB.println(F("Air Pollutans 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
  APPSensor.ON();
}

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

  float APPVol = APPSensor.readVoltage();         // Voltage value of the sensor
  float APPRes = APPSensor.readResistance();      // Resistance of the sensor
  float APP_PPM = APPSensor.readConcentration();  // PPM value of AP1

  // Print of the results
  USB.print(F("Air Pollutans Sensor Voltage: "));
  USB.print(APPVol);
  USB.print(F(" V |"));

  // Print of the results
  USB.print(F(" Air Pollutans Sensor Resistance: "));
  USB.print(APPRes);
  USB.print(F(" Ohms |"));

  USB.print(F(" Air Pollutans concentration Estimated: "));
  USB.print(APP_PPM);
  USB.println(F(" ppm"));
    
  ///////////////////////////////////////////
  // 3. Create ASCII frame
  /////////////////////////////////////////// 
  
  // Create new frame (ASCII)
  frame.createFrame(ASCII, node_ID);
  // Add CO2 PPM value
  frame.addSensor(SENSOR_GASES_AP1, APP_PPM);
  // Show the frame
  frame.showFrame();
  
  delay(5000);
}

Output

H#
Air Pollutans Sensor reading for v30...
Air Pollutans Sensor Voltage: 0.1882638835 V | Air Pollutans Sensor Resistance: 82492.6328125000 Ohms | Air Pollutans concentration Estimated: 9.3910455703 ppm
===============================
Current ASCII Frame:
Length: 47
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234150505F6578616D706C652330234150313A392E33393123
frame (STR): <=>�#41187063D93742F4#APP_example#0#AP1:9.391#
===============================
Air Pollutans Sensor Voltage: 2.3680553436 V | Air Pollutans Sensor Resistance: 6057.3320312500 Ohms | Air Pollutans concentration Estimated: 89.4522018432 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234150505F6578616D706C652331234150313A38392E34353223
frame (STR): <=>�#41187063D93742F4#APP_example#1#AP1:89.452#
===============================
Air Pollutans Sensor Voltage: 2.3680553436 V | Air Pollutans Sensor Resistance: 6057.3320312500 Ohms | Air Pollutans concentration Estimated: 89.4522018432 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234150505F6578616D706C652332234150313A38392E34353223
frame (STR): <=>�#41187063D93742F4#APP_example#2#AP1:89.452#
===============================
Air Pollutans Sensor Voltage: 2.3680553436 V | Air Pollutans Sensor Resistance: 6057.3320312500 Ohms | Air Pollutans concentration Estimated: 89.4522018432 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234150505F6578616D706C652333234150313A38392E34353223
frame (STR): <=>�#41187063D93742F4#APP_example#3#AP1:89.452#
===============================
Air Pollutans Sensor Voltage: 2.3680553436 V | Air Pollutans Sensor Resistance: 6057.3320312500 Ohms | Air Pollutans concentration Estimated: 89.4522018432 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234150505F6578616D706C652334234150313A38392E34353223
frame (STR): <=>�#41187063D93742F4#APP_example#4#AP1:89.452#
===============================
Air Pollutans Sensor Voltage: 2.3680553436 V | Air Pollutans Sensor Resistance: 6057.3320312500 Ohms | Air Pollutans concentration Estimated: 89.4522018432 ppm
===============================
Current ASCII Frame:
Length: 48
Frame Type: 134
frame (HEX): 3C3D3E86012334313138373036334439333734324634234150505F6578616D706C652335234150313A38392E34353223
frame (STR): <=>�#41187063D93742F4#APP_example#5#AP1:89.452#
===============================
...

Quick Publish: