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 05: O2 Sensor Reading

In this example the Gases 2.0 board and the CO2 sensor are turned on, then reading the sensor every second while printing the output voltage through the USB.

Required Materials

1 x Waspmote
1 x Battery
1 x Gases 2.0 board
1 x O2 sensor (SK25)

Notes

* Remember to connect the battery to Waspmote for proper operation.
* The connection of the sensor is described in the Gases 2.0 technical guide.
* Take into account that the sensor output may vary from one sensor to another.
* This example can only be executed in Waspmote v12

Code

/*  
 *  ------ [Ga_5] - O2 Sensor for Gases v20-------- 
 *  
 *  Explanation: Turn on the Gases Board v20 and read the O2
 *  sensor every second, printing the result through the USB
 *  
 *  Copyright (C) 2012 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:    
 */

#include <WaspSensorGas_v20.h>

#define GAIN  100  //GAIN of the sensor stage

//Variable to store the read O2 value
float o2Val;

void setup()
{
  // Turn on the USB and print a start message
  USB.ON();
  USB.println(F("start"));
  delay(100);

  // Turn on the sensor board
  SensorGasv20.ON();

  // Turn on the RTC
  RTC.ON();

  // Configure the O2 sensor socket
  SensorGasv20.configureSensor(SENS_O2, GAIN);

  
  // Turn on the O2 sensor and wait for stabilization and
  // sensor response time
  SensorGasv20.setSensorMode(SENS_ON, SENS_O2);
  delay(10);
 
  
}
 
void loop()
{
  
  // Read the sensor 
  o2Val = SensorGasv20.readValue(SENS_O2);
  
  // Print the result through the USB
  USB.print(F("O2: "));
  USB.print(o2Val);
  USB.println(F("V"));
  
  delay(1000);
}

Output

B#
start
O2: 0.5225806236V
O2: 0.5225806236V
O2: 0.5225806236V

Quick Publish: