![](/media/cache/group/digilogo.png.50x50_q85.jpg)
ZigBee Send Data example for mbed XBeeLib By Digi
You are viewing an older revision! See the latest version
Homepage
Description¶
This example shows how to send data to a remote XBee module.
The application creates a message for a remote XBee module.
This library encodes and sends it to the local XBee module through the serial port. Then the local XBee module sends the packet to the remote XBee module through the air.
The example shows how to send both uni-cast and broadcast messages. Also how to send messages to the network coordinator.
See Sending data to another module chapter for more information on data transmission.
Common Setup¶
In this chapter we'll describe the setup required to evaluate the examples. That implies creating a wireless network between two XBee modules.
One of them will be physically connected to the mbed module though a serial link. We'll call it the 'local XBee module'.
The other one will be called the 'remote XBee module'
Remote Setup¶
The more comfortable remote setup to evaluate these examples is having the remote XBee module mounted in baseboard (XBIB, TODO....) and connected to the PC through an usb cable to create a serial connection.
Open XCTU tool and connect to the remote XBee module through corresponding serial connection.
With XCTU tool its easy to configure the remote XBee module settings so it creates a wireless network with the local XBee module. Once the network is created, you can even discover the local XBee module through the air and check that the module settings match the requirements explained in the 'Local Setup' chapter.
The XCTU tool is later used to evaluate the examples by injecting or monitoring packets in the network.
Information
When using ZigBee modules, it's usual that the 'Remote XBee' it's an X-STICK module acting as the network coordinator.
Local Setup¶
The local setup includes:
- The mbed module and its debug connection to the PC (normally an usb cable)
So you can see the sample application debug messages. For that you have to configure the DEBUG_TX and DEBUG_RX pins in config.h and open a console in the PC on the corresponding serial port.
See Configuring the library and Debugging the library chapters for more info. - The connection between the mbed module and the local XBee module
That includes at least wiring and configuring RADIO_TX and RADIO_RX in config.h. Wiring RADIO_RESET is highly recommended as well.
See Configuring the library and Initializing modules chapters for more info. - The local XBee module persistent configuration
This library expects that the local XBee module has the default settings stored (but for the "AP" setting that must be set to 1 or 2). You can verify those settings previous to run the example using XCTU tool through following two options:
- Having the local radio wired to the mbed module, you can discover the local XBee module from the remote XBee module in the same network as explained in the 'Remote Setup' chapter.
- You can temporarily unplug the local XBee module from the mbed module and plug it to the PC.
Special care must be taken with following settings:
- "ID" and rest of Networking settings: Leave them default or customize them as in your remote XBee module. The important thing is that both local and remote XBee modules create a network. This library has methods to change these settings but the sample applications are not calling them.
- Firmware: In S2B modules, end-device firmware will complicate evaluation of standard examples because the radio will sleep automatically. To avoid that it's recommended to flash 'router' firmware that make devices don't sleep.
- "SM" setting: Set it to 0=No Sleep.
- "BD" setting: The sample applications expect it set to 3=9600bps. If you change it, change it in the sample application accordingly (See Initializing modules chapters for more info).
- "AP" setting: It's compulsory to change this setting set to 1 or 2 !!!!.
Example Setup¶
Broadcast messages and messages to the coordinator don't require any configuration, but for the unicast messages you have to configure the remote device 64-bit address by customizing the REMOTE_NODE_ADDR64_MSB and REMOTE_NODE_ADDR64_LSB defines with the remote XBee module 64-bit address.
Running the example¶
Build and deploy the example to the mbed module.
Reset the mbed module so the example starts. You should see the example debug information through the debug interface configured in the 'Local Setup' chapter.
Once joined to the coordinator, the application will first send a message to the coordinator, then a broadcast message and finally a couple of unicast messages to the configured remote XBee module.
Verify that the remote XBee module is receiving the frames by accessing the "Console" tab of the X-CTU. You should see there the broadcast and unicast messages. If the remote XBee module is also the network coordinator, you should see there also the message sent to the coordinator.