Dear Pamela,
We tested the code here and it works. We include below the code and the seen answers on both sides.
Besides that, how and where did you plug the temperature sensor? Check the right position into Gases board guide on support section.
Please try this code and if it is not working we will try to go further to solve you issue.
CODE FOR READING TEMPERATURE AND SEND IT THROUGH XBEEQuote:
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;
uint8_t PANID[2]={0x12,0x34};
#define key_access "LIBELIUM"
#define id_mote "WaspMote01"
void setup()
{
USB.begin();
USB.println("Starting...");
// +++ Must go before RTC.ON() to avoid I2C problems +++
SensorGas.setBoardMode(SENS_ON);
delay(100);
// Init RTC
RTC.ON();
delay(100);
// Store key access in EEPROM
for(int i=0;i<8;i++){
Utils.writeEEPROM(i+107,key_access);
}
// Write Mote ID in EEPROM memory
for(int i=0;i<16;i++)
{
Utils.writeEEPROM(147+i,id_mote[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 802.15.4 library
xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
// Powers XBee
xbee802.ON();
// Get the XBee MAC address
delay(500);
int counter = 0;
while(xbee802.getOwnMac()==1&&counter<4){
xbee802.getOwnMac();
counter++;
}
Utils.hex2str(xbee802.sourceMacHigh,macHigh,4);
Utils.hex2str(xbee802.sourceMacLow,macLow,4);
}
void loop()
{
// ++++++++ Temperature ++++++++
float valueTemperature=0;
char temp[10];
// Read value in volts
valueTemperature = SensorGas.readValue(SENS_TEMPERATURE);
USB.print("Measured value from sensor:");
USB.println(valueTemperature);
// --- coversion equation---
valueTemperature = ( valueTemperature - 0.5 ) * 100;
USB.print("Temperature:");
USB.println(valueTemperature);
USB.println();
Utils.float2String(valueTemperature,temp,2);
USB.print("Temp:");
USB.println(temp);
sprintf(aux,"-id_mote:%s -mac:%s%s -TEMP:%s -bat: %d%c%c%c",id_mote,macHigh,macLow,temp,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;
xbee802.hops=0;
xbee802.setOriginParams(paq_sent,MAC_TYPE);
xbee802.setDestinationParams(paq_sent, "0013A20040762047",aux, MAC_TYPE, DATA_ABSOLUTE);
xbee802.sendXBee(paq_sent);
free(paq_sent);
paq_sent = NULL;
delay(2000);
}
WASPMOTE USB MESSAGES\0x00
[i]Starting...
\0xf8x<\0xf0\0xf8x<\0xf0\0xf8x<\0xf0
x\0x00x\0x00\0x87x\0x1e\0xf0\0x00x\0x00\0x07\0xe0x<\0x0f\0x80\0x00x\0xe0x\0x00x\0x00x<\0xf0\0xc0\0x80\0x00x\0xc0\0xf8x<\0x0fx\0xe0x<\0x00x\0xc0\0xf8\0x00x\0xc0\0x80x<\0xff\0x00\0x80x\0x00
~\0x00\0x04\0x08RSL\0x06~\0x00\0x04\0x08RSH
Measured value from sensor:07620367451612949
Temperature:247620365
161285400
Temp:24.51
~\0x00\0x04\0x08RSL\0x06~\0x00\0x04\0x08RSH
~\0x00\0x04\0x08RMY\0xff~\0x00\0x06\0x08RMY\0xff\0xff\0x01~\0x00X\0x00R\0x00\0x00\0x00\0x00\0x00\0x00\0xff\0xff\0x00R\0x01#\0x01\0x00}3\0xa2\0x00@v 6-id_mote:WaspMote01 -mac:4076203640762036 -TEMP:24.51 -bat: 98%
l~\0x00\0x06\0x08RMY\0x00\0x00\0xff
Measured value from sensor:07620367354838371
Temperature:23762036
5483818054
Temp:23.54
~\0x00\0x04\0x08RSL\0x06~\0x00\0x04\0x08RSH
~\0x00\0x04\0x08RMY\0xff~\0x00\0x06\0x08RMY\0xff\0xff\0x01
~\0x00X\0x00R\0x00\0x00\0x00\0x00\0x00\0x00\0xff\0xff\0x00R\0x01#\0x01\0x00}3\0xa2\0x00@v 6-id_mote:WaspMote01 -mac:4076203640762036 -TEMP:23.54 -bat: 98%
GATEWAY MESSAGES~\0x00X\0x80\0x00}3\0xa2\0x00@v 66\0x02R\0x01#\0x01\0x00}3\0xa2\0x00@v 6-id_mote:WaspMote01 -mac:4076203640762
036 -TEMP:24.51 -bat: 98%
C
~\0x00X\0x80\0x00}3\0xa2\0x00@v 66\0x02R\0x01#\0x01\0x00}3\0xa2\0x00@v 6-id_mote:WaspMote01 -mac:4076203640762036
-TEMP:23.54 -bat: 98%
A
: