Friday, October 24, 2014

XBEE Series 1 Configuration

Sources

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

Introduction

In this tutorial we will be configuring an XBee to send text from one computer to another, and eventually from a microprocessor or microcomputer to a computer.  XBee is a wireless communication module that allows point-2-point communication or mesh communication.  It is a complex device that provides a simple solution to wireless communications.

XBee is an RF device.  It is essentially a radio.  Other forms of wireless communications are Bluetooth and Wifi.

There are two types of XBee modules, the Series 1 (S1) and the Series 2 (S2).  The S1 is an Xbee Wireless 802.15.4 Wireless Module while the S2 is an Xbee ZB ZigBee Module.  The two are not compatible as they use different protocols.  In this tutorial we will be dealing with the XBee S1.

Equipment and Software

Figure 1:  2 XBee S1 modules and 2 XBee USB breakout boards.

Figures 2 and 3:  Close ups of XBee S1 and XBee USB breakout board.

Figure 4:  XBee module lines up with silk screen on USB board.


If you don't already have a Virtual Com Port (VCP) driver you will need to download and install one from FTDI.  You can check if you already have a compatible VCP or if your FTDI driver installed properly by opening Terminal (on OSX and Linux.  Windows should just skip ahead and use the software provided) and typing the following command.


 ls /dev/tty*  

Figure 5:  Without module inserted into USB drive.

Figure 6:  With module inserted into USB drive.  
A new device appears for our wireless module. 

You will need a serial port viewing program.  You can use a multitude of programs but this tutorial will be using CoolTerm because it is a small and simple program

Download and open CoolTerm with the device plugged in.  Click Options.

Figure 7:  CoolTerm Serial Port settings.

Select the Port that we saw earlier in Terminal.  If using Windows, the Port will be "COMx" where x is a number, e.g. COM3, COM5.  Baudrate could range from 1200 to 115200, you may need to try a few different rates.  Data Bits should be 8, this designates the number of bits per word.  Parity should be "none" and Stop Bits should be 1.   Now click the "Terminal" tab.

Figure 8:  CoolTerm Terminal settings.  This configures the window that you type in.

Make sure "Local Echo" is checked.  This echoes what you type to the screen so you can see what you typed (and you thought computers just did this didn't you?  Nope your OS echoes keyboard inputs to the screen so you can have visual feedback).

Click "OK" then "Connect" on the top bar menu.  Now we will program the XBee.  All commands except for the start command begin with "AT" and the last two letters are abbreviations for what you are doing.  When typing "+++" do not hit "Enter", wait about 3 seconds until you see "OK" appear. If you do not see "OK" appear then try a different Baud Rate. For all following commands, hit "Enter" to submit setting.  You should see "OK" after every command.  The Xbee drops out of configuration mode after 10 seconds of none use. 

+++      -   Command to begin setting the XBee
ATID   -   Personal Area Network ID (PAN ID).  Only XBees on the same PAN ID can communication with one another.  This allows you to have many sets of XBees buzzing around in the same area.
ATMY -   32-bit address of XBee being programmed.  
ATDH  -   16-bit High byte of address of XBEE being written to.
ATDL  -   16-bit Low byte of address of XBEE being written to.  ATDH + ATDL must = ATMY
ATBD  -   Baud rate are:
    0 = 1200
    1 = 2400
    2 = 4800
    3 = 9600
    4 = 19200
    5 = 38400
    6 = 57600
    7 = 115200
ATWR -   Saves XBee settings to non-volatile memory (will not change if power-cycled).

Table 1:  AT Command Layout.
Command Parameter Description
+++ none Enters configuration mode
ATID PAN ID 0 to FFFFFFFFFFFFFFFF
ATMY My Address 0 to FFFE
ATDH Destination Address High MSB of other XBee Address
ATDL Destination Address Low LSB of other XBee Address
ATBD Baud Rate 1 through 7
ATWR none Saves settings to XBee


Table 2:  Example settings for two XBee S1 modules.
Command XBee A Parameter XBee B Parameter
+++
ATID DEAD DEAD
ATMY 1 2
ATDH 0 0
ATDL 2 1
ATBD 7 7
ATWR

Figure 9: Configuring XBee A with CoolTerm.


Figure 10: Configuring XBee B with CoolTerm.

Now that you have both your Xbees configured you can now transmit data wirelessly!  To check that the two Xbees are communicating somehow have two serial ports open connected to the XBee modules, either one one computer or two different computers.  If you open the two ports with CoolTerm you will see what you type into one window appear in the other.

Head on over to BeagleBone Black UART Tutorial to learn how to send and receive data via a serial port on the BeagleBone Black.  In theory, this is the same thing just on a microcomputer, a UART serial port instead of a USB serial port, and code instead of CoolTerm.



No comments:

Post a Comment