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 = (cel9)/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