Strange values of sensors

Questions about the Waspmote board and its modules
Post Reply
dimitar
Posts: 5
Joined: Mon Feb 04, 2019 1:21 pm
Company: Vista Group

Strange values of sensors

Post by dimitar » Mon Feb 04, 2019 3:13 pm

Hi,
I have issue with with getting wrong data from sensors connected on Plug & Sense. We have 6 Plug&Sense controllers. Only few of them make this problem. Each Plug&Sense have 9370-P, 9371-P and 9372-P sensors
We receive values -1000 for Temperature, Humidity and Pressure.
How can we solve this issue?

Print screen from meshlium received data can be saw at: https://1drv.ms/u/s!AiYtK7frMQ-8h94gMzIMsGNjiGZ4ZQ

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Strange values of sensors

Post by libelium-dev » Tue Feb 05, 2019 9:24 am

Hi,

What code did you upload to the nodes? What P&S model do you have? In which socket did you connect the sensor?

Usually -1000 values for temp, hum, press sensor means a error in the I2C bus caused by a erroneous code.

Regards

dimitar
Posts: 5
Joined: Mon Feb 04, 2019 1:21 pm
Company: Vista Group

Re: Strange values of sensors

Post by dimitar » Tue Feb 05, 2019 9:48 am

Hi,
thanks for prompt answer.
we use same code on 6 P&S. Only on 3 we have that problem. All P&S have same sensors connected on sockets according manual.
Because P&S are installed on remote location, at this moment I can't check model version.

Regards

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Strange values of sensors

Post by libelium-dev » Wed Feb 06, 2019 10:44 am

Hi,

The I2C errors are aleatory, they can happen in some P&S and another P&Ss can work properly without errors.

What code did you upload to the nodes? What API version did you use?

Did they work at the beginning?

Regards

dimitar
Posts: 5
Joined: Mon Feb 04, 2019 1:21 pm
Company: Vista Group

Re: Strange values of sensors

Post by dimitar » Wed Feb 06, 2019 12:42 pm

Hi,
all of P&S work fine at beginning. We uste code from below
#include <WaspSensorGas_v30.h>
#include <WaspFrame.h>
#include <WaspXBee868LP.h>
#include <BME280.h>
#include <WaspSensorGas_Pro.h>

// CO Sensor must be connected physically in SOCKET_4
COSensorClass COSensor;
char RX_ADDRESS[] = "0013a200415c61ae";
char WASPMOTE_ID[] = "NPP1";
uint8_t error;
CO2SensorClass CO2Sensor;
// Concentratios used in calibration process
#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration
#define POINT2_PPM_CO 300.0 //
#define POINT3_PPM_CO 1000.0 //

// Calibration resistances obtained during calibration process
#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value.
#define POINT2_RES_CO 40.665 //
#define POINT3_RES_CO 20.300 //

#define POINT1_PPM_CO2 350.0 // <-- Normal concentration in air
#define POINT2_PPM_CO2 1000.0
#define POINT3_PPM_CO2 3000.0

// Calibration vVoltages obtained during calibration process (Volts)
#define POINT1_VOLT_CO2 0.300
#define POINT2_VOLT_CO2 0.350
#define POINT3_VOLT_CO2 0.380

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

float concentrations[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO };
float resValues[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO };

float concentrationsCo2[] = { POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2 };
float voltages[] = { POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2 };

char node_ID[] = "NPP1";

float temperature; // Stores the temperature in ºC
float humidity; // Stores the realitve humidity in %RH
float pressure; // Stores the pressure in Pa


void setup()
{
// Configure the USB port
USB.ON();
USB.println(F("Sensor reading for v30..."));

// Calculate the slope and the intersection of the logarithmic function
COSensor.setCalibrationPoints(resValues, concentrations, numPoints);
CO2Sensor.setCalibrationPoints(voltages, concentrationsCo2, numPoints);
///////////////////////////////////////////
// 1. Turn on the board and the SOCKET
///////////////////////////////////////////

// Switch ON and configure the Gases Board
Gases.ON();
// Switch ON the sensor socket
COSensor.ON();
CO2Sensor.ON();

frame.setID( WASPMOTE_ID );
xbee868LP.ON();

pinMode(GP_I2C_MAIN_EN, OUTPUT);
}

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

digitalWrite(GP_I2C_MAIN_EN, HIGH);
BME.ON();

temperature = BME.getTemperature(BME280_OVERSAMP_16X, BME280_FILTER_COEFF_OFF);
humidity = BME.getHumidity(BME280_OVERSAMP_16X);
pressure = BME.getPressure(BME280_OVERSAMP_16X, BME280_FILTER_COEFF_OFF);

digitalWrite(GP_I2C_MAIN_EN, LOW);

USB.println(F("***************************************"));
USB.print(F("Temperature: "));
USB.print(temperature);
USB.println(F(" Celsius degrees"));
USB.print(F("RH: "));
USB.print(humidity);
USB.println(F(" %"));
USB.print(F("Pressure: "));
USB.print(pressure);
USB.println(F(" Pa"));

float COVol = COSensor.readVoltage(); // Voltage value of the sensor
float CORes = COSensor.readResistance(); // Resistance of the sensor
float COPPM = COSensor.readConcentration(); // PPM value of CO
float CO2PPM = CO2Sensor.readConcentration();

// Print of the results
USB.print(F("CO Sensor Voltage: "));
USB.print(COVol);
USB.print(F(" mV |"));

// Print of the results
USB.print(F(" CO Sensor Resistance: "));
USB.print(CORes);
USB.print(F(" Ohms |"));

USB.print(F(" CO concentration Estimated: "));
USB.print(COPPM);
USB.println(F(" ppm"));

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

// Create new frame (ASCII)
frame.createFrame(ASCII, node_ID);
// Add CO PPM value
frame.addSensor(SENSOR_GASES_CO, COPPM);
frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel());
frame.addSensor(SENSOR_GASES_TC, temperature);
// Add humidity
frame.addSensor(SENSOR_GASES_HUM, humidity);
// Add pressure
frame.addSensor(SENSOR_GASES_PRES, pressure);
frame.addSensor(SENSOR_GASES_CO2, CO2PPM);

// Show the frame
frame.showFrame();
error = xbee868LP.send( RX_ADDRESS, frame.buffer, frame.length );

if( error == 0 )
{
USB.println(F("send ok"));

// blink green LED
Utils.blinkGreenLED();

}
else
{
USB.println(F("send error"));

// blink red LED
Utils.blinkRedLED();
}

delay(10000);
}

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Strange values of sensors

Post by libelium-dev » Thu Feb 07, 2019 9:37 am

Hi,

Please try to read the BME sensor as is showed here. It this way, the I2C bus is managed in the library. It isn't recommended to manage the I2C bus in the code by yourself.

Code: Select all

#include <WaspSensorGas_v30.h>
#include <WaspFrame.h>
#include <WaspXBee868LP.h>
#include <BME280.h>

// CO Sensor must be connected physically in SOCKET_4
COSensorClass COSensor;
char RX_ADDRESS[] = "0013a200415c61ae";
char WASPMOTE_ID[] = "NPP1";
uint8_t error;
CO2SensorClass CO2Sensor;
// Concentratios used in calibration process
#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration
#define POINT2_PPM_CO 300.0 //
#define POINT3_PPM_CO 1000.0 //

// Calibration resistances obtained during calibration process
#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value.
#define POINT2_RES_CO 40.665 //
#define POINT3_RES_CO 20.300 //

#define POINT1_PPM_CO2 350.0 // <-- Normal concentration in air
#define POINT2_PPM_CO2 1000.0
#define POINT3_PPM_CO2 3000.0

// Calibration vVoltages obtained during calibration process (Volts)
#define POINT1_VOLT_CO2 0.300
#define POINT2_VOLT_CO2 0.350
#define POINT3_VOLT_CO2 0.380

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

float concentrations[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO };
float resValues[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO };

float concentrationsCo2[] = { POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2 };
float voltages[] = { POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2 };

char node_ID[] = "NPP1";

float temperature; // Stores the temperature in ºC
float humidity; // Stores the realitve humidity in %RH
float pressure; // Stores the pressure in Pa


void setup()
{
  // Configure the USB port
  USB.ON();
  USB.println(F("Sensor reading for v30..."));

  // Calculate the slope and the intersection of the logarithmic function
  COSensor.setCalibrationPoints(resValues, concentrations, numPoints);
  CO2Sensor.setCalibrationPoints(voltages, concentrationsCo2, numPoints);
  ///////////////////////////////////////////
  // 1. Turn on the board and the SOCKET
  ///////////////////////////////////////////

  // Switch ON and configure the Gases Board
  Gases.ON();
  // Switch ON the sensor socket
  COSensor.ON();
  CO2Sensor.ON();

  frame.setID( WASPMOTE_ID );
  xbee868LP.ON();

}

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

  temperature = Gases.getTemperature();
  humidity = Gases.getHumidity();
  pressure = Gases.getPressure();

  USB.println(F("***************************************"));
  USB.print(F("Temperature: "));
  USB.print(temperature);
  USB.println(F(" Celsius degrees"));
  USB.print(F("RH: "));
  USB.print(humidity);
  USB.println(F(" %"));
  USB.print(F("Pressure: "));
  USB.print(pressure);
  USB.println(F(" Pa"));

  float COVol = COSensor.readVoltage(); // Voltage value of the sensor
  float CORes = COSensor.readResistance(); // Resistance of the sensor
  float COPPM = COSensor.readConcentration(); // PPM value of CO
  float CO2PPM = CO2Sensor.readConcentration();

  // Print of the results
  USB.print(F("CO Sensor Voltage: "));
  USB.print(COVol);
  USB.print(F(" mV |"));

  // Print of the results
  USB.print(F(" CO Sensor Resistance: "));
  USB.print(CORes);
  USB.print(F(" Ohms |"));

  USB.print(F(" CO concentration Estimated: "));
  USB.print(COPPM);
  USB.println(F(" ppm"));

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

  // Create new frame (ASCII)
  frame.createFrame(ASCII, node_ID);
  // Add CO PPM value
  frame.addSensor(SENSOR_GASES_CO, COPPM);
  frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel());
  frame.addSensor(SENSOR_GASES_TC, temperature);
  // Add humidity
  frame.addSensor(SENSOR_GASES_HUM, humidity);
  // Add pressure
  frame.addSensor(SENSOR_GASES_PRES, pressure);
  frame.addSensor(SENSOR_GASES_CO2, CO2PPM);

  // Show the frame
  frame.showFrame();
  error = xbee868LP.send( RX_ADDRESS, frame.buffer, frame.length );

  if ( error == 0 )
  {
    USB.println(F("send ok"));

    // blink green LED
    Utils.blinkGreenLED();

  }
  else
  {
    USB.println(F("send error"));

    // blink red LED
    Utils.blinkRedLED();
  }

  delay(10000);
}[/code

Regards

dimitar
Posts: 5
Joined: Mon Feb 04, 2019 1:21 pm
Company: Vista Group

Re: Strange values of sensors

Post by dimitar » Wed Feb 27, 2019 10:36 am

Hi,
thanks for answer. This was helpful. We have one more issue. We want to send data every 3 minutes. We use configuration below, but data arrive on Meshlium every 15 sec. Please advise how to fix this.

#include <WaspSensorGas_v30.h>
#include <WaspFrame.h>
#include <WaspXBee868LP.h>
#include <BME280.h>

// CO Sensor must be connected physically in SOCKET_4
COSensorClass COSensor;
char RX_ADDRESS[] = "0013a200415c61ae";
char WASPMOTE_ID[] = "NPP3";
uint8_t error;
CO2SensorClass CO2Sensor;
// Concentratios used in calibration process
#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration
#define POINT2_PPM_CO 300.0 //
#define POINT3_PPM_CO 1000.0 //

// Calibration resistances obtained during calibration process
#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value.
#define POINT2_RES_CO 40.665 //
#define POINT3_RES_CO 20.300 //

#define POINT1_PPM_CO2 350.0 // <-- Normal concentration in air
#define POINT2_PPM_CO2 1000.0
#define POINT3_PPM_CO2 3000.0

// Calibration vVoltages obtained during calibration process (Volts)
#define POINT1_VOLT_CO2 0.300
#define POINT2_VOLT_CO2 0.350
#define POINT3_VOLT_CO2 0.380

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

float concentrations[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO };
float resValues[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO };

float concentrationsCo2[] = { POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2 };
float voltages[] = { POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2 };

char node_ID[] = "NPP3";

float temperature; // Stores the temperature in ºC
float humidity; // Stores the realitve humidity in %RH
float pressure; // Stores the pressure in Pa


void setup()
{
// Configure the USB port
USB.ON();
USB.println(F("Sensor reading for v30..."));

// Calculate the slope and the intersection of the logarithmic function
COSensor.setCalibrationPoints(resValues, concentrations, numPoints);
CO2Sensor.setCalibrationPoints(voltages, concentrationsCo2, numPoints);
///////////////////////////////////////////
// 1. Turn on the board and the SOCKET
///////////////////////////////////////////


frame.setID( WASPMOTE_ID );
xbee868LP.ON();
}

void loop()
{

// Switch ON and configure the Gases Board
Gases.ON();
// Switch ON the sensor socket
COSensor.ON();
CO2Sensor.ON();

PWR.deepSleep("00:00:01:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);

//////////////////////////////////////////
// 2. Read sensors
//////////////////////////////////////////
temperature = Gases.getTemperature();
humidity = Gases.getHumidity();
pressure = Gases.getPressure();

USB.println(F("***************************************"));
USB.print(F("Temperature: "));
USB.print(temperature);
USB.println(F(" Celsius degrees"));
USB.print(F("RH: "));
USB.print(humidity);
USB.println(F(" %"));
USB.print(F("Pressure: "));
USB.print(pressure);
USB.println(F(" Pa"));

float COVol = COSensor.readVoltage(); // Voltage value of the sensor
float CORes = COSensor.readResistance(); // Resistance of the sensor
float COPPM = COSensor.readConcentration(); // PPM value of CO
//float CO2PPM = CO2Sensor.readConcentration();

// Print of the results
USB.print(F("CO Sensor Voltage: "));
USB.print(COVol);
USB.print(F(" mV |"));

// Print of the results
USB.print(F(" CO Sensor Resistance: "));
USB.print(CORes);
USB.print(F(" Ohms |"));

USB.print(F(" CO concentration Estimated: "));
USB.print(COPPM);
USB.println(F(" ppm"));

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

// Create new frame (ASCII)
frame.createFrame(ASCII, node_ID);
// Add CO PPM value
frame.addSensor(SENSOR_GASES_CO, COPPM);
frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel());
frame.addSensor(SENSOR_GASES_TC, temperature);
// Add humidity
frame.addSensor(SENSOR_GASES_HUM, humidity);
// Add pressure
frame.addSensor(SENSOR_GASES_PRES, pressure);
//frame.addSensor(SENSOR_GASES_CO2, CO2PPM);

// Show the frame
frame.showFrame();
error = xbee868LP.send( RX_ADDRESS, frame.buffer, frame.length );

if( error == 0 )
{
USB.println(F("send ok"));

// blink green LED
Utils.blinkGreenLED();

}
else
{
USB.println(F("send error"));

// blink red LED
Utils.blinkRedLED();
}

// Switch ON and configure the Gases Board
Gases.OFF();
// Switch ON the sensor socket
COSensor.OFF();
CO2Sensor.OFF();


PWR.deepSleep("00:00:02:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);

}

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Strange values of sensors

Post by libelium-dev » Thu Feb 28, 2019 9:42 am

Hi,

Do you have Smart Environment PRO or not PRO version? The reference of the sensors are for PRO version but you are coding like it is a not PRO version. You have to use the following example codes to develop your code. It seems that the node doesn't sleep due to interference by using the wrong code.
http://www.libelium.com/development/was ... -pro-board

Regards

dimitar
Posts: 5
Joined: Mon Feb 04, 2019 1:21 pm
Company: Vista Group

Re: Strange values of sensors

Post by dimitar » Fri Mar 29, 2019 4:42 pm

Hi,
we are using PRO version. We try with code below but without success. Again data are coming on every 13-15 sec.

#include <WaspSensorGas_v30.h>
#include <WaspFrame.h>
#include <WaspXBee868LP.h>
#include <BME280.h>

// CO Sensor must be connected physically in SOCKET_4
COSensorClass COSensor;
char RX_ADDRESS[] = "0013a200415c61ae";
char WASPMOTE_ID[] = "NPP1";
uint8_t error;
CO2SensorClass CO2Sensor;
// Concentratios used in calibration process
#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration
#define POINT2_PPM_CO 300.0 //
#define POINT3_PPM_CO 1000.0 //

// Calibration resistances obtained during calibration process
#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value.
#define POINT2_RES_CO 40.665 //
#define POINT3_RES_CO 20.300 //

#define POINT1_PPM_CO2 350.0 // <-- Normal concentration in air
#define POINT2_PPM_CO2 1000.0
#define POINT3_PPM_CO2 3000.0

// Calibration vVoltages obtained during calibration process (Volts)
#define POINT1_VOLT_CO2 0.300
#define POINT2_VOLT_CO2 0.350
#define POINT3_VOLT_CO2 0.380

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

float concentrations[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO };
float resValues[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO };

float concentrationsCo2[] = { POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2 };
float voltages[] = { POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2 };

char node_ID[] = "NPP1";

float temperature; // Stores the temperature in :C
float humidity; // Stores the realitve humidity in %RH
float pressure; // Stores the pressure in Pa


void setup()
{
// Configure the USB port
USB.ON();
USB.println(F("Sensor reading for v30..."));

// Calculate the slope and the intersection of the logarithmic function
COSensor.setCalibrationPoints(resValues, concentrations, numPoints);
CO2Sensor.setCalibrationPoints(voltages, concentrationsCo2, numPoints);
///////////////////////////////////////////
// 1. Turn on the board and the SOCKET
///////////////////////////////////////////
// Switch ON and configure the Gases Board
Gases.ON();
// Switch ON the sensor socket
COSensor.ON();
CO2Sensor.ON();

PWR.deepSleep("00:00:01:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);

frame.setID( WASPMOTE_ID );
xbee868LP.ON();
}

void loop()
{

//////////////////////////////////////////
// 2. Read sensors
//////////////////////////////////////////
temperature = Gases.getTemperature();
humidity = Gases.getHumidity();
pressure = Gases.getPressure();

USB.println(F("***************************************"));
USB.print(F("Temperature: "));
USB.print(temperature);
USB.println(F(" Celsius degrees"));
USB.print(F("RH: "));
USB.print(humidity);
USB.println(F(" %"));
USB.print(F("Pressure: "));
USB.print(pressure);
USB.println(F(" Pa"));

float COVol = COSensor.readVoltage(); // Voltage value of the sensor
float CORes = COSensor.readResistance(); // Resistance of the sensor
float COPPM = COSensor.readConcentration(); // PPM value of CO
float CO2PPM = CO2Sensor.readConcentration();

// Print of the results
USB.print(F("CO Sensor Voltage: "));
USB.print(COVol);
USB.print(F(" mV |"));

// Print of the results
USB.print(F(" CO Sensor Resistance: "));
USB.print(CORes);
USB.print(F(" Ohms |"));

USB.print(F(" CO concentration Estimated: "));
USB.print(COPPM);
USB.println(F(" ppm"));

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

// Create new frame (ASCII)
frame.createFrame(ASCII, node_ID);
// Add CO PPM value
frame.addSensor(SENSOR_GASES_CO, COPPM);
frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel());
frame.addSensor(SENSOR_GASES_TC, temperature);
// Add humidity
frame.addSensor(SENSOR_GASES_HUM, humidity);
// Add pressure
frame.addSensor(SENSOR_GASES_PRES, pressure);
frame.addSensor(SENSOR_GASES_CO2, CO2PPM);

// Show the frame
frame.showFrame();
error = xbee868LP.send( RX_ADDRESS, frame.buffer, frame.length );

if( error == 0 )
{
USB.println(F("send ok"));

// blink green LED
Utils.blinkGreenLED();

}
else
{
USB.println(F("send error"));

// blink red LED
Utils.blinkRedLED();
}


PWR.deepSleep("00:00:02:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);

}

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Strange values of sensors

Post by libelium-dev » Mon Apr 01, 2019 8:58 am

Hi,

Your code is for gases sensor (not pro), please create the code usinf the examples of the link
http://www.libelium.com/development/was ... -pro-board

For example, connect a gas sensor to socket B and temperature humidity and pressure sensor to socket E. Then upload the following code to the node to read the sensors.

Code: Select all

/*  
 *  ------------  [GP_v30_01] - Electrochemical gas sensors  -------------- 
 *  
 *  Explanation: This is the basic code to manage and read an electrochemical
 *  gas sensor. These sensors include: CO, O2, O3, NO, NO2, SO2, NH3, H2, H2S,
 *  HCl, HCN, PH3, ETO and Cl2. Cycle time: 2 minutes
 *  
 *  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.1
 *  Design:            David Gascón 
 *  Implementation:    Alejandro Gállego
 */

#include <WaspSensorGas_Pro.h>

/*
 * Define object for sensor: gas_PRO_sensor
 * 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 gas_PRO_sensor(SOCKET_B);

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

void setup()
{
    USB.println(F("Electrochemical gas sensor example"));
    
    ///////////////////////////////////////////
    // 1. Turn on the sensors
    /////////////////////////////////////////// 

    // Power on the electrochemical sensor. 
    // If the gases PRO board is off, turn it on automatically.
    gas_PRO_sensor.ON();
    
    // First sleep time
    // After 2 minutes, Waspmote wakes up thanks to the RTC Alarm
    PWR.deepSleep("00:00:02:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);
    
}	


void loop()
{

    ///////////////////////////////////////////
    // 2. Read sensors
    ///////////////////////////////////////////  

    // Read the electrochemical sensor and compensate with the temperature internally
    concentration = gas_PRO_sensor.getConc();

    // Read enviromental variables
    temperature = gas_PRO_sensor.getTemp();
    humidity = gas_PRO_sensor.getHumidity();
    pressure = gas_PRO_sensor.getPressure();

    // And print the values via USB
    USB.println(F("***************************************"));
    USB.print(F("Gas concentration: "));
    USB.print(concentration);
    USB.println(F(" ppm"));
    USB.print(F("Temperature: "));
    USB.print(temperature);
    USB.println(F(" Celsius degrees"));
    USB.print(F("RH: "));
    USB.print(humidity);
    USB.println(F(" %"));
    USB.print(F("Pressure: "));
    USB.print(pressure);
    USB.println(F(" Pa"));

    ///////////////////////////////////////////
    // 5. Sleep
    /////////////////////////////////////////// 

    // Go to deepsleep	
    // After 2 minutes, Waspmote wakes up thanks to the RTC Alarm
    PWR.deepSleep("00:00:02:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);

}
Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest