mbed + xBee

25 Sep 2009

Hey

Just got my mbed today and im loving it. I was just wondering if anyone knows if the mbed would support the xbee system. I have two xbees and I really want to see if I can get them talking through the mbed.

Any ideas?

25 Sep 2009

It seems they use serial interface (UART). mbed has supports that out-of-box.

25 Sep 2009

Yes it is serial to serial, but I was wondering how the pins should be connected. I am not very experienced at this and have used arduino shield in the past, but there is no mbed sheild..yet...

26 Sep 2009

Hi Vlad,

I haven't got one of these in front of me, but just had a look at the datasheet and this might help get you started:

First, the wiring. Main thing looks like power, serial and the reset. e.g.

1 VCC -------------- 3.3v
2 DOUT ------------- mbed serial rx (e.g. p10)
3 DIN -------------- mbed serial tx (e.g. p9)
4 not connected
5 RESET ------------ mbed digital out (e.g p11)
6-9 not connected
10 GND ------------- 0v/GND
11-20 not connected  

Then, get it doing something. An example using two xbees (totally untested!):

// basic xbee example
// - take chars from the terminal, push them out xbee1
// - listen on xbee2, and print value + 1 to terminal

#include "mbed.h"

Serial xbee1(p9, p10);
DigitalOut rst1(p11);

Serial xbee2(p13, p14);
DigitalOut rst2(p15);

Serial pc(USBTX, USBRX);

int main() {

    // reset the xbees (at least 200ns)
    rst1 = 0;
    rst2 = 0;
    wait_ms(1); 
    rst1 = 1;
    rst2 = 1;
    wait_ms(1); 
 
    while(1) {
        if(pc.readable()) {
            xbee1.putc(pc.getc());
        }
        if(xbee2.readable()) {
            pc.putc(xbee2.getc() + 1);
        }
    }
}

Hope this gets you started!

Simon

27 Sep 2009

Thank you so much for your quick reply.

This is exactly what I need and I am pretty sure it will work flawlessly.

I will start working on this tomorrow and then maybe write/draw something up for everyone else.

Then I will try to create something more permanent for it.

BTW have you heard of anyone experimenting with iPhone + mbed utilites. iPhone has serial rx and tx pins and so does the mbed. Now that would create some useful applications!

27 Sep 2009

Vlad Cazan wrote:
Thank you so much for your quick reply. This is exactly what I need and I am pretty sure it will work flawlessly. I will start working on this tomorrow and then maybe write/draw something up for everyone else.

Great. Just make an XBee page in the cookbook and note down your experiments. These are great modules and i'm sure others will want to use them (apart from the 2mm pitch :( but sparkfun have a breakout http://www.sparkfun.com/commerce/product_info.php?products_id=8276)

Vlad Cazan wrote:
BTW have you heard of anyone experimenting with iPhone + mbed utilites. iPhone has serial rx and tx pins and so does the mbed. Now that would create some useful applications!

I heard a good few people comment on it, and I think maybe someone is working on it. Philip?

There are some examples just doing basic control of ipod already (play, song select etc) see http://mbed.org/projects/cookbook/wiki/iPod, but I agree, a bridge to iPhone/Touch apps would be awesome. Maybe an opportunity for an iPhone RPC interface to make it nice an easy :) (see http://mbed.org/projects/cookbook/wiki/RPC)

Simon

27 Sep 2009 . Edited: 25 Nov 2009

For future reference the full guide is here: mBed + xBee

Code is here: XBeeTest2XbeeTest