Pages: [1]   Go Down
Author Topic: Single XBee shield blues  (Read 800 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 
Hello forum, got some really embarrassing questions. It seems everyone has trouble getting two xbees talking to each other, I have managed to mess up a monologue. Here goes.

I got an xbee shield & xbee similar to this one (not actually from that shop but it looks identical, got mine from a phyisical shop).

I downloaded X-CTU and after immense amounts of trouble managed to upload into it and set it up as ZIGBEE ROUTER/END DEVICE AT. In X-CTU's terminal, it responds to +++ and replies to AT commands.

So far so good.

Now, I thought I 'd take tiny little baby steps and try chatting between the Arduino and the shield (as opposed to between XBee-ed Arduinos) since I only have one Arduino (Duemilanove) right now.

So, the last section on Arduino's XBee shield reference page ("Configuring the Xbee Module") seems to imply that it's fairly easy for the Arduino to get the XBee into configuration mode and then have a talk via AT commands. Well...

First sign of trouble, shield on top, jumpers to "XBee", when trying to upload any sketch, the IDE reports that:

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding


Damn! I haven't seen anyone else reporting you have to have the shield off when uploading but maybe I haven't been looking. So, first question, do you?

Anyway, I can upload the damn thing and then stick the shield on so that kinda works, till I hit the next obstacle, with the shield on, weird chars appear in the IDE's monitor (baud rate is checked). Sometimes most of these go away with a few delay() statements thrown around the code but sometimes everything is gibberish. So, question number two, WTF?

Still, I have an LCD and I 'm not afraid to use it. The shield allows access to pins 8-13 so I requisitioned 12 and 13 for NewSoftSerial and fed the following sketch to my board:

Quote
#include <NewSoftSerial.h>

NewSoftSerial LCD(12, 13);

const int bufferSize = 10;
char ca[bufferSize];

void setup() {
  
  Serial.begin(19200);
  LCD.begin(9600);
  
  LCD.print(12, BYTE);
  Serial.print("+++");
  
  delay(10000);                      // normally one second should be enough for XBee to answer but let it breathe
  
  int i = 0;
  while(Serial.available() > 0) {
    ca[i++] = Serial.read();
    LCD.print(".");                 // show if there's activity
  }
  ca = '\0';
  
  LCD.print(ca);
  LCD.print("end");                // if this prints alone, nothing got received
  
}


void loop()
{
}


Just a couple of comments,  LCD.print(12, BYTE); clears the LCD.  Serial.begin(19200); is just a value I got at some Arduino/XBee tutorial (can't find it now) since I didn't have a clue what kind of baud rate the Arduino/XBee chatter should be at. Is that an OK value?

Now, no prizes for guessing that the code prints a single "end" and that's it. So, I 'm out of ideas. Any help would be greatly appreciated.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 653
Posts: 50881
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I haven't seen anyone else reporting you have

There is a jumper on that shield. You have to have the jumper in the USB position to upload sketches, and in the Xbee position to have the Arduino talk to the XBee.

The xbee takes whatever appears on the TX pin of the Arduino and broadcasts it to any other radios on the XBee frequency along with some additional information (who it's from, who can decode it, etc.). If those other XBees are in the right PAN, and are the target of the message, they might do something with the data and reply.

The sending XBee listens for responses, and puts whatever it hears on the RX pin of the Arduino.

With just one XBee, you are listening to the sound of one hand clapping with the Serial Monitor.

You really do need two radios to do anything useful.

I won't tell anyone you were asking
Quote
really embarrassing questions.
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You have to have the jumper in the USB position to upload sketches, and in the Xbee position to have the Arduino talk to the XBee.

Duh, how stupid am I?  smiley-razz

And of course you 're right, I should be trying with two Arduinos but for the time being one is all I have (you 'll get some real gems when I get the second one, just you wait).

Still, the question remains, why don't I get an "OK<CR>" to my "+++"? I should be getting replies from the XBee right? The way I understand it, with the jumpers in the XBee position, Serial.print() statements go to both the XBee and the computer via USB with the only drawback being that the comp can only receive but not talk. So, my sketch should at least print some reply from the XBee (BTW, my 10 seconds delay is enough for the XBee to drop out of configuration mode. This value is just for extravagance, I have also tested with around 1.5 seconds. Also, the replies, if any, should be waiting around in the Arduino's buffer till Serial.read() fetches them).

Also, any idea why the garbled chars when printing to the IDE's serial monitor?
« Last Edit: January 09, 2010, 06:32:05 pm by ardudillo » Logged

Spokane, Washington
Offline Offline
God Member
*****
Karma: 1
Posts: 686
My name is Bob, and I'm an addict.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I haven't had any experience with Xbee yet, but normally in Serial monitor, when it's "garbage" coming through, either, you're reading too fast for the buffer to fill up, which is doubtful.... or it's at the wrong baud rate.

Like I said.. no experience with Xbee, so not sure what they're baud rates normally are, but try changing your baud rate and see if that makes a difference.
Logged

Pages: [1]   Go Up
Jump to: