Post a new topicPost a reply Page 2 of 2   [ 16 posts ]
Go to page Previous  1, 2
Author Message
 Post subject: Re: Problems with Zigbee Pro S2
PostPosted: Wed May 23, 2012 7:38 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7821
Dear fofo33,

It seems your problem is solved, please let us know if it is not.

Dear ankit,

yes, we know you opened that thread, we have replied in it to you.

Best regards


Top
 Profile  
 
 Post subject: Re: Problems with Zigbee Pro S2
PostPosted: Fri Jun 01, 2012 8:23 pm 

Joined: Wed May 02, 2012 8:48 pm
Posts: 36
Dear administrator,

Finally I solve the principal problem with this code:

Code:
//Declarem les variables
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;

float temperatura=0;
float llum=0;
float humitat=0;

int pir=0;//Nombre presències detectades

char T[10];
char L[10];
char H[10];


uint8_t counter=0;


// Definim la clau
#define key_access "LIBELIUM"

void setup()
{

  // Desem la clau d'accés a  l'EEPROM
  for(int i=0;i<8;i++)
  {
    Utils.writeEEPROM(i+107,key_access[i]);
  }


  // Activem la placa de sensors
  SensorEvent.setBoardMode(SENS_ON);
 
  delay(100);
 
  // Activem el mode USB
  USB.begin();
 
  //enable sensor board interruptions
  enableInterrupts(SENS_INT);
 
  //Activem el rellotge
  RTC.ON();
 
 
  RTC.setTime("12:05:04:00:00:00:00");
 
  //Cal activar-ho 5'8 segons abans, quasi 6
 
  RTC.setAlarm1("00:00:00:01",RTC_OFFSET,RTC_ALM1_MODE1);


   
  XBee.setMode(XBEE_ON);
  /*XBee.begin(9600);
  delay(1000);
  XBee.print("+++");
  delay(2000);
  XBee.println("ATBD5,AP2,WR,CN");
  delay(150);*/
 
    // Inits the XBee XSC library
  xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);
 
  // Powers XBee
  xbeeZB.ON();
 
  // Get the XBee MAC address
  int counter = 0; 
  while(xbeeZB.getOwnMac()==1&&counter<4)
  {
    xbeeZB.getOwnMac();
    counter++;
  }
 
  Utils.hex2str(xbeeZB.sourceMacHigh,macHigh,4);
  Utils.hex2str(xbeeZB.sourceMacLow,macLow,4);
 
  //Tanquem perque no generi brutícia
  XBee.setMode(XBEE_OFF);
 
}



void loop()
{
 
  XBee.println("PAS PER L'INICI");
 
  // Habilitem les interrupcion generades pels sensors de la placa
  SensorEvent.attachInt();
 
   //Aturem el sistema
  PWR.sleep(UART0_OFF | UART1_OFF | BAT_OFF | RTC_OFF);
 
 
 
  //Deshabilitem les interrupcion generades pels sensors de la placa
  SensorEvent.detachInt();
 
  //LLegim el registre de desplaçament i emmagatzemem el seu valor a una variable anomenada
  //SensorEventintFlag
  SensorEvent.loadInt();
 
  //Tornem a activar usb
  USB.begin();
 
  XBee.println("SORTIDA DE SLEEP L'INICI");
     
 
   if( intFlag & RTC_INT )
  {
   
    XBee.println("INTERRUPCIÓ RELLOTGE RTC 1");
       
    XBee.setMode(XBEE_ON);
    XBee.begin(9600);
    delay(950);// 1200
    XBee.print("+++");
    delay(1950);//2200
    XBee.println("ATBD5,AP2,WR,CN");
    delay(150);//250
 
    // Inits the XBee XSC library
    xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);
 
    /*
    xbeeZB.ON();
    delay(250);//No hi era */   
       
    Utils.float2String(temperatura,T,2);
    Utils.float2String(llum,L,2);
    Utils.float2String(humitat,H,2);
   
    sprintf(aux,"-mac:%s%s -T:%s,L:%s,H:%s -t:%d -bat: %d%c%c%c",macHigh,macLow,T,L,H,pir,PWR.getBatteryLevel(),'%','\r','\n');
 
   // Powers XBee
    xbeeZB.ON();
    delay(250);//No hi era 
 
    paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
    paq_sent->mode=UNICAST;
   
    paq_sent->packetID=0x52;
    paq_sent->opt=0;
    xbeeZB.hops=0;
    xbeeZB.setOriginParams(paq_sent,MAC_TYPE);
    xbeeZB.setDestinationParams(paq_sent, "0013A20040714C1A", 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(5000);
   
    intFlag &= ~(RTC_INT); // Clear flag
           
    RTC.clearAlarmFlag(); //L'he desactivat
   
       
    XBee.setMode(XBEE_OFF);
   
    //Podem enviar les dades cada quart o cada hora. Suma 4 (quasi 5) segons a cada volta
   
    //14 min i 55 seg
   
    RTC.setAlarm1("00:00:14:55",RTC_OFFSET,RTC_ALM1_MODE1);
   
   
   
    XBee.println("INTERRUPCIÓ RELLOTGE RTC");
   
           
    //Aqui cal posar que posi la variable pir a zero
   
    pir=0;
  }
 
   
 
  if(SensorEvent.intFlag & SENS_SOCKET7)
  {
   
    pir++;
   
    SensorEvent.intFlag = 0;
   
    XBee.println("INTERRUPCIÓ PIR");
     
   }
 
   
}



But now I still have a small problem. I put the waspmote running and then, after an undefined time, this stops working and sending packages. It seems that the waspmote can't leave from the sleep. Do you see something wrong in the code?

Thanks.


P.D: The operation of the code is: counting people during 15 minutes and then send the packet to the Meshlium.


Top
 Profile  
 
 Post subject: Re: Problems with Zigbee Pro S2
PostPosted: Mon Jun 04, 2012 8:51 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7821
fofo33,

This problem can be happening due to a memory lack.

Could you please test how much free RAM memory do you have while you run your code?

Use method freeMemory() method for example in this way USB.println(freeMemory());

Regards.


Top
 Profile  
 
 Post subject: Re: Problems with Zigbee Pro S2
PostPosted: Tue Jun 05, 2012 6:14 pm 

Joined: Wed May 02, 2012 8:48 pm
Posts: 36
Dear libelium-dev,

And how can I free memory?

Thanks.


Top
 Profile  
 
 Post subject: Re: Problems with Zigbee Pro S2
PostPosted: Tue Jun 05, 2012 6:19 pm 

Joined: Wed May 02, 2012 8:48 pm
Posts: 36
If several paquets arrives at the zigbee of Meshlium at the same time, it's possible that one o more be lost.


Top
 Profile  
 
 Post subject: Re: Problems with Zigbee Pro S2
PostPosted: Wed Jun 06, 2012 5:22 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7821
fofo33,
foto33 wrote:
And how can I free memory?
You should optimize the way you code, for example using "calloc" and "free" for large variables. Take into account that Waspmote microcontroller has 8K of RAM memory, that is a limiting factor when you manage huge amounts of data and forces to think carefully in each step.

foto33 wrote:
If several paquets arrives at the zigbee of Meshlium at the same time, it's possible that one o more be lost.
Yes, it is possible, so you should try to control when your motes are going to send information.

Any other questions please feel free to ask.

Best Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 2 of 2   [ 16 posts ]
Go to page Previous  1, 2


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use