Setting up X-bee network in API mode

I am trying to implement the same thing wireless.
The Light sensors will communicate to the Light control arduino node through xbee radios (S2). I have light sensor to communicate with the control node. I established communication between them in AT mode. But I want to establish the communication in API mode.
I am a newbie to zigbee communication. I want to learn to communicate these xbee in API mode.I am using X-CTU version 6.1.1 to configure.Any help would be appreciated.
I have configured them as follows

Radio 1.
XB24-ZB Ver:21A7
ZIGBEE COORDINATOR API
Pan ID: 10
SH:13A200
SL:4086DE9E
DH:13A200
DL:40B3EE21

Radio 2.
XB24-ZB Ver:29A7
ZIGBEE ROUTER API
PAN ID :10
SH:13A200
SL:40B3EE21
DH:13A200
DL:4086DE9E

I checked for the network topology in X-CTU and found both nodes are connected one as co-ordinator and other as end device.Pls find the attached image for the topology.
Now how to establish communication between them?. I tried to communicate as in AT mode by typing in one console and receiving the same in another radios console. But API mode is asking for frames. And I dont know how to define frames. I have attached the image of the screen. Can someone help on how to proceed from here?

All is explained in the product manual.
Andrew Rapp's library makes it easy.
Be sure to set AP=2.

Hi,
I tried reading manual but couldn't undertand API frame setting. I feel its too heavy for a newbie.
So I am going with digi mesh network which I am familiar with. But I am not able to load digimesh firmware in S2 series module.
The DM firmware option doesn't show up in X-CTU when I am configuring S2 series radio but is available when I use S1 series radio.
Is it not possible to load DM firmware in S2 radios?

viz_90:
Is it not possible to load DM firmware in S2 radios?

I was under the impression that it was, but reviewing Digi's web site I think that I was mistaken. Like you say, the S1 modules will support DM.

Don't give up on the S2 modules. Get Andrew Rapp's library. It is rather extensive so it takes a bit to get the hang of the object model. But it's really designed well and it works great. Have a look at the examples and the doxygen documentation that comes with the library. Here is code for a demonstration I gave recently. Not necessarily the best, I cobbled it together in a hurry from other projects, so FWIW.

Hi Jack,
I read the manual again. I felt I can understand a little more now. Here are some of my doubts.

I saw a video in which network Co-ordinator is set in API mode and router in AT mode?.Can we have different modes in the same network?

I read that there are different AT command frames to carry out different functions like source routing,remote AT commands etc. Now My question is how to set different command frames?. Should I program in arduino to send those corresponding AT command frames serially through xbee to other xbee I wish to communicate?
eg:If i want a router to send a data, Should I create a command frame and send it serially from co-ordinator through zigbee so that router receives it and responds accordingly?
If so ,can u show me a small program example to request a data from a router?

since I am using more than one light sensor, I want to address a particular sensor from co-ordinator and ask it to transmit the data only when I need it. Is it possible to do using AT command? If so, how to do it?

You're teetering on "do my project for me" territory here, but we can at least help...

First, if you haven't seen it already, you might want to pick up a copy of Building Wireless Sensor Networks by Robert Faludi. It has a few examples of using one end in API mode and the other not, and does a little more layman type explanations of the frames in API mode.

To answer your main question, yes, you can have one end in API mode and the other in AT mode. I'm doing just that now. Basically, any end in API mode is usually going to be connected to a computer of some kind to decode and create frames.

One component of frames is the XBee address of the source of the frame, so that's one way to tell which sensor is which (assuming each sensor is on a different Xbee, anyway).

You router Xbee can have sensors connected and simply be setup in XCTU for the rate to poll the sensors and send the data. Your coordinator in API mode will receive these as "frames" automatically that you can decode using your arduino. There are examples of doing exactly this using one light sensor in the book referenced above, though they are very simple (and are using only one light sensor and ignoring the address the data came from...shouldn't be terribly hard to figure out how to decode that address out, too, however).

Hope that gets you moving in the right direction...

--Donnie

viz_90:
I saw a video in which network Co-ordinator is set in API mode and router in AT mode?.Can we have different modes in the same network?

It's a common misconception, but indeed, as @djb_rh said, the interfaces API/AT as well as baud rates can be mixed or matched in any way. The key point to understand is that these only affect the local interface to the module, and the RF link between modules is always the same and is unaffected by choice of mode (API or AT) or baud rate.

I read that there are different AT command frames to carry out different functions like source routing,remote AT commands etc. Now My question is how to set different command frames?. Should I program in arduino to send those corresponding AT command frames serially through xbee to other xbee I wish to communicate?
eg:If i want a router to send a data, Should I create a command frame and send it serially from co-ordinator through zigbee so that router receives it and responds accordingly?

Source routing can be a bit hairy, I would recommend avoiding it until you have more experience and are sure that you need it. Indeed there is a frame to cause a remote module to execute AT commands, frame type 0x17.

If so ,can u show me a small program example to request a data from a router?

I don't happen to have one of those.

since I am using more than one light sensor, I want to address a particular sensor from co-ordinator and ask it to transmit the data only when I need it. Is it possible to do using AT command? If so, how to do it?

There is a command (1S) to force a sample to be taken, I suppose this could be sent via frame type 0x17. I don't operate my nodes this way, however, so I haven't tried it.

At the risk of repeating myself, the best favor you could do yourself is to learn to use Andrew Rapp's library. Otherwise you will be reinventing several large wheels. Of course maybe you want to roll your own API frames and also interpret them on the other end as an exercise, which is fine, but prepare to spend much more time on that than on the actual problem you're trying to solve.

In any event, API mode is the only way to go in order to really take advantage of the XBees' capabilities. AT mode is only good for trivial and non-critical applications, and is terribly cumbersome to use in any advanced scenario.

Hi,
I set up coordinator and end device in API mode. I am able to communicate from coordinator to router using transmit request and I got an acknowledgement from router too.
But I am not able to transmit from end device the same way.
I have attached the coordinator and end device configuration images, their console images and their Frames for your reference.
Can you help me to debug this?

Pls find attached the frame settings of coordinator and end device with this post

Hi,
I set up a 3 node network in digimesh.
I set up one as a router and other two as end device.
I connected all the three radios to the computer through usb explorer and from the X-CTU console I found they are all able to communicate bidirectionally.
But when I connected these three x-bee radios to arduino using x-bee sheild,the communication is not happening.
I loaded the following program in arduino with xbee radio configured as router which sends 'H' and 'L' alternatively.

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.print('H');
  delay(1000);
  Serial.print('L');
  delay(1000);
}

This is the program at the other two receiver ends of the arduino.

byte byteRead;
void setup() {                
// Turn the Serial Protocol ON

  Serial.begin(9600);
}

void loop() {
   /*  check if data has been sent from the computer: */
  if (Serial.available()) {
    /* read the most recent byte */
    byteRead = Serial.read();
    Serial.print("msg received");
    Serial.write(byteRead);
  }
}

When I connected other two receivers using USB explorer and checked their console in X-CTU. I found that they are receiving the 'H' and 'L' properly.So I guess there is some problem only when I interface with arduino. Can someone help me in this?

Hi,
I think I found the issue, I named the router which transmits 'H' and 'L' as '1' and other two receivers as '2' and '3' .
Its because since there is a command in the two receivers '2' and '3'

Serial.print(''msg received");

the second receiver instead of getting the data from transmitter,it receives the 3rd receiver output msg received serially and it outputs msg received serially into the serial monitor.

When i had only one receiver and one transmitter, the communication was happening smoothly. So i guess the issue is with interference between two receivers.

so I changed the code in the sender to send with an identification mark say '1' and wrote the program in the receiver so that it displays only data which it got with identification mark '1'.
here is the program at the sender

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.print('1');
  Serial.print('H');
  delay(1000);
  Serial.print('1');
  Serial.print('L');
  delay(1000);
}

the code at the receiver

byte byteRead;
void setup() {                
// Turn the Serial Protocol ON

  Serial.begin(9600);
}

void loop() {
   /*  check if data has been sent from the computer: */
  if (Serial.available()==2) {
    /* read the most recent byte */
    if(Serial.read()==1)
    {
    byteRead = Serial.read();
    Serial.write(byteRead);
  }
  }
}

But i didnt get any output from the receiver serial monitor. Can someone help me with the code to selectively display only data from particular node say '1'
Also I want the node '1 ' to receive data from other two nodes and display them in serial monitor also.Any help on this front will be appreciated.