Go Down

Topic: Arduino and XBee Serial communication (Read 9 times) previous topic - next topic

TimBot

Feb 10, 2011, 12:09 am Last Edit: Feb 10, 2011, 12:17 am by TimBot Reason: 1
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 http://www.sparkfun.com/products/9132 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
Code: [Select]
#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
Code: [Select]
#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 :) Maybe a pointer to some documentation i have missed?

Many thanks,
Tim

mowcius

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.

TimBot

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:
Quote
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

mowcius

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

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

Tim

Go Up