I am trying to use the getAssociationIndication() function with a gases sensor board as follows:
Quote:
long previous=0;
packetXBee* paq_sent;
int8_t state=0;
char A[10]; // Temperature
char B[10]; // Barometric Pressure
char C[10]; // Carbon Monoxide
char D[10]; // Carbon Dioxide
char E[10]; // Oxygen
char F[10]; // Ozone
char G[10]; // Air Contaminants Gases I
char H[10]; // Air Contaminants Gases II
char I[10]; // Waspmote Battery
char aux[200];
char* macLow=" ";
// Resistor (1 - 100 KOhms) and Gain (1 - 101)
#define CO_GAIN 1
#define CO_RESISTOR 50
#define CO2_GAIN 1
#define O2_GAIN 100
#define O3_GAIN 1
#define O3_RESISTOR 10
#define ACS1_GAIN 1
#define ACS1_RESISTOR 10
#define ACS2_GAIN 1
#define ACS2_RESISTOR 10
#define key_access "WaspmoteKey"
float value_T=0.0;
float value_Air=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;
float value=0;
uint8_t batt;
uint8_t counter=0;
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);
xbeeZB.writeValues();
delay(500);
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();
delay(100000);
// Get the XBee MAC address
int counter = 0;
while(xbeeZB.getOwnMac()==1&&counter<4){
xbeeZB.getOwnMac();
counter++;
}
Utils.hex2str(xbeeZB.sourceMacLow,macLow,4);
}
void loop()
{
SensorGas.setBoardMode(SENS_ON);
delay(50);
RTC.ON();
delay(500);
XBee.setMode(XBEE_OFF);
delay(500);
PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE2,ALL_OFF);
if( intFlag & RTC_INT )
{
Utils.blinkLEDs(1000);
Utils.blinkLEDs(1000);
Utils.blinkLEDs(1000);
intFlag &= ~(RTC_INT);
}
getData();
sendData();
}
// gets values from sensors
void getData()
{
SensorGas.setBoardMode(SENS_ON);
RTC.ON();
delay(100);
value=0;
for(int g=0;g<5;g++){
value_T = SensorGas.readValue(SENS_TEMPERATURE);
value_T = (value_T - 0.5) * 100;
value = value_T + value;
delay(100);
}
value = value/5;
Utils.float2String(value,A,1);
// Waspmote Battery
batt = PWR.getBatteryLevel();
Utils.long2array(batt,I);
}
// sends a message
void sendData()
{
sprintf(aux,",%s,%s,%s,",macLow,A,I);
xbeeZB.ON();
delay(10000);
do
{
XBee.print("waiting for association ");
XBee.println(xbeeZB.associationIndication,HEX);
delay(1000);
xbeeZB.getAssociationIndication();
}
while(xbeeZB.associationIndication!=0);
paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
paq_sent->mode=UNICAST;
paq_sent->MY_known=0;
paq_sent->packetID=0x52;
paq_sent->opt=0;
xbeeZB.hops=0;
xbeeZB.setOriginParams(paq_sent, "0013A20040714C00", MAC_TYPE);
xbeeZB.setDestinationParams(paq_sent, "0013A200406B094A", aux, MAC_TYPE, DATA_ABSOLUTE);
xbeeZB.sendXBee(paq_sent);
while( counter<1 ){
state=xbeeZB.sendXBee(paq_sent);
counter++;
}
counter=0;
if(!state)
{
XBee.println("OK");
}
free(paq_sent);
paq_sent = NULL;
delay(1000);
}
So if I set the sleeping time to 10 seconds:
Code:
PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE2,ALL_OFF);
I get the following data over wireless on the coordinator:
Quote:
38,~ • }3¢ @qL d5Bd5 }3¢ @qL Áz
16,~ • }3¢ @qL ÿÂB
22,ÿÂ }3¢ @qL Á*
48,~ * }3¢ @qL ÿÂAR# }3¢ @qL ,00000000,19.8,55,(
48,~ * }3¢ @qL ÿÂAR# }3¢ @qL ,00000000,19.8,55,(
48,~ * }3¢ @qL YsAR# }3¢ @qL ,00000000,19.6,55,
48,~ * }3¢ @qL YsAR# }3¢ @qL ,00000000,19.6,55,
48,~ * }3¢ @qL £GAR# }3¢ @qL ,00000000,19.2,55,
48,~ * }3¢ @qL £GAR# }3¢ @qL ,00000000,19.2,55,
48,~ * }3¢ @qL AR# }3¢ @qL ,00000000,19.0,55,$
48,~ * }3¢ @qL AR# }3¢ @qL ,00000000,19.0,55,$
48,~ * }3¢ @qL -×AR# }3¢ @qL ,00000000,19.0,55,í
48,~ * }3¢ @qL -×AR# }3¢ @qL ,00000000,19.0,55,í
48,~ * }3¢ @qL §TAR# }3¢ @qL ,00000000,19.0,55,ö
48,~ * }3¢ @qL §TAR# }3¢ @qL ,00000000,19.0,55,ö
48,~ * }3¢ @qL TAR# }3¢ @qL ,00000000,19.1,54,š
48,~ * }3¢ @qL TAR# }3¢ @qL ,00000000,19.1,54,š
48,~ * }3¢ @qL ã¿AR# }3¢ @qL ,00000000,19.8,55,G
48,~ * }3¢ @qL ã¿AR# }3¢ @qL ,00000000,19.8,55,G
48,~ * }3¢ @qL ¤AR# }3¢ @qL ,00000000,19.0,55,9
48,~ * }3¢ @qL ¤AR# }3¢ @qL ,00000000,19.0,55,9
Which is what I would expect (Temperature around 19°C and Battery capacity around 55%).
The problem is when I try to make the sleeping time longer (since this is what I would need to run the gases board for a prolonged period) and I set a longer sleeping time of lets say 5 minutes:
Quote:
PWR.deepSleep("00:00:05:00",RTC_OFFSET,RTC_ALM1_MODE2,ALL_OFF);
... I do no longer get any data on the coordinator! Why this?
Another question would be why is the mac low adress zeroes only?