Mac OS X Talks to AVR MT 128 via XBee

This little project is about communicating between a Mac (or Linux) system and an AVR MT 128 using an XBee device for wireless communications.

So, what's an XBee? It's a small wireless transceiver that operates in the same 2.4GHz spectrum as WiFi (and doesn't interfere at all), implements the
IEEE "ZigBee" standard, and is manufactured by MaxStream. They are primarily designed for wireless control applications, but have all sorts of uses. The simplest use for a pair of XBees is a wireless serial cable replacement. Depending upon power/range, you can buy them for $20 or about $35 from DigiKey.

HPIM4220


As a prototyper/hobbiest, though, to work with an XBee you really need a breakout board because XBee's pin placement is 2mm whereas most breadboard and protoboard placement is 0.1".
Spark Fun has such a breakout which I used over on the XBee GPS project. But to plug an XBee straight into your PC or Mac you need to get a USB dongle for it. The only company I know of which sells such a dongle is the Selma group and they make a family of boards called the AppBee.

Using the Selma "AppBee" USB board connected to my Mac, I can talk to an AVR MT 128 through a 'virtual serial' connection. Here's how the evolution worked for me:

I needed to make a simple serial cable to connect the AVR MT 128 to the AppBee breakout board:

HPIM4212

I pulled a 4 strand strip of ribbon cable from my infinite strand of ribbon cable supply, soldered some molex connectors and inserted them into the housings. Added a little shrink wrap around the ribbon for some strain relief and connected it to the molex of AVR MT 128. Note the colors don't mean anything in this setup. (See the phyiscal pinout of the AVR MT 128).
HPIM4221

I later went with a different cable because I wanted to be able to use the same cable to tie into various serial devices, not just an XBee breakout. This is that cable tied between the XBee breakout and the AVR.
HPIM4218

So, that was the AVR side. The Mac side looks like this:
HPIM4222
This is an XBee mounted in a Selma AppBee USB dongle breakout. When you plug it in you get a new /dev devices called:

/dev/tty.SLAB_USBtoUART

Using the 'screen' command native to Mac OS X and Linux systems, I could connect to the USB/XBee with this command:


whitecloud:~/Documents/360vl-src/sawdust lcox$ screen /dev/tty.SLAB_USBtoUART 9600

That command will connect to the device at 9600 baud and allow you to see what's coming across as well as type characters that will be sent over the connection.

I thought this setup would be sufficient and it almost was. The default demo firmware on the AVR will send a serial string when you poke the top button. I could see the serial sting coming out on the Mac side, however, after a few pokes the AVR would go belly up. The +5V output to the XBee would drop to 4V and everything was hung.

So, I powered the XBee externally from my bench supply, shared a common ground, and could send strings from the AVR to the Mac all day long. I saw a note on the Spark Fun forums that suggested it was possible to power the AVR by injecting 5V into the external pins rather than using the 12VDC wall wart through the DC Jack. I quickly hooked up a AA to 5VDC step up converter to test it out. The setup now looked like this:


HPIM4225
With the AVR being powered this way, there seemed to be more juice to drive the XBee. I could send strings back and forth with this setup and never have any problems.

Here's the string the default AVR firmware is sending over the serial port. The Mac is receiving this through the XBee dongle using the screen command above. The display on the AVR in the picture above is taken after I had typed "sent from mac through xbee" on the Mac's screen session.

screenoutput

This all worked great and let me communicate with the Mac. I also have an identical XBee dongle on my Linux laptop running a similar screen command. XBee out of the box will broadcast so the Linux machine was seeing all the XBee traffic between the Mac and AVR. XBee can be programmed to use addresses and create interesting networks, but the default mode of XBee is a simple serial cable replacement.

With this setup there was no place I could go in my house where I wasn't able to communicate. This test was all with XBee Pro which is more powerful than the standard XBee. I also did these tests in the presence of 3 802.11 access points and numerous 802.11 clients with no interference to them.

Clicky Web Analytics