Getting Started with Zigbee S2 I/O

You can connect a sensor node or a switch to an I/O pin of S1 module and program the other module to follow the changes happening to that I/O pin. The changes reflect at the I/O pin of the distant radio. No external microcontroller is required for a S1 Direct I/O.

This I/O functionality is not possible with S2 modules. But this can be achieved by reading the API frames transmitted by the sensor node. The XBee radio at the sensor node should be configured as a ROUTER or END device & the data collecting XBee should be configured with COORDINATOR API Firmware

Before going further, let us have a brief overview of the two modes of data transfer in Xbee – Transparent data mode and API mode (Application Programming Interface).

Transparent mode

When operating in transparent mode, the modules act as serial line replacement. All UART data received through the DIN pin is queued up for RF transmission. When RF data is received, the data is sent out through the DOUT pin. The module configuration parameters are configured using the AT command mode interface.

RF modules that contain the following firmware versions will support Transparent Mode:

                  20xx (AT coordinator), 22xx (AT router) and 28xx (AT end device)

Application Programming Interface (API) mode

API operation is an alternative to transparent operation. The frame-based API extends the level to which a host application can interact with the networking capabilities of the module. When in API mode, all data entering and leaving the module is contained in frames that define operations or events within the module.

RF modules that contain the following firmware versions will support API operation:

                  21xx (API coordinator), 23xx (API router) and 29xx (API end device)

Grab a pair of Xbees and connect them to your PCXBee Explorer, XBee Explorer USB and XBee Explorer Dongle come handy.

Launch XCTU (If  your PC doesn’t have XCTU, you can get it here). The opening window looks like this

Now scan for the Zigbee modules connected to your PC

On scanning, the port numbers assigned to the detected Zigbee modules get listed. Check the square box to select your device(s) and click Next

A new window opens with the devices listed. Now click Add selected device to add the selected devices and click Next

Set the port parameters and click Finish

The modules get added

One of the modules should be configured as Coordinator and other as Router in API mode. If your modules have different firmware, then you can update by following these steps.

Firmware Updation

Select the module whose firmware should be updated. Click update firmware button on the configuration toolbar

The update firmware dialog box appears, displaying the available and compatible firmware for the module. Select the product family of your module, desired firmware and click Update button

Now the firmware gets updated

Similarly you can configure the other one as router

Click the new module, and wait a few seconds as X-CTU reads the configuration settings of your XBee. You will then be presented with the entire configuration of your XBee.

Profile Settings

You may have to modify the profiles of Xbees a bit. For communication to take place between both the radios, their PAN IDs should match and the DH, DL of one radio should be the address of the other one i.e, the DH, DL of coordinator should be the address of router and vice versa.

Now for Coordinator,

  • Set DIO0 as digital input
  • DIO Change Detect (IC) : For digital input, the DIO Change Detect (IC) parameter configures the pin for digital sampling. Modules can be configured to transmit a data sample immediately whenever a monitored digital IO pin changes state. The IC command is a bitmask that can be used to set which digital IO lines should be monitored for a state change. If one or more bits in IC is set, an IO sample will be transmitted as soon as a state change is observed in one of the monitored digital IO lines. Change detection samples are transmitted to the 64-bit address specified by the Destination Address (DH/DL) parameters.
    Set this parameter to 0x2 to use. Each time the value of the specified DIO changes, the XBee module sends an XBee packet with the new value of the DIO to the XBee Gateway.
  •  I/O Sampling Rate (IR) : I/O Sampling Rate (IR) parameter sets the sampling rate, in milliseconds.
    Periodic sampling allows an XBee/XBee-PRO module to take an IO sample and transmit it to a remote device at a periodic rate. If IR is set to 0, periodic sampling is disabled. For all other values of IR, data will be sampled after the number of milliseconds set by the IR parameter have elapsed and then transmitted to a remote device. Only devices running API firmware can send IO data samples out their UART. Devices running AT firmware will discard received IO data samples. A sleeping end device will transmit periodic IO samples at the IR rate until the ST timer expires and the device can resume sleeping.

After making the changes, write the profile to radio.

Get API frames on console window

Click the “Switch to Consoles” icon – in the upper-right part of the window. This will switch from the configuration tab to the console. If you have two XBees connected to your computer, you can switch between each radio’s console by selecting the device on the left.

First, open a serial connection on each device by clicking the connect icon – . The icon will change, and the border of the console will turn green.

You can see the API frames indicating the status of DIO0 on the console of Router. To see the details of a particular frame, click the corresponding frame name in the frames log.

If 0V is applied to DIO0, DIO0/AD0 digital value (in red box) will indicate Low

If 3.3V is applied to DIO0, DIO0/AD0 digital value (in red box) will indicate High

Read further

Leave a Reply