Post a new topicPost a reply Page 1 of 1   [ 8 posts ]
Author Message
 Post subject: Problems with CO-, CO2-sensors
PostPosted: Fri Jun 22, 2012 1:24 pm 

Joined: Fri Jun 22, 2012 1:11 pm
Posts: 5
I met a strange bug. I use Waspmote with gas sensor board and CO2 (tgs4161), CO(2442) sensors on it. After some experiments with a candle and measuring CO2 in a closed room I discovered that a value from CO-sensor varied while a value from a CO2-sensor didn’t. In a bottle with a burning candle the value of CO changed from 10 units to 30. In a closed room with 5 men in it the value changed from 12 to 33 units. CO2 sensor showed like the same in both experiments without changing. But it must be exact opposite! What it might be. May be the ADC sockets are mixed up and the library reads the values from a wrong analog socket?
This is the code I use for gas board:


SensorGas.setBoardMode(SENS_ON);

SensorGas.configureSensor(SENS_CO2, GAIN_CO2);
SensorGas.setSensorMode(SENS_ON, SENS_CO2);
delay(TIME);
valCO2 = MGAIN*SensorGas.readValue(SENS_CO2);

SensorGas.configureSensor(SENS_SOCKET3B, GAIN_CO, RES_CO);
valCO = MGAIN*SensorGas.readValue(SENS_SOCKET3B);


Top
 Profile  
 
 Post subject: Re: Problems with CO-, CO2-sensors
PostPosted: Mon Jun 25, 2012 8:21 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7467
Hi soloitd,

could you please post the whole code you are using and detail the results you are getting?

Regards.


Top
 Profile  
 
 Post subject: Re: Problems with CO-, CO2-sensors
PostPosted: Thu Jun 28, 2012 10:48 am 

Joined: Fri Jun 22, 2012 1:11 pm
Posts: 5
This is the code

Code:

// Settings
#define RES_O3   30
#define RES_NH3  30
#define RES_CO2  30
#define RES_NO2  2
#define RES_CO   30
#define RES_CH4  3

#define GAIN_O3  1
#define GAIN_NH3 1
#define GAIN_CO2 1
#define GAIN_CO  1
#define GAIN_NO2 1
#define GAIN_CH4 1
#define TIME     40000
#define MGAIN    10

#define RTCOFFSET 8

float vHumidity=0;
float vTemp = 0;
float valO3  =  0;
float valCH4 =  0;
float valNH3 =  0;
float valCO2 =  0;
float valCO  =  0;

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

#define key_access "LIBELIUM"

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

char ZBprint (char* taux){
  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, direccion, taux, MAC_TYPE, DATA_ABSOLUTE);
  xbeeZB.sendXBee(paq_sent);   
  free(paq_sent);
  paq_sent = NULL;
  delay(1000); 
return (0);
}

void setup(){

  Utils.blinkLEDs(1000);
 
  SensorGas.setBoardMode(SENS_ON); 
  delay(100);
//  SensorGas.configureSensor(SENS_SOCKET2B, GAIN_O3, RES_O3);
  SensorGas.configureSensor(SENS_SOCKET4C, GAIN_NH3, RES_NH3);
  SensorGas.configureSensor(SENS_SOCKET2A, GAIN_CH4, RES_CH4); 
  SensorGas.configureSensor(SENS_CO2, GAIN_CO2);
  SensorGas.configureSensor(SENS_SOCKET3B, GAIN_CO, RES_CO);
  SensorGas.configureSensor(SENS_SOCKET2B, GAIN_NO2, RES_NO2);
 
  for(int i=0;i<8;i++){
    Utils.writeEEPROM(i+107,key_access[i]);
  }

  RTC.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);
  }
 

  xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);
  xbeeZB.ON();
  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);
 

}

void loop(){

  Utils.blinkLEDs(1000);
/* 
  //Setting and getting Alarms
  RTC.setAlarm1(RTC.getTime(),RTC_ABSOLUTE,RTC_ALM1_MODE2);
  RTC.setAlarm1(0,0,RTCOFFSET,0,RTC_OFFSET,RTC_ALM1_MODE2);
  // Setting Waspmote to Low-Power Consumption Mode
  PWR.sleep(ALL_OFF);
  Utils.blinkLEDs(500);
  // Woken up, Powers XBee
  SensorGas.setBoardMode(SENS_ON);
  xbeeZB.ON(); 
  Utils.blinkLEDs(1000);
*/ 
  vHumidity = 37*SensorGas.readValue(SENS_HUMIDITY);
  vTemp = 34*SensorGas.readValue(SENS_TEMPERATURE);
  Utils.blinkLEDs(500);

  SensorGas.setSensorMode(SENS_ON, SENS_SOCKET2B); delay(TIME);
  valO3 = MGAIN*SensorGas.readValue(SENS_SOCKET2B);
  Utils.blinkLEDs(500);
/*
  SensorGas.setSensorMode(SENS_ON, SENS_SOCKET2B); delay(TIME);
  valO3 = MGAIN*SensorGas.readValue(SENS_SOCKET2B); //NO2
  Utils.blinkLEDs(500);
*/ 
  SensorGas.setSensorMode(SENS_ON, SENS_SOCKET2A); delay(TIME);
  valCH4 = MGAIN*SensorGas.readValue(SENS_SOCKET2A);
  Utils.blinkLEDs(500);

  valNH3 = MGAIN*SensorGas.readValue(SENS_SOCKET4C);
  Utils.blinkLEDs(500);

  SensorGas.setSensorMode(SENS_ON, SENS_CO2); delay(TIME);
  valCO2 = MGAIN*SensorGas.readValue(SENS_CO2);
  Utils.blinkLEDs(500);

  valCO = MGAIN*SensorGas.readValue(SENS_SOCKET3B);
  Utils.blinkLEDs(500);

  sprintf(aux,"-BoardOne; mac:%s%s Time: %s; ",macHigh,macLow,RTC.getTime());
  ZBprint(aux);
  sprintf(aux,"-BoardOne; Altit:%s; Long:%s; Latit:%s %c%c",GPS.getAltitude(),GPS.getLongitude(),GPS.getLatitude(),'\r','\n');
  ZBprint(aux); 
  sprintf(aux,"-BoardOne; Temp:%d; Humid:%d; Bat:%d%c; ",(int)vTemp,(int)vHumidity, PWR.getBatteryLevel(),'%');
  ZBprint(aux);
  sprintf(aux,"-BoardOne; NO2:%d; CH4:%d; NH3:%d; CO2:%d; CO:%d %c%c",(int)valO3,(int)valCH4,(int)valNH3,(int)valCO2,(int)valCO,'\r','\n'); //O3-change
  ZBprint(aux);
}



Top
 Profile  
 
 Post subject: Re: Problems with CO-, CO2-sensors
PostPosted: Thu Jun 28, 2012 11:02 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7467
Hi sololtd,

one suggestion, you should not turn on the XBee module and all the sensors at the same time, since consumption may be too high and exceed the maximum consumption allowed by the board. Apart from that, your code seems correct, could you post the CO, CO2, temperature and humidity values you are getting?

Regards.


Top
 Profile  
 
 Post subject: Re: Problems with CO-, CO2-sensors
PostPosted: Thu Jun 28, 2012 11:44 am 

Joined: Fri Jun 22, 2012 1:11 pm
Posts: 5
About the eperiments.

I measured CO and CO2 in a closed bottle. Put Waspmote with gas-sensor board (CO2 (tgs4161), CO(2442)) + over ZBPro communication into the bottle. Lit a candle. Each 2 mins got the results and saw CO changed from about 10 to 33 units. CO2 didn't changed at all & showed 4 units.

Later I left the board in closed room (windows & door were closed) with 5 persons in it. After half an hour I discovered that CO values grew up from 10 to 30 units, but CO2 remained the same. After ventilation CO return to previous. CO2 - without changing.

The code: see above.


Top
 Profile  
 
 Post subject: Re: Problems with CO-, CO2-sensors
PostPosted: Thu Jun 28, 2012 11:57 am 

Joined: Fri Jun 22, 2012 1:11 pm
Posts: 5
Quote:
could you post the CO, CO2, temperature and humidity values you are getting?


I didn't save the results, but remember that in 1st experiment the values changed as

temperature: Humidity: CO: CO2:
25C 46% 8 3-4
27C 60% 33 3-4
26C 48% 10 3-4 candle is off

2nd Exp:
temperature: Humidity: CO: CO2:
25C 46% 10 3-4
27C 48% 33 3-4


Top
 Profile  
 
 Post subject: Re: Problems with CO-, CO2-sensors
PostPosted: Thu Jun 28, 2012 11:58 am 

Joined: Fri Jun 22, 2012 1:11 pm
Posts: 5
Regards


Top
 Profile  
 
 Post subject: Re: Problems with CO-, CO2-sensors
PostPosted: Fri Jun 29, 2012 9:30 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7467
Hi sololtd,

when we have tested the sensors in experiments similar to your first one, we have seen first an increase in the CO2 concentration and later an increase in the CO concentration, it is strange you have not changes in your first sensor.

Variations in temperature and humidity are too low to have been the cause of a drift.

I'd advise you to increase the CO2 sensor gain up to a value between 7 and 10, so you have a wider resolution in your measurement.

Also, if you have kept the sensors stored for a long period, a conditioning time, with the sensor connected (in the case of the CO2) or applying heating and measurement cycles (case of the CO sensor) for 24 hours. Before starting your experiment, if the board has been off, I'd advice you to do the same for a few minutes before starting.

If you repeat your experiment, please post the raw values you get so we can take a look and see if something has gone worng.

Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 8 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