Post a new topicPost a reply Page 1 of 1   [ 7 posts ]
Author Message
 Post subject: Gases board setup - lots of questions!
PostPosted: Tue Jan 31, 2012 4:32 pm 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
I am about to setup a gases board using Waspmote ZB PRO UFL with the following sensors:
Air pressure / CO / CO2 / O2 / O3 / API / APII

The following questions have risen up so far:
> I can upload to the board directly via USB the code below and I get readout in the serial monitor. as soon as I put back XBee and try to monitor wireless via the Waspmote Gateway there is no longer any readout. Com port is correct. If I load the wasp_start_program_full_ZB_v1 I get remote readout

> a typical readout is as follows:

¹Barometric Pressure :1020.9677124023
Temperature :24.8387107849
Carbon Monoxide Value :2.2677419185
Carbon Dioxide Value :0.0096774187
Oxygen Value :0.0096774187
Ozone Value :0.1580645084
TGS2600 Value :0.1580645084
TGS2602 Value :0.0000000000
~

>Why are CO2 values a O2 values the same?

>Why are O3 values and API values the same?

>Why is APII value zero?

>The barometric pressure (displayed as hPa) varies quite a bit (between 1014.0 and 1037.0 within a minute) this in the range of the precision of 1.5% as stated in the sensor board documentation but not really usable for real life measurement!

>Why is there alway a strange sign before Barometric Pressure (here it is ¹ but it was also ° or ~)


My code is

Code:
/*
 *  ----- wasp_start_program_full_ZB_v1------
 *
 *  Explanation:
 *
 *  Waspmote starting program for XBee ZB module. This program
 *  initializes the XBee module, prepares the frame to send and every
 *  second it sends it.
 *
 *  Remarks: This code shall work with a XBeeZB-router, so before
 *  executing this example, A ZB-Coordinator must be plugged in your Gateway
 *  and your ZB-router must have: JV parameter set to '1'; BD parameter set to 5;
 *  and AP parameter set to 2.
 * 
 *
 *  Copyright (C) 2009 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 2 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:         Marcos Yarza, Alberto Bielsa, Yuri Carmona
 */


packetXBee* paq_sent;
int8_t state=0;
long previous=0;
char aux[200];
char* macHigh="          ";
char* macLow="           ";
int aux_1 = 0;
int aux_2 = 0;

#define key_access "LIBELIUM"

// Set delay here
#define TIME 30000

// Set resistor here
#define CO_GAIN 1
#define CO_RESISTOR 0.5
#define CO2_GAIN 1
#define O2_GAIN 1
#define O3_GAIN 1
#define O3_RESISTOR 0.5
#define ACS1_GAIN 1
#define ACS1_RESISTOR 0.5
#define ACS2_GAIN 1
#define ACS2_RESISTOR 50

float value_Air=0;
float value_T=0;
float value_CO=0;
float value_CO2=0;
float value_O2=0;
float value_O3=0;
float value_ACS1=0;
float value_ACS2=0;


uint8_t direction[8]={0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF};

void setup(){

  // Store key access in EEPROM
  for(int i=0;i<8;i++){
    Utils.writeEEPROM(i+107,key_access[i]);
  }

  RTC.ON();
 
  ACC.ON();
 
  XBee.setMode(XBEE_ON);
  XBee.begin(9600);
  delay(1000);
  XBee.print("+++");
  delay(2000);
  XBee.println("ATBD5,AP2,WR,CN");
  delay(150);
 
  XBee.setMode(XBEE_OFF);
  XBee.close();
   
  Utils.setLED(LED0, LED_ON);
  Utils.setLED(LED1, LED_ON);
  delay(5000);
  Utils.setLED(LED0, LED_OFF);
  Utils.setLED(LED1, LED_OFF);
  for (int i=0;i<24;i++){
    Utils.blinkLEDs(125);
  }
 
  // Inits the XBee XSC library
  xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);
 
  // Powers XBee
  xbeeZB.ON();
 
  // Get the XBee MAC address

  delay(500);
 
  int counter = 0; 
  while(xbeeZB.getOwnMac()==1&&counter<4){
    xbeeZB.getOwnMac();
    counter++;
  }
 
  Utils.hex2str(xbeeZB.sourceMacHigh,macHigh,4);
  Utils.hex2str(xbeeZB.sourceMacLow,macLow,4);
 

 // Init USB port
  USB.begin();
  USB.println("Waspmote gases sensor board..");

 //switch on the gases sensor board
  SensorGas.setBoardMode(SENS_ON);
  delay(100);
  // Init RTC
  RTC.ON(); 
  delay(100);
 
 
  // Barometric pressure (Atmospheric Pressure Sensor – MPXAZ6115A)
  SensorGas.setSensorMode(SENS_ON, SENS_PRESSURE);
  delay(30);
 
  // CO (Carbon Monoxide Sensor – TGS2442)
  SensorGas.configureSensor(SENS_SOCKET3, CO_GAIN, CO_RESISTOR);
  SensorGas.setSensorMode(SENS_ON, SENS_SOCKET3);
 
  // CO2 (Carbon Dioxide Sensor - Socket 1A; Sensor – TGS4161)
  SensorGas.configureSensor(SENS_CO2, CO2_GAIN);
  SensorGas.setSensorMode(SENS_ON, SENS_CO2);
   
  // O2 (Socket 1B; Sensor – SK-25)
  SensorGas.configureSensor(SENS_O2, O2_GAIN);
 
  // O3 (Socket 2B; Ozone Sensor - MiCS-2610)
  SensorGas.configureSensor(SENS_SOCKET2B, O3_GAIN, O3_RESISTOR);
  SensorGas.setSensorMode(SENS_ON, SENS_SOCKET2B);
 
  // Air Contaminants Sensor 1 (TGS2600)
  SensorGas.configureSensor(SENS_SOCKET2A,ACS1_GAIN,ACS1_RESISTOR);
  SensorGas.setSensorMode(SENS_ON,SENS_SOCKET2A);
   
   // Air Contaminants Sensor 2 (TGS2602)
  SensorGas.configureSensor(SENS_SOCKET4,ACS2_GAIN,ACS2_RESISTOR);
  SensorGas.setSensorMode(SENS_ON, SENS_SOCKET4);
   
  USB.println("Heating Sensor...");
  delay(TIME);

}

void loop(){

   // air pressure
  value_Air = SensorGas.readValue(SENS_PRESSURE);
  value_Air = (value_Air - 1.25) * 1000;
   
  // temperature
  value_T = SensorGas.readValue(SENS_TEMPERATURE);
  value_T = (value_T - 0.5) * 100;
 
  // CO
  value_CO = SensorGas.readValue(SENS_SOCKET3);
 
  // CO2
  value_CO2 = SensorGas.readValue(SENS_CO2);
 
   // O2
  value_O2 = SensorGas.readValue(SENS_O2);
 
  // O3
  value_O3 = SensorGas.readValue(SENS_SOCKET2B);
   
  // Air Contaminants Sensor 1 (TGS2600)
  value_ACS1 = SensorGas.readValue(SENS_SOCKET2A);
 
  // Air Contaminants Sensor 2 (TGS2602)
  value_ACS2 = SensorGas.readValue(SENS_SOCKET4);
 
 
  USB.print("Barometric Pressure :");
  USB.println(value_Air);
 
  USB.print("Temperature :");
  USB.println(value_T);
 
  USB.print("Carbon Monoxide Value :");
  USB.println(value_CO);
 
  USB.print("Carbon Dioxide Value :");
  USB.println(value_CO2);
 
  USB.print("Oxygen Value :");
  USB.println(value_O2);
 
  USB.print("Ozone Value :");
  USB.println(value_O3);
 
  USB.print("TGS2600 Value :");
  USB.println(value_ACS1);
 
  USB.print("TGS2602 Value :");
  USB.println(value_ACS2);
 
  delay(5000);
 
 
 
  sprintf(aux,"-mac:%s%s -x:%d,y:%d,z:%d -temp:%d -bat: %d%c%c%c",macHigh,macLow,ACC.getX(),ACC.getY(),ACC.getZ(),RTC.getTemperature(),PWR.getBatteryLevel(),'%','\r','\n');
 
  paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
  paq_sent->mode=BROADCAST;
  paq_sent->MY_known=0;
  paq_sent->packetID=0x52;
  paq_sent->opt=0;
  xbeeZB.hops=0;
  xbeeZB.setOriginParams(paq_sent,MAC_TYPE);
  xbeeZB.setDestinationParams(paq_sent, direction, aux, MAC_TYPE, DATA_ABSOLUTE);
  xbeeZB.sendXBee(paq_sent);
 
  free(paq_sent);
  paq_sent = NULL;
 
  delay(1000);
}



Top
 Profile  
 
 Post subject: Re: Gases board setup - lots of questions!
PostPosted: Wed Feb 01, 2012 1:03 pm 

Joined: Tue Mar 08, 2011 8:56 pm
Posts: 66
Hi,
1. Instead of writing USB.print, type XBee.print.
2. You also have issues with sprintf. First test XBee with a simple example.

Best,


Top
 Profile  
 
 Post subject: Re: Gases board setup - lots of questions!
PostPosted: Wed Feb 01, 2012 8:00 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7818
Hi Wirthm_U,

there are many problematic issues in your code regarding the sensors reading (dealing with the XBees, you should first try to follow the zeus2kx advice):

First, don't power all the sensors at the same time. They require too much current for the battery to supply, which may be the source of some strange behaviors.

Secondly, be careful with gains and load resistors, in some cases you will have to update your code after your first tests, depending on the sensor value.

Finally, please read carefully the board technical guide. You are making some basic mistakes, like trying to configure and turn on the O2 and the CO2 sensors at the same time, when both share some electronics which make necessary to perform those tasks separately, trying to turn on the carbon monoxide sensor (which may damage it) and using socket identifications that belong to other boards (SENS_SOCKET3 and SENS_SOCKET4).

Regards.


Top
 Profile  
 
 Post subject: Re: Gases board setup - lots of questions!
PostPosted: Thu Feb 02, 2012 10:15 am 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
Hi libelium-dev

I have changed powering up the sensors accordingly - maybe you should stress this out in the board technical guide a bit more prominently.

two further questions:

What do you mean by socket identifications that belong to other boards (SENS_SOCKET3 and SENS-SOCKET4)? The picture of the gas sensor specifications on page 5 of the board technical guide shows "Gas Sensor 3 Socket" and "Gas Sensor 4 Socket". In some of the detailed specifications of sensors below it says 3A or 3B (i.e. CO: SENS_SOCKET3B or SENS_SOCKET4B; or Air Contaminants Sensor (TGS2600): SENS_SOCKET 2A, SENS_SOCKET3A). So how do I adress socket 3 which I am using for CO? Is it 3A or 3B?

Also I would like to turn off the sensors between measurements to reduce battery load. Do I have to switch off the sensors individually or can I just program SensorGas.setBoardMode(SENS_OFF);

Thank you for your support


Top
 Profile  
 
 Post subject: Re: Gases board setup - lots of questions!
PostPosted: Thu Feb 02, 2012 3:33 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7818
Hi Wirthm_U,

though those sockets are named socket 3 and socket 4, in the board's API they are invoked as SENS_SOCKETXA, SENS_SOCKETXB or SENS_SOCKETXC to differentiate its use with different sensors. You should use SENS_SOCKET3B to read the CO sensor value (take into account that this sensor must NOT be turned on, please read carefully section 3.2 in the gases board technical guide).

Regarding your second question, if you switch off the board all the sensors will be turned off too, but again I'd advice you to turn them on and off individually and not at the same time.

Regards.


Top
 Profile  
 
 Post subject: Re: Gases board setup - lots of questions!
PostPosted: Tue Feb 07, 2012 7:26 pm 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
What is the difference between USB.print and XBee.print?

zeus2kx wrote:
1. Instead of writing USB.print, type XBee.print.


Where can I find the description of XBee and USB functions for Waspmote?

Cheers

Urs


Top
 Profile  
 
 Post subject: Re: Gases board setup - lots of questions!
PostPosted: Wed Feb 08, 2012 10:20 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7818
Hi Wirthm_U,

in the development section at the Libelium site you will find the technical guides for all the XBee modules (802.15.4, ZB, Digimesh...):

http://www.libelium.com/development/waspmote

Take a look at them and ask here in the forum if you need some more details about how they work.

Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 7 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use