XBee Arduino Interfacing

Hello friends , I hope you all are fine and having fun with your lives. Today, I am going to share a new project which is XBee Arduino Interfacing. In my previous tutorials in the XBee series, we have had first Introduction to XBee Module and after that we have also discussed How to Interface XBee Module with Computer. Now we are all well aware of XBee Module and can easily do the XBee Arduino Interfacing. We have seen in the previous tutorial that XBee Module works on Serial protocol so we have to use the Serial Pins of Arduino UNO board.

If you want to use any other microcontroller then you can its not a big issue, just see the way how the programming goes and convert it to the language of your microcontroller i.e. PIC Microcontrollers or 8051 Microcontrollers. If you guys have any question, you may contact me or can ask in the comments. so, let's get started with XBee Arduino Interfacing:

Other XBee Projects:

XBee Arduino Interfacing

  • First of all you need to do is XBee Arduino Interfacing.
  • So, in order to do that you have to connect the Pin # 2 and Pin # 3 of Xbee with the Tx and Rx of Arduino and Pin # 1 to 3.3V of Arduino and Pin # 10 to ground of Arduino as shown in the below figure:
Note :
  • Don't solder the XBee pins directly into the Arduino as it may damage the XBee.
  • You can buy the XBee Shield for Arduino.
  • After that attach your XBees with the two Arduino Boards and use the below code:
int b1 = 2;
int b2 = A3;int mode1 = A4;
int mode2 = A5;void setup()
{
Serial.begin(9600);
delay(100);
pinMode(b1,OUTPUT);digitalWrite(b1, LOW);

pinMode(b2,INPUT_PULLUP);
pinMode(mode1,INPUT_PULLUP);
pinMode(mode2,INPUT_PULLUP);

}

void loop()
{
if (Serial.available() > 0)
{
delay(500);
Serial.print("+++"); delay(1000);
Serial.print("rnATDL1"); delay(100);
Serial.print("rnATCN"); delay(100);
Serial.print("A");
}

}
  • Now add this code in one of your Arduino Board and a simple serial receiving code on the second arduino.
  • Now whenever you press the button you will get A on the second arduino board.
  • You can change it with anything you like and on the second side you can do anything by adding a condition.

That's all for today. I hope you have enjoyed this tutorial XBee Arduino Interfacing. I will share more projects on XBee Arduino Interfacing soon. If you are getting any problem you can ask in comments. Thanks. ALLAH HAFIZ :))

Interfacing of XBee with Computer

Hello friends, I hope you all are fine and having fun with your lives. In today's tutorial, I am going to show you the Interfacing of XBee with Computer. In the previous part of this tutorial, I have given the Introduction to XBee Module. Hope you guys have read it and if not then go visit it so that you may have some idea about XBee module.

Now come to the second part about how to interface xbee with computer because its important as if you cant interface the xbee with computer then you cant interface it with any microcontroller and later I will tell you its interfacing with microcontroller. You should also check this XBee Library for Proteus which will help you to simulate XBee module in Proteus.

We will cover arduino with more detail as its the most usable microcontroller these days with XBee. In this tutorial, I will remain to the basics of XBee i.e. we will just simple send data from one xbee to another but in coming tutorials we will have a look on quite difficult projects i.e. plotting of nodes using Rssi value. I have also posted a tutorial on Interfacing of XBee Module with Arduino. If you guys have any question, you may contact me or can ask in the comments. So, let's get started with Interfacing of XBee with Computer:

Interfacing of XBee with Computer

  • XBee works on the TX / RX logic so if we want to interface xbee with computer, we need to use a serial module.
  • There are two type of module, one is usb module available at sparkfun and its costly for the students of Pakistan.
  • So we have created our own module, its based on serial port and works is a similar way as this sparkfun module.
  • This serial module consists of MAX232 and here's its circuit diagram.
  • You just need to do is, the pins going to the uC are now go to the pin # 2 and pin # 3 of XBee.
  • Moreover, +3.3 V to the pin # 1 of XBee and Ground to the pin # 10 of XBee.
  • One more thing , dont forget to common the grounds of XBee and this circuit.

Software to Download

  • There is a software named X-Ctu, is used for Interfacing of XBee with Computer.
  • So first of all, download X-Ctu and install it in your computer.
  • Attach your module's serial port with the computer after placing the XBee in it.
  • Open the software, the first interface of this software is shown in the image below :
  • The White Box in which there is written USB Serial Port (COM 9) indicates the serial ports attached to your computer.
  • In my case it is COM 9 and in your case it will be mostly COM 1.
  • Now Click on the Test / Query button and if everything's going fine then the following window will pop up.
  •  This prompt box tell us a few things about XBee.
  • In case if something's missing and not working properly then you will get something like that :

Configuring the XBee

  • There are a lot of AT commands used for the configuring XBee. I will tell you where to enter these commands but first lets have a view at these commands.
  • Here I am explaining those which we are going to use for the simplest communication.
  • + + +  : This command will initiate the command mode and now our xbee is ready for taking orders and in this mode it wont transmit data.
  • ATMY2 : ATMY is used to set the address of xbee we are using and 2 is the address we have set for our module.
  • ATDL5 : ATDL is used to set the address of the destination module and 5 is the address. In other words now our module 2 only send data to that module which has address 5 .
  • ATWR : This command is used to write these configurations into XBee . If you don't use these commands then once you removed your xbee your values will be erased.
  • ATCN : To terminate the command mode and after that you are ready to send data.
NOTE :
  • ATDL of tranmitter = ATMY of reciever
  • Suppose I have two modules so in order them to communicate I will set the first module as ATMY = 2 and ATDL = 5 and the second module as ATMY = 5 and ATDL = 2. Now both the modules can send data to each other.But if I change the second module's ATDL = 3 then my second module can't send the data to first but still my first module can send data to the second. ( a bit complicated :) )
  • Only this +++ command doesn't require ENTER but in all other press the ENTER tab after entering command.

Where to Enter These Commands

  • Now the most common question is where to enter these commands.
  • Let's come back to X-Ctu,Now click the Terminal tab on top of the software as shown below :
  •  Now Enter the Commands one by one as shown in the image below :
  • In the above figure, I have set my first xbee as ATMY = 1111 and ATDL = 2222.
  • Now remove the first XBee and attach the second XBee , restart the software and do the same steps as for first but now the settings will be as follows :
  • In the above figure, I have set my first xbee as ATMY = 2222 and ATDL = 1111.
  • Check the difference in addressing of both XBees.
  • Your both XBees are configured.

Communication Between XBees

  •  Now attach first XBee to one computer using the module and the second to other computer using another module.
  • Open the software and click the terminal tab.
  • Now whatever you enter in the terminal tab of first xbee , it will be receiving on the terminal tab of second and vice versa.
  • So, that's all about Interfacing of XBee with Computer.

That's all for today and I am a bit tired too while writing this tutorial on Interfacing of XBee with Computer, so I will continue it tomorrow regarding the microcontroller part. One more thing play with the software and do let me know what you find in the comments. Thanks. ALLAH HAFIZ :))

Introduction to XBee Module

In this tutorial, we are gonna hanve an Introduction to XBee Module. XBee is an RF module and these days its using in lots of student projects and I am getting a lot of queries reagarding this module. So first we will cover the introduction of XBee in this post. Soon I will tell you about Interfacing of XBee Module with Computer and also after this discussion we will also discuss Interfacing of XBee Module with Arduino. You can also Interface it with other Microcontrollers like PIC Microcontroller or 8051 Microcontroller.

We will cover arduino with more detail as its quite famous and easily accessible microcontroller these days. In this tutorial I am gonna add just simple interfacing of XBee module with arduino but soon I will post few quite difficult project on XBee like mesh networking. If you guys have any question, you may contact me or can ask in the comments. So, let's get Started with Introduction to XBee Module:

What is XBee ?

  • XBee is a very complicated module used for RF communication. It is used for wireless communication.
  • It is used these days in many projects as it is very easy to use and its advantages are more than any other RF module.
  • You can use XBee for point to point communication also.
  • There are two commonly used versions of XBee, one is XBee series 01 and other is XBee pro.
  • The only difference between the two is in their range.XBee pro has more range to operate than the simple XBee.
  • Its hardly available in Pakistan so if you want to buy XBee Series 01 in Pakistan then use our Contact Form. You will get it within 2 days.
  • Download the datasheet of XBee and must read it as reading datasheet is always beneficial.

How to operate XBee ?

  • To operate XBee, you will need two XBees, one will act as a transmitter and the other will act as a receiver.
  • Now suppose you want to send something from one side to another, now you have to connect one xbee at the transmitter side and the other at the reciever side.
  • Let's take an example of home automation project in which you are using a remote to switch on your light or fan etc.
  • So in that case there must be one XBee in your remote and the second one in your board where the light circuit is placed.
  • So when you press the button of remote, the XBee in remote will send an instruction to the XBee in the board.
  • As soon as the XBee in the board recieve the instruction from XBee in the remote it will on the light.
  • Obviously there will be microcontrollers attached with both the xbees and you need hell of a programming to do this operation but I was just explaining the procedure.
So, that's all about Introduction to XBee Module, I hope you have enjoyed this Introduction to XBee Module and are gonna use it in your projects. Thanks for reading and have fun !!! :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir