XBee Testing (using a mac)

I've finally got a basic test of xbee communication working.  I'll document my experience here, which could be useful for other mac users.

Equipment:

Sparkfun Xbee USB Explorer

Sparkfun Xbee Regulated Breakout Board

1xXbee 1mw 2.5 series module with wire antenna

1xXbee Pro 50mw 2.5 series module with wire antenna

Macbook running 10.6 Snow Leopard

Cables, breadboard etc.

 

Mac setup

1. Download FTDI drivers for Mac: http://www.ftdichip.com/Drivers/VCP.htm

2. Install Minicom

I found minicom the easiest terminal program to use:

installed using:

> sudo port install minicom (requires www.macports.org)

3. Install VirtualBox (www.virtualbox.org) and a Windows virtual machine (I used Windows XP)

4. Install digi xctu http://www.digi.com/support/productdetl.jsp?pid=3352&osvid=57&s=316&tp=5&tp2=0 on Windows XP virtual machine (FTDI drivers also required to be install for Windows)

XBee Config

I found that my xbee's didn't want to communicate out of the box so followed the guide here: http://blog.kevinhoyt.org/wp-content/xbee-setup.pdf to set one as a Router and the other as the Coordinator (I used the pro as the Coordinator).  I used the same Pan Id of 332 for each and kept baud at 9600 for testing.  Config was done by plugging each into the usb explorer in turn then using xctu on the windows virtual machine.

Hardware Setup

I followed http://mbed.org/projects/cookbook/wiki/XBee wiring hookup to connect the standard xbee to my mbed (with the exception of using the 5v VU since I used the regulated breakout).  The Xbee Pro was kept in the usb explorer.  I used the following code:

 

#include "mbed.h"


Serial xbee1(p9,p10);

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

Serial pc(USBTX,USBRX);


int main() {

    
    while(1) {
    
      myled1=0;
     
      if ( xbee1.readable()) {
        myled1=0;
        pc.printf("Data: ");
        
        char c;
        
        c=xbee1.getc();        
        
        pc.putc(c);
        pc.printf("\n");
        
        if (c=='l') {
            pc.printf("LED toggle\n");
            myled2=!myled2;
        }
        
        myled1=1;
        wait(1);
      
      }  
      
      if (pc.readable()) {
      
        xbee1.putc(pc.getc());
      
      }
    
    
    }

}

 

 

I then fired up two OS X terminal windows.  Using ls /dev/tty. then tab you can get the device names for the two usb connections.  Mine was usbmodem... (mbed) and usbserial... (explorer) -> note, I'll try and copy exact names later.

Open a minicom connection in 1 terminal to the mbed (I found I had to sudo this and you'll need to run minicom -s to set up the modem details) and a minicom connection in the other to the usb explorer (message if you need me to post more minicom details).

Typing an 'l' in the usb explorer terminal should toggle led 2 on the mbed.

 

 

 

 

 

 

 


0 comments

You need to log in to post a comment