Post a new topicPost a reply Page 2 of 2   [ 18 posts ]
Go to page Previous  1, 2
Author Message
 Post subject: Re: [Gases Board] strange behavior and wrong values..?
PostPosted: Wed Feb 08, 2012 12:08 pm 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
Thank you for your support.

I try to configure a gas sensor board with star configuration (one coordinator, multiple end devices).

I have looked at several examples in the forum and came out with the following code:

Code:
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;

// Set resistor here
#define CO_GAIN 1
#define CO_RESISTOR 0.5
#define CO2_GAIN 14
#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 0.5

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


#define key_access "LIBELIUM"

uint8_t batt;
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]);
  }

  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();
 
  ACC.ON();

}

void loop(){
 
  // Barometric pressure (Atmospheric Pressure Sensor; hPa – MPXAZ6115A)
 
  SensorGas.setBoardMode(SENS_ON);
  RTC.ON();
  SensorGas.setSensorMode(SENS_ON, SENS_PRESSURE);
  delay(100);
  value_Air = SensorGas.readValue(SENS_PRESSURE);
  value_Air = (value_Air - 1.25) * 1000;
  SensorGas.setSensorMode(SENS_OFF, SENS_PRESSURE);
         
  // temperature (°C)
  value_T = SensorGas.readValue(SENS_TEMPERATURE);
  value_T = (value_T - 0.5) * 100;
   
  // CO (Carbon Monoxide Sensor; ppm – Socket 3B; TGS2442)
  SensorGas.configureSensor(SENS_SOCKET3B, CO_GAIN, CO_RESISTOR);
  delay(1000);
  value_CO = 100*pow ((((5*10/ SensorGas.readValue(SENS_SOCKET3B))-10)/1101),-0.7925);
     
  // CO2 (Carbon Dioxide Sensor; ppm - Socket 1A; TGS4161)
  SensorGas.configureSensor(SENS_CO2, CO2_GAIN);
  SensorGas.setSensorMode(SENS_ON, SENS_CO2);
  delay(30000);
  value_CO2 = 350* pow (10, SensorGas.readValue(SENS_CO2));
  SensorGas.setSensorMode(SENS_OFF, SENS_CO2);
 
  // O2 (%; Socket 1B; Sensor – SK-25)
  SensorGas.configureSensor(SENS_O2, O2_GAIN);
  delay(1000);
  value_O2 = SensorGas.readValue(SENS_O2);
       
  // O3 (Socket 2B; Ozone Sensor; ppb - MiCS-2610)
  SensorGas.configureSensor(SENS_SOCKET2B, O3_GAIN, O3_RESISTOR);
  SensorGas.setSensorMode(SENS_ON, SENS_SOCKET2B);
  delay(30000);
  value_O3 = exp ((SensorGas.readValue(SENS_SOCKET2B) + 7.56)/1.86);
  SensorGas.setSensorMode(SENS_OFF, SENS_SOCKET2B);
       
  // Air Contaminants Sensor 1 (ppm; Socket 2A; TGS2600)
  SensorGas.configureSensor(SENS_SOCKET2A,ACS1_GAIN,ACS1_RESISTOR);
  SensorGas.setSensorMode(SENS_ON,SENS_SOCKET2A);
  delay(30000);
  value_ACS1 = SensorGas.readValue(SENS_SOCKET2A);
  SensorGas.setSensorMode(SENS_OFF,SENS_SOCKET2A);
     
  // Air Contaminants Sensor 2 (ppm; Socket 4A; TGS2602)
  SensorGas.configureSensor(SENS_SOCKET4A,ACS2_GAIN,ACS2_RESISTOR);
  SensorGas.setSensorMode(SENS_ON, SENS_SOCKET4A);
  delay(30000);
  value_ACS2 = SensorGas.readValue(SENS_SOCKET4A);
  SensorGas.setSensorMode(SENS_OFF, SENS_SOCKET4A);
  SensorGas.setBoardMode(SENS_OFF);
 
  batt = PWR.getBatteryLevel();
   
  delay(5000);
 
 
  XBee.println("");
  XBee.print(value_Air);
  XBee.print(",");
  XBee.print(value_T);
  XBee.print(",");
  XBee.print(value_CO);
  XBee.print(",");
  XBee.print(value_CO2);
  XBee.print(",");
  XBee.print(value_O2);
  XBee.print(",");
  XBee.print(value_O3); 
  XBee.print(",");
  XBee.print(value_ACS1);
  XBee.print(",");
  XBee.print(value_ACS2);
  XBee.print(",");
  XBee.println(batt, DEC);
 
 
 
  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);
}


The readout from a waspmote using USB connection to the PC and serial monitor is as follows:

Image

As you can see there are two sensors showing only 0 (carbon monoxide and molecular oxygen). And a lot of the others show only little or no variation over time. I quess this has to do with the way the sensor board or the single sensors are turned on and off.

Maybe you have some suggestions looking at my code.

Cheers

Urs


Top
 Profile  
 
 Post subject: Re: [Gases Board] strange behavior and wrong values..?
PostPosted: Thu Feb 09, 2012 10:35 am 

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

the way you are reading the sensors seems pretty fine to me, only a couple of issues:

1) Be careful with gains and load resistor. For the first one, 1 will be fine for all the sensors but for the O2, which will need 100 to perform adequately. For the load resistor, all seem too low to me (some of them even bellow the minimum load resistance specified for the given sensor).

2) Secondly, conversion into ppm/ppb may be problematic. Could you also transmit the raw value read at the analog input to check out that everything is right?

Please, try to repeat your tests and post your results here so we can check everything is going fine.

Regards.


Top
 Profile  
 
 Post subject: Re: [Gases Board] strange behavior and wrong values..?
PostPosted: Tue Feb 14, 2012 5:23 pm 

Joined: Fri Jan 06, 2012 4:11 pm
Posts: 10
Hi libelium-dev,

I followed your instruction to start an RMA process. However, it turned out that the main error (better: my mistake) was that the battary was not attached, when using the gases board. As a result, I didnt send the devices back, yet. It is possible to readout the sensor values correctly. But there are still some other problems..so I have to ask you for help again :)


In general, I have two remaining problems:

1) The values from my O2 sensor seem to be faulty
2) One of my gases board is still not working correctly


1)
I've read that a gain of 100 should be used for the O2 sensor. I'm converting the raw voltage value from the sensor into a %-value after this formula:

Code:
value=((value-0.05))/(0.033); //for GAIN=100


At least, this time (after the bugfix) the raw values are in the valid range which the sensor can provide (0-10mV). However, I get every time approx. 4.7mV as output. According to the datasheet (and my formula), this value represents approx. 12-13% of O2 which is far to low. So where is the problem here? Or is the variation from sensor to sensor really such high?

The other sensors like temperature and preassure are working correctly as far as I know.

2)
If the other gas sensor board is used, I get completely different values. Examples:
Preassure: 80kPa instead of 100kPa
Temp: 8°C instead of 21°C
O2: 25....50% instead of 13%

I get these strange values as soon as I exchange the gas sensor board. The sensors are the same ones as well as the program I run on the waspmote.

Do you have any ideas what could be the source of the problem?


Thx and kind regards

Stephan


Top
 Profile  
 
 Post subject: Re: [Gases Board] strange behavior and wrong values..?
PostPosted: Wed Feb 15, 2012 12:45 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7811
Hi Justin Time,

could you please post the code you are using to read the O2 sensor?

Regarding the board outputting the strange values, is the code, Waspmote and configuration all the same than with the other board? Could you test it on other mote?

Regards.


Top
 Profile  
 
 Post subject: Re: [Gases Board] strange behavior and wrong values..?
PostPosted: Wed Feb 15, 2012 1:34 pm 

Joined: Fri Jan 06, 2012 4:11 pm
Posts: 10
Hi libelium-dev,

for the O2 sensor, I've used the example code provided by the manual of the gases board:

Code:
SensorGas.setBoardMode(SENS_ON);
RTC.ON();
...
SensorGas.configureSensor(SENS_O2, 100); //GAIN=100
...
value =SensorGas.readValue(SENS_O2); //In a loop with delay(5000)
value=((value-0.05))/(0.033); //O2 for GAIN=100
USB.println(value);


I've measured the the voltage of the O2 sensor again with an accurate voltmeter: 5,7mV.


And yes, I didnt alter the conditions. Waspmote, code, sensors and environment are the same. However, if another Waspmote is going to be used, I still get the same (strange) values as soon as I use the (probably) broken gases board. When using the (probably correct) working one, I get every time (also independent of the waspmote) the same (correct) output. The only strange value I've observed here is, as I said, the O2 value.


Kind regards

Stephan


Top
 Profile  
 
 Post subject: Re: [Gases Board] strange behavior and wrong values..?
PostPosted: Thu Feb 16, 2012 9:54 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7811
Hi Justin Time,

Though according to the data sheet this value is in the range of normal measurement in initial conditions, it is true that it is lower than usually. In which conditions of temperature, humidity and temperature are you receiving those measurements? Do you have a way to test it in a different concentration so we can check if the sensor is stall or it is just a question of a different sensitivity? A simple, though very unaccurate, way to do it is breathing on the sensor while taking continuous measurements.

Regarding your non-working board, it seems a hardware failure, we will have to fulfill an RMA so you can return it to us, but I think we should wait till we find out what's happening with your sensor.

Regards.


Top
 Profile  
 
 Post subject: Re: [Gases Board] strange behavior and wrong values..?
PostPosted: Fri Feb 17, 2012 12:20 pm 

Joined: Fri Jan 06, 2012 4:11 pm
Posts: 10
Hi libelium-dev,

I've tested the sensor under normal conditions / gas concentrations. Breathing or opening the window doesn't change anything notable. However, the problem is not that the value of this sensor is faulty. According to the manual, 5,7 mV are fine. But after plugging the sensor onto the board, I get only 4,x mV apparently. So I don't just get a value which is too low, it differs (in this case massively) from the real value.


Regards.


Top
 Profile  
 
 Post subject: Re: [Gases Board] strange behavior and wrong values..?
PostPosted: Fri Feb 17, 2012 1:40 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7811
Hi Justin Time,

It seems there is some hardware failure in your sensor or your boards, lets go on with the RMA, and send all the three of them to us.

Please, fulfill this form to submit the problem to the Technical Service department:

http://www.libelium.com/support/technicalservice

Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 2 of 2   [ 18 posts ]
Go to page Previous  1, 2


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