Hardware Support: Digi XBee Network
The Digi International XBee Modules are family of wireless communication devices that have their own microcontroller and IO pins that make them useful for many distributed control networks, including on model railroads.
JMRI can communicate with XBee Series 1 and XBee Series 2 modules.
JMRI support for XBee devices includes serial interfaces to XBee Networks. The connection to the computer may be made by any USB or RS232 XBee adapter. Tested adapters include:
- The Sparkfun Electronics XBee Explorer USB
- The Sparkfun Electronics XBee Explorer Serial
- The CISECO Slice of Pi (in conjunction with a Raspberry Pi)
JMRI can communicate with XBee Series 1 and XBee Series 2 modules.
In JMRI versions Prior to 4.5.5, Underlying support for communication is provided by Andrew Rapp's xbee-api library for Java.
Starting with JMRI version 4.5.5, the Underlying support for communication is provided by The Digi XBee Java Library.
Both library requires that the XBee module connected to the PC be configured for API mode with escapes (mode 2).
JMRI support for the Digi XBee Modules currently includes the ability to passively read digital sensor inputs, as JMRI Sensors, and triggering digital outputs, through the JMRI Lights and Turnouts.
XBee Module Addressing
Each XBee module has 5 addresses we need to be aware of:
- a Channel Number
- a 16 bit PAN address
- a 16 bit User address
- a 64 bit Globally Unique ID
- a free-form Node Identifier string
The IEEE 802.15.4 Channel Number is set by configuring the XBee's CH parameter. The value of the CH parameter can be any (hex) value from 0x0B to 0x1A. This corresponds to decimal values 11 to 26. All XBee modules in the network must be set to the same channel number.
The 16 bit PAN (Personal Area Network) address is assigned by setting the XBee's ID parameter. All XBee modules in the network must be set to use the same PAN.
The 16 bit user address is defined by the XBee's MY parameter. Some XBee firmware will automatically set the value of MY to be a unique address on the network, but others do not. If the My parameter is user configurable, it should be a unique address.
The 64 bit globally unique id (GUID) is defined by the factory. This value is the hex string printed on the underside of each XBee module. You can also read the value by reading the SH (Serial Number High) and SL (Serial Number Low) parameters of the XBee. The user cannot change the values of SH and SL.
The free-form Node Identifier is a 20 character text value stored in the XBee's NI parameter. The Node Identifier should be unique, and may be human readable.
Note: You need to be aware of other devices using IEEE 802.15.4 radio networks that may be operating in the same area. Digitrax Duplex throttles and Roco MultiMaus Pro radio throttles both use IEEE 802.15.4 as the underlying network layer protocol. If these devices share a PAN and channel with your XBee modules, the devices are all a part of the same network, and the 16 bit user address must be unique.
Input/Output pin addressing
When creating inputs (Sensors) and outputs (either Lights or Turnouts) in JMRI, the XBee's IO pins can be individually addressed. To access a single bit, you can use the form:
Where ModuleAddress is one of the 16 bit node address, the 64 bit node address, or the Node Identifier string and Pin is an XBee IO pin number.
Turnouts may be created using two bits. To specify a turnout created with two bits, you use the following format:
Where ModuleAddress is one of the 16 bit node address, the 64 bit node address, or the Node Identifier string and Pin1 and Pin2 are XBee IO pin numbers. The Pin numbers do not need to be consecutive.
Automatic Creation of Sensors
When an XBee input status message is received indicating one ( or more ) of the XBee IO Pins is used as an input, JMRI will automatically create a sensor for each input pin if it does not already exist.
When sensors are created automatically, the Node Identifier will be used for the ModuleAddress if it is not blank. If the Node Identifier is blank, the 16 bit MY address field will be used for the ModuleAddress unless the MY address field contains a broadcast address. If neither the Node Identifier or the 16 bit MY Address are used for the ModuleAddress, the 64 bit GUID will be used for the ModuleAddress.
Adding an item to the table
When you add an item to one of the tables, many times you only
have to fill in the numbers to have JMRI construct
the complete system name.
Here's a summary, split up for outputs (eg. Turnouts) and inputs (eg. Sensors):
|In/Out||Entry||Meaning||makes System Name||Mask||Equivalent||Minimum||Maximum|
|i||4:3||ModuleAddress:Pin||ZS4:3||int : int||pin: 0||pin: 7|
|o||4:3||ModuleAddress:Pin||ZS4:3||int : int||pin: 0||pin: 7|
|o (Turnouts)||4:3:4||ModuleAddress:Pin1:Pin2||ZT4:3:4||int : int : int||pin: 0||pin: 7|
- Connect your XBee adapter using the appropriate cable.
- USB-connected XBee adapters may need to have a driver installed. See the documentation provided by the manufacturer of your XBee Adapter.
- Make sure you have the latest version of JMRI, then go to the preferences panel of a JMRI-based program. This opens automatically the first time a program is run, or you can select it from the "Edit" menu
- Select "IEEE 802.15.4 Network" from the System Manufacturer selection box.
- Select "XBee Network" from the System Connection selection box.
- You can then select the proper serial port in the
Serial port selection box under Settings.
Note that USB XBee adapters will appear as a serial port.
- The "Connection Prefix" is used to help JMRI communicate separately with multiple "connections" to layout hardware. Each "connection" must have a unique identifier, which is specified as the "Connection Prefix". By default, the first XBee connection is given a prefix of "Z", and additional XBee networks are given prefixes like "Z1", "Z2", ... Most users should be able to use the default "Connection Prefix" value provided by the JMRI tools.
- When a JMRI tool is configured for more than one connection, each connection gets a menu item on the main JMRI tool window. To help users differentiate between their different connections, each connection has a "Connection Name", which is used as the name of the associated menu item on the main JMRI tool window. Users may change the "Connection Name" for any connection to suit their needs.
- The XBee adapter "Additional Connection Settings" provides access to the Baud rate for the connection. Make sure the selected Baud rate matches the port speed setting of your XBee.
- The "Configure XBee Nodes" button opens the XBee Node Configuration tool. If you save Preferences after Nodes are created, node address information will be stored with the JMRI Preferences.
- Click "Save". You'll be asked if it's OK for the program to quit; click "Yes".
- Restart the program. You should be up and running.
JMRI XBee Tools
The XBee Node Configuration tool can be used to add XBee Nodes to a JMRI configuration. You can access the tool from the Xbee menu when an XBee connection is active. The "Configure XBee Nodes" button at the bottom of the JMRI Preferences Connections tab also opens the XBee Node Configuration tool. If you save Preferences after Nodes are created, node address information will be stored with the JMRI Preferences.
Third Party info
Digi Intl. XBee web site