In this workshop we shall see how to communicate between  two Arduinos Wirelessly using XBEE Radios.

Hardware to keep in handy are :

2 x  Arduino UNO board

2 x  Series 1 XBEE Radio

2 x  Breakout Board  for XBEE

& Connecting Wires ,USB A-B cable,LED , Mini Buzzer.

   

Picture 1

To start with we’ve to configure the Series 1 XBEE Radios.For this we shall make use one of the Arduino boards.The USB –UART portion of the Arduino is used for this purpose.But the Arduino Boot Loader residing under the AtMega328 chip of Arduino will take over command as soon as you power the board.To Bypass the Boot loader there are two methods.

1. You can carefully Remove the AtMega328 controller IC from the Arduino UNO.

removechip2

2. If you are not comfortable removing the chip,there is an easier Hack.

  Just Load an empty Sketch on to the Arduino UNO.

 

empty_sketch

     

Upload this Empty Sketch on to the Arduino UNO board.Now the Boot loader is bypassed & only the USB-UART portion of Arduino is used.

Now you need to wire only 4 connections between Arduino & XBEE.

ARD_XBEE_CONFIG

 

Plug in the first XBEE on to the Breakout Board.

GND of Arduino is connected to pin 10  (GND) of XBEE.

5V of Arduino is connected to pin 1 of XBEE EXPLORER BOARD.

As XBEEs operate on 3.3V you should be extremely careful to ensure that  the power to pin 1 of XBEE is always 3.3V.If you are using a breakout board,you can use 5V ,as the Breakout board has an inbuilt 3.3v regulator.

Note that if you use 3.3v of Arduino to Explorer board of XBEE the code may not be executed.This is because the Explorer has inbuilt 3.3v regulator & if you feed 3.3v as input, the supply to XBEE may slightly drop down to 3v.This may cause malfunction.

If you are using Explorer board for XBEE, always connect  5v Arduino to power up the XBEE EXPLORER.

RX (0)  of Arduino is connected to PIN 3 (DIN) of XBEE.

TX (1)  of Arduino is connected to PIN 2 (DOUT) of XBEE.

Please note This connection is only for Configuration Mode.While on working mode you’ve to interchange RX,TX connections.

We shall make use of a simple Terminal Software  COOLTERM .You can download it here.

Note down the COM port allotted to the Arduino board under Device Manager of your PC

comport

 

Now open the Terminal software COOLTERM.

Click on OPTIONS & under Serial Port make sure that the port allotted (COM5 in our case) is entered &  Baud Rate setting  : 9600  ,Data Bits : 8, Parity : None ,Stop Bits : 1  (9600 8N1).

Under Terminal  option check mark “Local Echo “.This will enable you to see what you type under Terminal window.

 

coolterm1    coolterm2

Click CONNECT  to connect with the COM port where Arduino is connected.

Now at the Left hand side bottom you can see the confirmation that the Terminal is communicating with COM 5 with settings 9600 8 N 1.

Type 3 consecutive +++  symbols.Do not hit Enter key.

Just type & wait to enter the COMMAND MODE.

Once you enter the command mode you’ve to feed the AT commands within 10 seconds.Otherwise it will enter the Transmit mode.Again you’ve to type +++ & wait.

 

 coolterm5

For two XBEES to communicate , both should have same PANID.

This is achieved by typing ATID followed by a 16 bit address,which is entered in HEX  as 4 bytes.Valid range is 0000 to FFFF.

You can enter any 4 digit number between this Range.The other XBEE should also work under the same PANID.

DH is destination High byte address,which we shall leave to default value 0.

DL is Destination Low byte.Set this to  10 .

MY is the short 16bit address used to identify your XBEEs.Valid range is 00 to FF.Set this to 11.

BD is to set the baud rate.Set it as ATBD3 , which represents 9600.

Finally don’t forget to give the WRITE command  ATWR.

Now the configuration of first XBEE is over.

Pull out the XBEE gently from the breakout board after disconnecting USB cable from Arduino.

Place the second XBEE on the Breakout board & connect the USB cable to Arduino.

 

Second XBEE Configuration

Configure the settings as below :

ATID1001    –  PAN ID same as that of first XBEE.

ATDL11       — Destination address Low is 11 which is the MY address of first XBEE.

ATMY10      — Source address .Set this as 10.

ATBD3        — Set Baud Rate as 3 (9600)

ATWR     — Write command to register the changes made.

 

second_xbee   first_config

Now your XBEEs are configured & ready to use.

If you had pulled out the IC from Arduino,replace it carefully so that the notch on IC matches that of the IC base on board.

Connecting XBEEs to Arduino for Wireless Communication

We shall test the setup for two way communication.

We are going to connect a Buzzer  to the 2nd Arduino (we will call it as  B ).The first Arduino (we will call it as A)  will send a character “ K” & it is transmitted through the first XBEE connected to Arduino A.

The Arduino B will look for a capital “K” & switches ON the buzzer for 5 seconds.After that it sends back a character “O” .Arduino A will wait for this character & on receiving ,it lights up an LED for 5 secs.

Both the Transmit & Receive parts of both XBEEs & Arduinos are tested successfully by this setup.

ARD_XBEE_COM

 

 

TRANSMIT Side Code  ARDUINO “A”

———————-

/*This program initializes Serial port & sends a character capital “K” & then waits for a

     character   ‘O’ to switch ON  an LED at pin 13 for a short time */

char readChar;
void setup()
{
pinMode(13,OUTPUT);
Serial.begin(9600);
delay(500);
Serial.print(‘K’);
delay(500);

}

void loop()
{
  if (Serial.available() >0){
   
    readChar=Serial.read();
    if(readChar==’O’){
       digitalWrite(13,HIGH);
    delay(5000);
    digitalWrite(13,LOW);
   
              }
       }
}

———————–

 

RECEIVER side Code  Arduino ‘B’

——————

/* This code waits  for a character capital ‘K’ over Serial port & switches ON a buzzer

     connected to pin 11 for 1.5 secs..Then it sends a character capital ‘O’ over Serial

      to light up an LED at the Sender side Arduino A.  */

int Buzzer=11;
void setup()
{
  pinMode(Buzzer,OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  if(Serial.available()>0){
       if(Serial.read() == ‘K’){
      digitalWrite(Buzzer,HIGH);
      delay(3000);
      digitalWrite(Buzzer,LOW);

     delay(1000);

     Serial.print(‘O"’);
       }
    }
}

—————————

 

CODES

 

Watch this Video on How to configure XBEEs using Arduino Board & setup Wireless Communication :

 

 

Configure XBEEs using Arduino & test for Wireless Communication

 

 

 

 

 

    cooltext753793315       cooltext753790696