|
Hi Thanks for the reply... Now i have a question about Gases, i see the example of Temperature Sensor – MCP9700A and it work perfectly with USB port, but when i want to use it with XBee 802.15.4 and send the value to the GateWay, i see tha strange symbol and value...
I don't understand exactly what's the problem?? please can you help me because i want to measure the temperature of 3 rooms, every room have a Waspmote with temperature sensor attached...
The code is above:
packetXBee* paq_sent; float value; 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[i]); }
// 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 ++++++++
// Read value in volts value = SensorGas.readValue(SENS_TEMPERATURE);
USB.print("Measured value from sensor:"); USB.println(value);
// --- coversion equation--- value = ( value - 0.5 ) * 100;
USB.print("Temperature:"); USB.println(value); USB.println(); sprintf(aux,"-id_mote:%s -mac:%s%s -temp:%f -bat: %d%c%c%c",id_mote,macHigh,macLow,value,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);
}
Please, can you tell me what is my mistake... Best Regard Pamela
|