10 years, 8 months ago.

Communication between two Xbees using Mbed

Hi i am trying to communicate between two xbees (digi S1 bought from sparkfun). I am using one Xbee as TX and other as RX. my Transmitter is working fine but receiver is not getting anything :( don't know what is the problem. can anyone help me

attached is the code of both TX and RX

..........TX.................

  1. include "mbed.h" Serial xbee1(p9, p10); DigitalOut rst1(p11);

DigitalOut myled1(LED1); DigitalOut myled2(LED2);

Serial pc(USBTX, USBRX);

int main() {

pc.baud(9600); xbee1.baud(9600);

char a,b; char buff[]="1111 1234 mynameisaftabmynameisaftabmynameisaftab";

while(1)

{

rst1 = 0;

wait_ms(1); rst1 = 1;

int i=0; if(xbee1.writeable()) { while(buff[i]!='\0') { xbee1.putc(buff[i]); pc.putc(buff[i]); i++; myled1=0; wait(.1); myled1=1; } }

} }

.......RX..............

  1. include "mbed.h" Serial xbee1(p9, p10); DigitalOut rst1(p11);

DigitalOut myled1(LED1); DigitalOut myled2(LED2);

Serial pc(USBTX, USBRX);

int main() {

pc.baud(9600); xbee1.baud(9600); int i; char a,b; char data[100];

reset the xbees (at least 200ns)

while(1)

{ i=0; rst1 = 0; wait_ms(1); rst1 = 1;

if(xbee1.readable()) { a=xbee1.getc(); while(a!='\0') { data[i]=a; pc.putc(data[i]); i++; a=xbee1.getc(); myled1=0; wait(.1); myled1=1; } }

} }

can anyone help me :(

2 Answers

10 years, 8 months ago.

Before you use this code for data transmission, you must configure the modules individually.

Good tutorial is: http://examples.digi.com/get-started/basic-xbee-802-15-4-chat/

Please, place your code into <<code>>your code<</code>> tags. It's more readable.

Accepted Answer
Syed Aftab
poster
10 years, 8 months ago.

Thank You Martin

It works fine with the character echo program found in xbee cookbook but when i send data from one mbed to another transmitter transmits but receiver doesn't receive anything :( i have sent the PAN ID =3332, DH=0,DL=0,MY=0 of all the devices can this be a problem??

Check my link at above. It's all described there.

In a nutshell, if you want connect 2 Xbees, so for the first one: PAN ID=3332, MY=1, DH=0 , DL=2

and for the second XBee: PAN ID=3332, MY=2, DH=0 , DL=1

You can't set the same addresses as you wrote.

posted by Martin Wolker 01 Aug 2013

Martin actually what happens is that i am getting the data using the RX xbee with X-CTU when connecting to PC. but when i RX data over mbed and then Display it using putty over serial i get no output ? if the problem is with the ID's (MY,DH,DL) then why am i getting the data on PC using the xbee explorer

posted by Syed Aftab 01 Aug 2013

Even I facing the same problem. The data is tranfering from arduino to mbed using XBEE but not in between mbed. Please give some suggestion if your problemm is solved.

posted by chetan chowdary 06 Apr 2017