Urgent - Need help in Xbee S2 Interfacing with aduino

Hi all :slight_smile: ,
I am doing my UG and I have a small problem in my Project

I need to interface 2 Xbees in my project…

In my Project The System (Computer) is Transmitter end (Initially) and the Robot is in Receiver end… Later Both units acts as both Tx(Transmitter) and Rx(Receiver) to simultaneously send and receive info…

I use 1 arduino and Xbee S2 at Tx end and 1 arduino and Xbee s2 at Rx end.

Task I need to do :

  1. If i send any value (say 1, Using the Serial Monitor) from Tx end , The value must be Sent to the Rx end and say Led must Glow. If 2 is sent then LED must be Off

Issue/Problem I am Facing :

  1. When I Press 1 and send it via Serial monitor of Tx ,the data is not being sent to Rx end.
    Hence the Led is not turning On and off.

2)In the Tx end, when i remove the xbee and open serial monitor and type 1, then i could see the 1 getting printed in Tx serial monitor. But, when I plug in the xbee and open the serial monitor and send the value 1, i am not able to find the value being printed in Tx serial monitor NOR is it getting sent to RX end.

I have configured the XCTU FOR BOTH XBEE’S.

I have attached the Code for both Tx and Rx … Please see it and say if i have made any mistake

1)Transmitter end Code:
https://drive.google.com/file/d/0B6wbE0pypaYqb1BqOXhrT3BieXM/view?usp=sharing

  1. Receiver end Code:
    https://drive.google.com/file/d/0B6wbE0pypaYqblJDS3hzT3FUeG8/view?usp=sharing

If you can help please mail me for any further info…

Mail id : gireesh.star@gmail.com

Tx_end.ino (505 Bytes)

Rx_end.ino (778 Bytes)

) When I Press 1 and send it via Serial monitor of Tx ,the data is not being sent to Rx end.
Hence the Led is not turning On and off

How have you ascertained it is not being sent? It may not be receiving.
Have you tested the Rx code using serial terminal instead of Xbee?

Please supply a circuit drawing and links to the Xbees you are using.

Weedpharma

weedpharma:
How have you ascertained it is not being sent? It may not be receiving.
Have you tested the Rx code using serial terminal instead of Xbee?

Weedpharma

I found this by using a simple thing.. without me sending any user defined values i put 2 values in the void loop to check if data is getting transferred and received.

To do this i used

void loop()
{
Serial.println('1');
Serial.println('2');
}

when i sent this , the values where transferred and received and the Led started to operate (Basically Blinked coz 1-on;2-off and this was repeated )

but , when i sent used defined values (i.e.) when i send 1 or 2 manually via serial monitor , the values are not being sent and here is where the discrepancy arises.The codes of Tx and Rx are being attached in the post

Could you please help me sort this thing out. Thanks in advance !

Not everyone reads the forum on a device that can read the ino file. For example, I use an iPod so cannot open your attached files.

Please put your code in its own window as seen in other posts. This can be done by placing     [code]  and [/code]  around the code or use the </> icon. This makes it easier for others to read.

How to use this forum

Weedpharma

weedpharma:
Not everyone reads the forum on a device that can read the ino file. For example, I use an iPod so cannot open your attached files.

Please put your code in its own window as seen in other posts. This can be done by placing     [code]  and [/code]  around the code or use the </> icon. This makes it easier for others to read.

Weedpharma

Thanks for the tip… I have provided below the codes
The code for Transmitter end

int inputvalue=0;
void setup() 
{
Serial.begin(9600);
}

void loop()
{
if(Serial.available()>0)
inputvalue=Serial.read();

  if(inputvalue=='1')       // If entered I/P is 1,then
  {
  Serial.println('1');      // Print 1 in Serial monitor 
  }

  else if(inputvalue=='2')  // If entered I/P is 2,then
  {
  Serial.println('2');      // Print 2 in Serial monitor
  }

  else                      // If any other value is entered as I/P
  {
    Serial.println('-');    // Print - in Serial monitor
  }
}

The code for Receiver End:

int input_from_Transmitter_value=0;
int led=13;
void setup() 
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}

void loop()
{
if(Serial.available()>0)
inputvalue=Serial.read();

  if(input_from_Transmitter_value=='1')       // If Tx I/P is 1,then
  {
  Serial.println('1');                        // Print 1 in Serial monitor 
  digitalWrite(13, HIGH);                     // LED is ON
  }

  else if(input_from_Transmitter_value=='2')  // If entered I/P is 2,then
  {
  Serial.println('2');                        // Print 2 in Serial monitor
  digitalWrite(13, LOW);                      // LED is OFF
  }

  else                                        // If any other value is entered as I/P
  {
    Serial.println('*');                      // Print * in Serial monitor
  }
}