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