Arduino and XBee Serial communication

Hi All,

First, I have to say i really love how easy everything is with the Arduino boards! Spent months struggling with PICs and it is such a pleasure to work with these easy to use chips.

Anyway, i have 2 Arduino Uno boards and 2 XBee 2.5 modules. I have a couple of SparkFun XBee Explorer Regulated - WRL-11373 - SparkFun Electronics for the XBees, so no way of programming the XBee, but was hoping to use the 2 XBees in the default transparent serial mode.

I have a very bare bones setup:

Stand alone Board (Powered by a 9v bat.) with pin 2 (Arduino) connected to DOUT (XBee) and pin 3 connected to DIN
and the following arduino code

#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
#define ledPin 13
SoftwareSerial xbee =  SoftwareSerial(rxPin, txPin);
void setup(){
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  xbee.begin(9600);
}

void loop(){
  xbee.print('A');
  delay(100);
}

NOTE: Previously, i had this standalone arduino/xbee use the RX/TX pins 0-1 but then switched to SoftwareSerial as a test, but same results.

I then have a second arduino, connected to a XBee with in 2 (Arduino) connected to DOUT (XBee) and pin 3 connected to DIN (Same as the standalone board)
and the following code

#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
#define ledPin 13
SoftwareSerial xbee =  SoftwareSerial(rxPin, txPin);

void setup(){
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  xbee.begin(9600);
  Serial.begin(9600);
  Serial.println("Starting XBee Comunication");
}


void loop(){
  Serial.println("Waiting for XBe");
  Serial.println(xbee.read());
  //Serial.println(rec);
}

The DIN LED blinks on the standalone board when running, but the board connected to the computer never prints anything via the usb-serial monitor, nor does the DOUT led on the XBee of the receiver (connected to computer)

Little perplexed by this, am I thinking about this correctly?

Would be very grateful for any guidance on this :slight_smile: Maybe a pointer to some documentation i have missed?

Many thanks,
Tim

You need to configure the XBees to talk to each other.

If you have an FTDI cable/breakout board then you can connect it to those boards you have and use X-CTU to configure them, or use the USB to serial chip (ATmega8U2) on the arduino by removing the ATmega chip and connecting to the corresponding pins. O
r you can configure them by serial commands sent from the arduino boards.

Mowcius! Thanks for the response!

Ok, so this is where i must be missing something, because looking at the XBee datasheet (http://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf), i read this:

By default, XBee®/XBee-PRO® RF Modules operate in Transparent Mode. When operating in this
mode, the modules act as a serial line replacement - all UART data received through the DI pin is
queued up for RF transmission. When RF data is received, the data is sent out the DO pin

So i thought that the default factory settings would allow 2 XBees to comunicate without further configuration.

Many Thanks,
Tim

You still to change some settings.
They are set up in Transparent mode but they are not set to communicate with each other.

Excellent! Thanks for the info Mowcius!

I have an XBee Explorer Shield on the way from CoolComponents, so will be able to get to the bottom of this tomorrow.

Thanks again for taking the time to answer my (newbie) questions :wink:

Tim

TimBot:
Excellent! Thanks for the info Mowcius!

I have an XBee Explorer Shield on the way from CoolComponents, so will be able to get to the bottom of this tomorrow.

Thanks again for taking the time to answer my (newbie) questions :wink:

Tim

Well when you get that board I will happily help you set them up.

The basics are:
Get X-CTU software
In 'Modem Configuration' - Download new versions (get the latest module firmware)

Click 'Read'
Change the 'Version' drop down to the latest version
If my memory serves me correctly, the function set for one of them should be router and one should be end device (doesn't matter which for simple point to point)
Then change the PAN ID to a value - doesn't matter what it is as long as the values are the same for both modules.

There are a few other values you can change (power settings etc) but if you need them in the future you will learn what they all do. Basically, if you don't know what it does, don't fiddle :smiley:

Then write it to the module, unplug the USB board from the computer, swap the modules, plug the USB board back in and do the same for the second module.

Mowcius

Got this working :slight_smile:

There is a thread on this forum that actually details the steps you need Arduino Forum. Although i found the info on youtube (of all places :slight_smile: Zigbee / XBee Adapter Configuration Tutorial - YouTube

Basiclly, there are a few pages on the web that say it works "out of the box" for serial communication: this isn't the case! You do need to configure a couple of settings.

Also note that while it can be handy to have the xbee usb explore or the xbee arduino shield, they aren't strickly needed. you can do everything you need just using your arduino board (i am using an Uno).

As Mowcius points out in this thread, you can remove the big chip from the Arduino, and then connect the tx to din and rx to dout on the arduino and xbee respectively. You should then be able to configure your xbees as described in the video above. (although obviously, you would need 2 arduino boards if you wanted to test them simultaneously.

Don't give up, once you have this step sorted, the XBees work like a dream, a real plug and play solution for serial communication (and even then you can delve into the documentation, and start doing some really fancy mesh type things).

Thanks to Mowcius for your help. and to everyone involved in one of the best open source projects ever!

Tim

Glad you got it working :slight_smile:

Mowcius