Pages: [1]   Go Down
Author Topic: Read parameters of xbee  (Read 491 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49433
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
  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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18810
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  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
Logged


Offline Offline
Newbie
*
Karma: 1
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49433
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
To connected the xbee with arduino I use the xbee shield
You misspelled "one of the dozen or so".
Logged

texas
Offline Offline
God Member
*****
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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'  ;-)
Logged

Experience, it's what you get when you were expecting something else.

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4086
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Pages: [1]   Go Up
Jump to: