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:

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