Interfacing XBee Pro S2C with Arduino

I am trying to interface XBee device with the arduino UNO. I am unable to figure out how to use the XBEE.h library. I tried tried examples but those are not working.
Any ideas how to come up with a code at the transmitter and receiver side ?

This is is the code I have tried at the receiver side. Sender side I have used XCTU software for sending the packet. Used softwareserial library.


'#include<SoftwareSerial.h>

SoftwareSerial softwareserial(4,5); // 4 -> TX, 5 -> RX

#define led 13

uint8_t myaddress[10];
int i = 0;
byte data;
byte discard;

void setup()
{
  Serial.begin(9600);
  softwareserial.begin(9600);
  pinMode(led,OUTPUT);
}

void loop()
{
  int a[15];
  if(softwareserial.available()>14)
  {
    if(softwareserial.read() == 126)
    {
      for(i=0;i<14;i++)
      {
        discard = softwareserial.read();
        Serial.print(discard,HEX);
        Serial.print(" ");       
      }
      if(softwareserial.read()==31)
      {
        data = softwareserial.read();
        Serial.print((char)data);
      }
      if(data == '1')
      {
        digitalWrite(led,HIGH);
      }
      else
      {
        digitalWrite(led,LOW);
      }
      Serial.println(" ");
    }
  }
}`

@karthikeya_sri, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

Hi,

what is the part number of your XBee module? Maybe you have programable version.
Example: XB24CZ7UIT-004 is not programable BUT XB24CZ7UITB003 is programmable.
Pls check this file: Digi XBee Zigbee Datasheet | Digi International
I hope it helps.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.