Go Down

Topic: Read parameters of xbee (Read 517 times) previous topic - next topic

tablet

I'm trying to read parameters of  xbee. The problem is I can not read parameters if the DIO7/CS  pin of Xbee is disabled but if I activate pin DIO7, the arduino crashes.
The Xbee is in mode at.
the code is this:
Code: [Select]

byte data;
void setup()
  {
  Serial.begin(9600);
}

void loop()
  {
  Serial.println(" \r\n read:");   
  Serial.print("+++");
  Serial.println("\r\nATID");  //  ID 
  while(Serial.available()==0){}
  while(Serial.available()>0){
  data=Serial.read();
  delay(5);       
  }   
   Serial.print(char(data));   
   Serial.println("\r\nATCN");   
  while(Serial.available()==0){}
  while(Serial.available()>0){
  data=Serial.read();
  delay(5);       
  }   
  Serial.print(char(data));
  delay(1000);
}



Any solutions?
Thanks,
Regards.

PaulS

It appears that you are using the serial port to talk to the XBee and to the PC. That won't work when you are trying to communicate with the XBees in command mode.

Code: [Select]
  Serial.print("+++");
  Serial.println("\r\nATID");  //  ID 

The +++ puts the XBee in command mode. ATID would then get information from it. \r\nAT is crap that the XBee won't understand.

The XBee, if it gets the right command, will reply with more than one byte of data. You are only saving the last character that it responds with.

Knowing something about the XBee would be useful. What type is it, and how have you configured it?

Knowing something about how the XBee is connected to the Arduino would be useful.

Knowing whether you are referring to pin 7 of the XBee or pin7 of the Arduino would be useful, too.

Nick Gammon

Code: [Select]

  while(Serial.available()==0) {  }
  while(Serial.available()>0)
   {
    data=Serial.read();
    delay(5);       
   }   


This is not a good way of reading serial data. Try reading this:

http://www.gammon.com.au/serial
http://www.gammon.com.au/electronics

tablet

Hello, thanks for reply. Pauls, the Xbee is Xbee ZB Pro S2B and the xbee is configurated how end device at. To connected the xbee with arduino I use the xbee shield and de pin7 is in the XBee, is pin 12 CTS  / DIO7.
Nick, thanks for the link, I will read the information.
Thanks,
Regards.

PaulS

Quote
To connected the xbee with arduino I use the xbee shield

You misspelled "one of the dozen or so".

afremont


Quote
To connected the xbee with arduino I use the xbee shield

You misspelled "one of the dozen or so".


Yes, it's kind of a shame too.  Makes it hard to pick the right one and they take up shelf space where other shields could sit.  They just add to the confusion.  Another rant issue I have is that they cost way too much.  With the competition, they should be cheaper.  I feel kind of odd paying more for a shield than the module that fits in it.  Just rantin'  ;-)
Experience, it's what you get when you were expecting something else.

Jack Christensen



Quote
To connected the xbee with arduino I use the xbee shield

You misspelled "one of the dozen or so".


Yes, it's kind of a shame too.  Makes it hard to pick the right one and they take up shelf space where other shields could sit.  They just add to the confusion.  Another rant issue I have is that they cost way too much.  With the competition, they should be cheaper.  I feel kind of odd paying more for a shield than the module that fits in it.  Just rantin'  ;-)


Good point. I prefer to use an adapter like Adafruit's on a breadboard, or if I really want to go bare bones, this one from Sparkfun which does nothing electrically, but adapts the module to fit the 0.1" breadboard spacing.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Go Up