Not able to get correct data while transferring from one zigbee to another zigbe

Dear All,

Please help me regarding XBee(Series 2) communication as I am very new to this. Any help would be highly appreciated.

I have 4 XBees in which 1 Xbee is acting as Co-coordinator and other 3 XBees are acting as Router.
Lets suppose coordinator XBee is A and other 3 XBee router is B, C and D respectively.
I am trying to send temperature sensor data from 3rd Xbee(Router) D to C then C to B then B to A,
.

Like : D->C->B->A.(Sending Temperature sensor data from D(Router) to A(Coordinator) via Routers C and D )

I am able to get temperature sensor data from D(Router) to B(Router) properly, but not getting proper data from B(Router) to C(Router), its giving some random value. Please help me to get data from 2nd XBee to 3rd XBee.

I am using following code.

Sensor Temperature sender(D(Router)) code.

int tempPin = 1;

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

void loop()
{
int val = analogRead(tempPin);
Serial.println(val);
delay(1000);
}

Receiver Code from XBee D(Router) to XBee C(Router)

void setup() {
// initialize serial communication:
Serial.begin(9600);
}

void loop(){
if(Serial.available() > 0)
{
static char input[16];
static uint8_t i;
char c = Serial.read ();

if ( c != ‘\r’ && i < 15 ) // assuming “Carriage Return” is chosen in the Serial monitor as the line ending character
input[i++] = c;

else
{
// input = ‘\0’;
i = 0;

int dato = atoi(input);
Serial.println(dato);
delay(1300);
}
}
}

===========================================

Receiver Code from XBee C(Router) to XBee B(Router)

void setup() {
// initialize serial communication:
Serial.begin(9600);
}

void loop(){
if(Serial.available() > 0)
{
static char input[16];
static uint8_t i;
char c = Serial.read ();

if ( c != ‘\r’ && i < 15 ) // assuming “Carriage Return” is chosen in the Serial monitor as the line ending character
input[i++] = c;

else
{
// input = ‘\0’;
i = 0;

int dato = atoi(input);
Serial.println(dato);
delay(1300);
}
}
}

=============================================

Receiver Code from XBee B(Router) to XBee A(Co-ordinator)

void setup() {
// initialize serial communication:
Serial.begin(9600);
}

void loop(){
if(Serial.available() > 0)
{
static char input[16];
static uint8_t i;
char c = Serial.read ();

if ( c != ‘\r’ && i < 15 ) // assuming “Carriage Return” is chosen in the Serial monitor as the line ending character
input[i++] = c;

else
{
// input = ‘\0’;
// input = 0;
i = 0;

int dato = atoi(input);
float mv = ( dato/1024.0)5000;
float cel = mv/10;
float farh = (cel
9)/5 + 32;

Serial.print(“TEMPRATURE = “);
Serial.print(cel);
Serial.print(”*C”);
Serial.println();
delay(1000);
}
}
}

Above is code which i using to transfer data from XBee D->C->B->A.
D->C getting proper data from D to C.
But not getting proper data in B from C.
Please help me to resolve this problem

I am trying to send temperature sensor data from 3rd Xbee(Router) D to C then C to B then B to A,

That doesn't make sense. In a coordinator/router configuration, all communication is device to coordinator or coordinator to device.

That some devices can act as relays (routers) should NOT be figured into you communications scheme.

All you should care about is that D needs to send a message to A. How the message gets there is not important. D->B->A is as good as D->A or D->C->A or any other combination of nodes.

I am able to get temperature sensor data from D(Router) to B(Router) properly, but not getting proper data from B(Router) to C(Router), its giving some random value. Please help me to get data from 2nd XBee to 3rd XBee.

You should not know this. D should send a message to A. If B and C are involved, or not, you should not be able to intercept the message on B or C.

How are the XBees configured? You should be using Anrew Rapp's XBee library.

Dear Mr. PaulS,

Thank You very much for replying.

I have configured XBee using XCTU and followed with given instruction in below link.

My purpose is to first send sensor data from D to A via C and B XBees. Once its succeed then i'll try to add sensors with each XBee Module i mean with D, C , B, A and want to access 3 difference sensor data from D to A.

Can you please check above code for 4 XBees and let me know if i am doing anything wrong.
I am not using any library.

I have configured XBee using XCTU and followed with given instruction in below link.

I do not know what values you assigned to SH, SL, DH, DL, PAN ID, etc.

You should NOT be sending data from A to B, and then having B send data to C, and then having C send data to D. A should send data to D. While that data might actually go from A to B to C to D, it should NOT be seen by the Arduinos at B and C. The XBees at B and C should not send the data to the serial port. If A and D are close enough, the data may never actually be seen by B and C.

But, it all depend on whether you have configured the XBees correctly.

Dear Mr. PaulS.

Thanks Again :slight_smile:

Yes. but Temperature Sensor data which i can see in D(Router) is not correct in A(Coordinator) via C and B.

I mean data is not able to transmit properly from One end(D) to other end(A). I can see temperature data in D(Router) is 32C but when i see at other end A(Coordinator), sometimes coming correct 32C but sometimes 0*C or Some other values.

I kept logs in all XBees(D->C->B->A) and can see correct temperature sensor data in First Router D and correct data in Router C but incorrect data in B as well as in A. Means Unable to transfer correct data from one end to other.

Please correct me from previous code which i have paste in earlier chain.

Now to more clarity, I am attaching XBees Configuration Snap shot, Please check and let me know if i am doing anything wrong.

I do not understand why you have configured your XBees that way. D talks to C; C talks to B; B talks to A.

Typically, you'd have D talk to A; C talk to A; B talk to A. If D can't communicate directly with A, but it can talk to C which can talk to A, then D can talk to A, with C relaying. If C can't talk to A, but B can, D can still talk to A, with C relaying to B which relays to A.

A can be configured to talk to any one end device, or it can be configured to broadcast to all end devices. Regardless of how the XBees are configured, Andrew Rapp's XBee library can let Arduino D talk directly to Arduino A, via their respective XBees, with the other XBees relaying as needed.

The library would allow the Arduino wearing the coordinator XBee talk to any specific other Arduino, via its XBee, with others relaying as needed.

What you have now requires that Arduino D talk to XBee D which talks to XBee C which talks to Arduino C which talks to XBee C which talks to XBee B which talks to Arduino B which talks to XBee B which talks to XBee A which talks to Arduino A. Far too many points of failure, when the XBees can figure out the minimum path from Arduino D, via XBee D to Arduino A via XBee A.

I have not looked at your code, and have no plans to do so, until you explain why the communicatios path is so convoluted.

Actually i want to cover long distance via using 3 XBees as router and 1 as Coordinator.

To achieve long distance, I am trying to connect D to C, C to B, B to A which will cover almost 450 Feet distance to send data from one end to other end.

Please let me know if you need any other details.

Thanks in advance

Actually i want to cover long distance via using 3 XBees as router and 1 as Coordinator.

To achieve long distance, I am trying to connect D to C, C to B, B to A which will cover almost 450 Feet distance to send data from one end to other end.

You are still doing it wrong. The XBees, without your "help", will pass data as needed so whatever two devices are supposed to communicate can, if physically possible.