Post a new topicPost a reply Page 1 of 1   [ 10 posts ]
Author Message
 Post subject: setting channel
PostPosted: Thu Feb 09, 2012 5:10 pm 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
How do I change the channel in an XBee end device since I cannot change it with X-CTU because API is enabled in the Zigbee!

Cheers

Urs


Top
 Profile  
 
 Post subject: Re: setting channel
PostPosted: Fri Feb 10, 2012 9:36 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7501
Dear Wirthm_U

Let us copy an extract from Digi documentation:

Quote:
....Command Mode
To modify or read RF Module parameters, the module must first enter into Command Mode - a state in which
incoming serial characters are interpreted as commands. Refer to the API Mode section in chapter 9 for an
alternate means of configuring modules.
AT Command Mode
To Enter AT Command Mode:
Send the 3-character command sequence “+++” ....


Regards!


Top
 Profile  
 
 Post subject: Re: setting channel
PostPosted: Fri Feb 10, 2012 10:21 am 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
If I understand it correct ZBee's in API mode cannot be programmed using X-CTU AT-commands. One has to configure them using code.

The line
Code:
xbeeZB.print("+++");
  delay(2000);
  xbeeZB.println("ATBD5,AP2,WR,CN");
  delay(150);


sets ZBee 38400 baud, AP mode 2, write these values to the ZBee ("store"), exit.

So if I modify the command to

Code:
xbeeZB.println("ATBD5,AP2,CH0x0C,WR,CN");


this should change channel to channel 12?


Top
 Profile  
 
 Post subject: Re: setting channel
PostPosted: Mon Feb 13, 2012 6:41 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7501
Wirthm_U,

There is a function inside Zigbee API to send AT commands to Xbee module.

It is shown on Zigbee programming guide at section 1.3.

xbeeZB.sendCommandAT(“CH#”); // Executes command ATCH

Also you can use this peace of code to get channel:
Quote:
  // Getting Channel
  xbee802.getChannel();
  if( !xbee802.error_AT ){
    XBee.print("Channel is: ");
    XBee.println(xbeeZB.channel,HEX);
  }
  else XBee.println("Error getting channel");



Moreover, in this tutorial is shown how to manage xbee sending AT commands.

Hope this is useful for you.

best regards.


Top
 Profile  
 
 Post subject: Re: setting channel
PostPosted: Mon Feb 27, 2012 3:53 pm 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
I am still having troubles getting the same channel on the coordinator and end device. Even with the same baud rate / PAN ID / API mode 2 / JV parameter 1 I do not get a connection. It seems that - for whatever reason I do not know - the coordinator does changes its channel and then the end device no longer gets a connection.

After applying the "ZigBee_Creating_Network" code I have noticed that the channel of the end device often changes to the one of the coordinator. But I do not know the exact sequence of events that allow this (which device has to be powered first etc.).

From your waspmote checklist on your home page, when using X-CTU I have seen that you configure using XB24 modem only. In my case I have XBee PRO's (XPB24-ZB) where the channel can not be changed using X-CTU! I am using function set ZIGBEE COORDINATOR API and ZIGBEE END DEVICE API, respectively.

Could you please give an exact order for XBee PRO how coordinator and end devices have to be setup. I.e. who gets power first, when is the xbee attached to the end device etc. so that the end device changes its channel to the one given by the coordinator.

Prerequisites set using X-CTU: same PAN ID, API mode 2 / baud rate 38'400 / JV parameter set to 1 (on the end device).


Top
 Profile  
 
 Post subject: Re: setting channel
PostPosted: Tue Mar 27, 2012 3:03 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7501
Hi Wirthm_U,

first of all, sorry for the delay in answering.

You cannot select the channel in which the network will be created, since it is selected by the coordinator in function of channel energy detected, it is a part of the process when creating a network and trying to join it to detect in which channel it is placed.

The end device will try to connect to a network when it is powered, so you will have to have the network created by the coordinator when you power the end device, so it can join it. Take into account that this process will take place always you turn on a module and it takes several seconds for the module to get that connection, so you will have to wait for some time before you may have data communication.

Could you post the code you are using?

Regards.


Top
 Profile  
 
 Post subject: Re: setting channel
PostPosted: Wed Mar 28, 2012 9:26 am 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
I am still making changes to adapt (I am using only 6 of the available 9 sensors).

My current code is:

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:05:00",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); 

// Barometric pressure (Atmospheric Pressure Sensor; hPa Ã¢â‚¬â€œ MPXAZ6115A)
  SensorGas.setSensorMode(SENS_ON, SENS_PRESSURE);
  delay(100);
  value_Air = SensorGas.readValue(SENS_PRESSURE);
  value_Air = (value_Air - 1.28) * 1000;
  Utils.float2String(value_Air,B,1); 
  SensorGas.setSensorMode(SENS_OFF, SENS_PRESSURE);

// CO (Carbon Monoxide Sensor; ppm Ã¢â‚¬â€œ Socket 3B; TGS2442); Rs=R0 at 100 ppm, 25°, 40%RH
  SensorGas.configureSensor(SENS_SOCKET3B, CO_GAIN, CO_RESISTOR);
  delay(1000);
  value_CO = 100*pow ((((5*10/ SensorGas.readValue(SENS_SOCKET3B))-10)/1101),-0.7925);     
  Utils.float2String(value_CO,C,1);

// CO2 (Carbon Dioxide Sensor; ppm - Socket 1A; TGS4161); y = p1*x + p2 / (value_CO2 + 3.6973) / 0.011992??
  SensorGas.configureSensor(SENS_CO2, CO2_GAIN);
  SensorGas.setSensorMode(SENS_ON, SENS_CO2);
  delay(30000);
  value_CO2 = 350* pow (10, SensorGas.readValue(SENS_CO2));
  Utils.float2String(value_CO2,D,1);
  SensorGas.setSensorMode(SENS_OFF, SENS_CO2);

// O2 (%; Socket 1B; Sensor Ã¢â‚¬â€œ SK-25)
  SensorGas.configureSensor(SENS_O2, O2_GAIN);
  delay(1000);
  value_O2 = ((SensorGas.readValue(SENS_O2)*10)-0.5)/0.3;
  Utils.float2String(value_O2,E,1); 


// Waspmote Battery  
  batt = PWR.getBatteryLevel();
  Utils.long2array(batt,I);
}  

// sends a message
void sendData()
{
  

  sprintf(aux,",%s,%s,%s,%s,%s,%s,%s,",macLow,A,B,C,D,E,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);

  
}



Since I have introduced the do/while loop with

Code:
 xbeeZB.getAssociationIndication();


connection between the end device and the coordinator always works.

The trouble I have is that when using wirless datalogging stops after three data transfers even if I run the mote the whole night:

Quote:
38,~ • }3¢ @qL ÜóBÜó }3¢ @qL Á
38,~ • }3¢ @qL DEBDE }3¢ @qL Áš
72,~ B }3¢ @qL DEAR# }3¢ @qL ,00000000,22.5,1032.9,100.2,355.2,14.6,98,Î
72,~ B }3¢ @qL DEAR# }3¢ @qL ,00000000,22.5,1032.9,100.2,355.2,14.6,98,Î
38,~ • }3¢ @qL ˆÁBˆÁ }3¢ @qL Á
71,~ A }3¢ @qL ˆÁAR# }3¢ @qL ,00000000,23.6,1032.9,94.5,365.9,14.5,98,&
71,~ A }3¢ @qL ˆÁAR# }3¢ @qL ,00000000,23.6,1032.9,94.5,365.9,14.5,98,&
38,~ • }3¢ @qL Ô7BÔ7 }3¢ @qL Á–
142,~ A }3¢ @qL Ô7AR# }3¢ @qL ,00000000,24.0,1032.9,94.5,357.8,14.5,98,i~ A }3¢ @qL Ô7AR# }3¢ @qL ,00000000,24.0,1032.9,94.5,357.8,14.5,98,i
38,~ • }3¢ @qL q4Bq4 }3¢ @qL Áb
71,~ A }3¢ @qL q4AR# }3¢ @qL ,00000000,23.5,1029.6,88.6,357.8,14.6,98,Ã
71,~ A }3¢ @qL q4AR# }3¢ @qL ,00000000,23.5,1029.6,88.6,357.8,14.6,98,Ã



If I run the same code connecting to the USB I do get a continuing data transfer between the end device and the coordinator.


Top
 Profile  
 
 Post subject: Re: setting channel
PostPosted: Wed Apr 04, 2012 11:06 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7501
Dear Wirthm_U,

It is very weird. The only thing could be that your battery is damaged and Wasp only works when the battery is being charged.

Could you please take a multi-meter and measure the voltage of the battery. This can be done measuring near the white female connector for the battery in Waspmote. Connect the battery there and measure in the 2 metal pins behind the females connetor (this is between ground and battery_voltage). All this, with the USB being connected.

Best regards


Top
 Profile  
 
 Post subject: Re: setting channel
PostPosted: Thu May 10, 2012 12:05 pm 

Joined: Wed May 09, 2012 5:39 am
Posts: 3
hi Wirthm_U,

I am getting trouble on setting the channel too, is this code working?
Code:
xbeeZB.println("ATBD5,AP2,CH0x0C,WR,CN");


can u set to channel 0x0C?

i cant set to my right channel. I am using the same ZB API with you.

Also, I cant find the AT command list in the Digi documentation. would you show me the exact document? thanks.

Are you working with the Meshlium? I am getting trouble in sending data from waspmote to meshlium now. Thanks


Top
 Profile  
 
 Post subject: Re: setting channel
PostPosted: Mon May 14, 2012 9:33 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7501
vlau,

Please find AT command set for Zigbee modules and other relevant documents here

Besides that, take a read into Zigbee programming guide. Section 3.7 shows information about channel.

best Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 10 posts ]


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