From charlesreid1

Background

Two-Station Zigbee Configuration

Zigbee Breakout Board

The first board I was using was a Zigbee breakout board. This had a mini USB plug on it, which allowed me to communicate and control the Zigbee directly from the computer using XCTU (which was provided by Digi Interational, the makers of the Zigbee chip I was using).

In this configuration, there are no "brains" on board the Zigbee that tell it what to transmit, so without the direct connection to a computer, the Zigbee will not talk with anyone. This is our first Zigbee "station."

Zigbee1.jpg

Zigbee Shield

The next configuration I used was an Arduino Uno with a Zigbee shield. This enables the Arduino to utilize the Zigbee for communication, independently of the computer. Now we have a way of setting up a Zigbee "station" that can transmit messages.

We will set up the Arduino Zigbee as the transmitting station, and the laptop Zigbee as the listening station.

ArdunioZigbeeShield.jpg

How Zigbee Works

From this page: https://learn.sparkfun.com/tutorials/xbee-shield-hookup-guide

They explained it pretty clearly. What makes Zigbee such a popular format is that it is simple. There is no extensive coding that needs to be done, no IDE, no microcontroller instructions. It is a serial interface. This means you can think of it like a wireless serial terminal.

That means this page, on using the screen command in Linux to communicate with serial devices, is gonna come in handy: www.cyberciti.biz/faq/unix-linux-apple-osx-bsd-screen-set-baud-rate/

On your computer, when you plug in a Zigbee device (e.g., with a mini USB cable like the one pictured above), it will be added as a device in /dev/*. Using that device file, you can interact with the serial device using the screen command.

Getting Zigbee Working

Here's the rundown of the steps:

  • find the device
  • figure out how to connect to the device
  • determine parameters necessary
  • ...
  • profit?

Find the device

To find the device file that shows up when I plug the Zigbee mini USB into the Mac, I'm looking for a device file that's added to /dev/* when I plug in the Zigbee. Here's how I did that:

Before I plug in the Zigbee, I list all the devices in /dev. Then, I plug in the Zigbee. Then I list all the devices in /dev/ again. I compare the two lists, and I have my Zigbee.

ZigbeeDeviceBeforeAfter.png

Bingo: I can see two new devices corresponding to the Zigbee,

/dev/cu.usbserial-A601FA3K
/dev/tty.usbserial-A601FA3K

Finding Baud Rate

From the SparkFun XBee Shield Hookup Guide, it looks like the connection rate to the zigbee is 9600 baud. https://learn.sparkfun.com/tutorials/xbee-shield-hookup-guide

We need to make a 9600 baud serial connection from the Mac to the Zigbee.

Connecting to the device

Connecting using screen

I used the instructions on this page to connect at 9600 baud to the Zigbee using the screen program: http://www.cyberciti.biz/faq/unix-linux-apple-osx-bsd-screen-set-baud-rate/

I ran:

$ screen /dev/tty.usbserial-A601FA3K 9600,cs8

and I got a "/dev/tty.usbserial' for R/W: resource busy" error message. What that means is, there's already a connection between screen and the zigbee. Use lsof to look for the current session that has a connection with the Zigbee:

$ lsof | grep usbserial
screen    837 charles    5u     CHR               17,8       0t3      645 /dev/tty.usbserial-A601FA3K

Then you can attach to that session using:

$ screen -x 837

This works like any ordinary session of screen: to detach, run Control+A D to detach, Control+A K to kill, screen -ls to list running sessions, etc.

Projects

HackRF and Zigbee

Main page: HackRF/Zigbee

As of June 2016, I am working on a project to transmit information with a Zigbee, receive the signal with a HackRF, and demodulate the signal with Gnuradio.

References

tutorial on arduino + zigbee: http://cs.smith.edu/dftwiki/index.php/Tutorial:_Arduino_and_XBee_Communication

more on the 802.15 protocol used by zigbee, and how to set up a demodulator in gnuradio: http://wiesel.ece.utah.edu/media/documents/pdf/2010/03/25/thomas_project_report.pdf

download X-CTU, the software used to control and interact with the Zigbee devices: http://www.digi.com/products/xbee-rf-solutions/xctu-software/xctu#productsupport-utilities

Flags