Cytron XBee Shield (SHIELD-XBEE) is an Arduino compatible shield which is compatible with Arduino UNO, Arduino Duemilanove, Arduino Mega, Arduino Leonardo and possibly other pin compatible main boards. XBee Shield is compatible with XBee Modules and other XBee Compatible footprint module such as BlueBee, XBee WIFI etc.
* Do take note if you are using Arduino Leonardo, XBee module is not configurable from computer as Arduino Leonardo does not have USB to UART chip. Same goes to Arduino YUN.
So, why do we design a new Xbee shield since we already have other type of Xbee shield?
In facts, the new Cytron Xbee shield offer more features than the existing Xbee shield such as able to select software or hardware UART, stackable and have extra prototyping area. In addition, it is much cheaper than the previous Xbee shield.
- Compatible with XBee (series 1 and series 2), XBee Pro (series 1 and series 2), XBee Wifi, BlueBee
- On board 5V – 3.3V level translator IC.
- Power, Transmit, Receive, Associate and RSSI LED indicators.
- Jumper selectors for software or hardware UART selection and PC-XBee Communication.
- Stackable side headers.
- Prototyping area.
- Arduino Wireless programming capable.
However, there are some limitation with the Cytron Xbee shield compared to SKXBee.
Firstly, you cannot update your Xbee’s firmware with this Cytron Xbee shield. This is because to update the Xbee’s firmware, XBee requires VCC, GND, DIN, DOUT, RTS and DTR and the shield provides only connection of VCC, GND, DIN and DOUT. You will still need SKXBEE in order to update the firmware of XBee. Not to be sad, we seldom need to update firmware of XBee, normally you just need the shield and Arduino 🙂 We can always configure the XBee without the SKXBEE if you are using Cytron Xbee shield.
In addition, Cytron Xbee shield do not provide ISP/ICSP port. However, since we usually program the Arduino board through bootloader (which is much easier), so that is not a big deal.
TX RX pin selector
There are pin selection present in this Cytron Xbee shield. So, what is the use of this things?
Actually, this is the section to choose the serial pins (DIN and DOUT) of Xbee connection. You can pull out the jumper (the tiny black plastic) and plug into whichever pins the XBee’s DIN and DOUT connect to.
Table below list out the modes of jumper selection.
What is PC-XBee communication, hardware and software UART?
This selection allow the XBee to communicates with computer via Arduino on board USB to UART chip. By selecting USB-USB on XBee shield’s TX and RX. This will connect the DIN of XBee to TX of USB to UART chip on Arduino UNO, or Mega (Arduino Leonardo does not have USB to UART chip). This also means the DOUT of XBee is connected to RX of USB to UART chip. Therefore, you can utilize this setting to configure the XBee from computer using X-CTU (preferable) or other terminal program such as Hyperterminal, RealTerm, PuttY, TeraTerm(BlueBee, RFBee.
Let’s see the example to communicate with BlueBee and XBee using PC.
BlueBee with PC
What you need here are a BlueBee, Cytron Xbee shield, Arduino UNO, smartphone with Integrated Bluetooth and PC.
Connect the Arduino UNO to PC via USB cable. Open the HyperTerminal or any other Terminal program. Enter the name of the device and click OK.
Select the COM port you are connecting your Arduino UNO (BlueBee) to your computer and click OK.
Set the Bits per second to 9600 and click OK.
Go to the Setting tab and click on the ASCII Setup.
Tick the “Send line ends with line feeds” and “Echo typed character locally”. Then click OK.
Now, turn on your phone’s Bluetooth and search and connect the BlueBee. Open your Bluetooth Terminal apps. If you are using a Window phone, you can download the apps named “BT Terminal” by DevFor8.com from the window apps store. If you are using an Android phone, you can download the apps named “BlueTerm” or any compatible apps.
On your phone, type any character and send. Your BlueBee should receive the character and send it to your PC. The HyperTerminal should shows the character you typed. Wireless communication from your phone to BlueBee and further to computer.
XBee with PC
To get wireless communication between XBees, you need two pieces of XBee. (You will still need two pieces of XBee because XBee communicate to XBee wirelessly).
To allow the communication between two XBees, you will need to set up their source address and destination address first. I will show you how to configure the XBee using the new version of XCTU software (Skip this part if you already knew it). The new version of XCTU is easier to setup and more user friendly compared to the older version.
Open the new version of XCTU software. Click “Discover devices” to add XBee to the list.
Select the COM port you connect your Arduino (XBee) to your PC and click Next. As shown in my example, the COM for Arduino UNO is COM145.
The setting should be as shown in diagram below. Click finish and wait for the software to discover the XBee.
Once the XBee is discovered, select it and click “Add selected devices”. Wait for it to read the settings of the XBee. It might takes awhile.
Once it is done loading, set the destination(DL) and source(MY) address as shown below. This is for XBee A.
Click the pencil symbol as shown in the diagram below to write the new values into XBee A.
Repeat the same steps to configure the second XBee (I call it XBee B). However, please swap the destination and source address. 2222 for DL and 1111 for MY. (If you are using your own address while setting the address, just swap the value when you configure XBee B.)
After completed the settings for both XBees (XBee A and B), the XBees can communicate wirelessly.
Connect both of the XBee to your PC, you can either use a SKXBee for one of the XBee and another uses Cytron XBee Shield, or use two XBee shield. Then search and select them to add them in the list as shown previously.
Now, click the Terminal button.
What actually just happened is, after you typed the characters in the first terminal, PC send the data to XBee A via USB cable to Arduino UNO, and on board USB to UART chip further to it on XBee shield. The XBee A receives the data and send it another XBee with destination address (1111) out to the air wirelessly. XBee B with source address 1111 extracts the data from the air wirelessly and sends it back to PC (XCTU’s terminal). That is why you can see the red “Hello!” on the second terminal.
If you don’t believe it, you can try it on two different PC, a PC for each XBee. The same thing will happen!
P/S: I just want to remind again that you cannot communicate either XBee or Bluebee with PC (through HyperTerminal or XCTU) if your jumper is at either D1D0, D3D2, D9D8 or D11D10. You can try it out.
P/S: This can only happen on Arduino that have USB to UART chip which is Arduino UNO, Mega. Arduino Leonardo cannot provide this.
By plug in the jumpers onto D1 and D0, your BlueBee or XBee will be communicating with your Arduino’s hardware UART pins. By default, most of the Arduino main board including Arduino UNO, have their serial pins at D0(RX) and D1(TX). So, What is the difference between communicating with PC and communicating with Arduino? When your BlueBee or XBee is communicating with Arduino, the arduino can send and receive data wirelessly.
I will show you a simple example to turn on a LED wirelessly, using a phone (BlueBee) and PC (XBee).
[code lang=”cpp” wraplines=”true”]
int ledPin = 13;
Serial.begin(9600); // begin the serial communication
pinMode(ledPin, OUTPUT); // set pin 13 as output
if (Serial.available() > 0) // when you receive a data
char value = Serial.read(); // put the value received into a character variable
if (value == ‘1’) // if the value received is 1
digitalWrite(ledPin, HIGH); // turn on LED
Serial.println("Received,LED ON"); // reply back to the transmitter
digitalWrite(ledPin, LOW); //turn off LED
Serial.println("Received,LED OFF"); // reply back to the transmitter
Stack the Cytron Xbee shield (with XBee or BlueBee) to your Arduino board.
For BlueBee, create connection from your phone Bluetooth with the BlueBee. Open the BT terminal (windows phone) or BlueTerm (Android), and connect your phone to the BlueBee. After they are connected, simply type a in a character and send, you should be receiving the reply from the BlueBee saying “Received, LED OFF”. If you type “1” and send, the LED will turn on and you will get a message saying “Received, LED ON”.
For XBee, (assuming you had set the destination and source address configured shown earlier in this article) connect your the other XBee to your computer. Open XCTU software. Search and add the device to the list. (All the steps as shown previously). Go to the Terminal tab and turn on the Serial connection. Type in any character, you should be receiving the reply from the XBee saying “Received, LED OFF”. If you type “1”, the LED will turn on and you will get a message saying “Received, LED ON”.
So, what about software serial? What is the difference between hardware serial and software serial? As mention earlier, The Arduino has built-in support for serial communication on pin 0 and pin 1. However, the software serial allows serial communication on other digital pins of Arduino instead of pin 0 and pin 1. You might ask why don’t we just reserved pin 0 and pin 1 all the time for communication and then we do not need to learn about software serial communication.
Unfortunately, there is time when we need to use software serial. For example, for Arduino Leonardo, the TX RX pins is at pin 1 and pin 0 respectively. However, the interrupt 2 and interrupt 3 is at pin 0 and pin 1 too. In that case, if you need to use interrupt 2 and interrupt 3 together with UART communication, you can use other pins as the serial communication pins, thus software serial.
Besides, by using software serial, we can have multiple software serial implemented in a single chip. We can communicate with more than one UART device. However, there is a limitation on the software serial. If you are using multiple software serial, only one of it can receive or send data at a time. They have to take turns to send or receive data. (However, one hardware serial and one software serial can be use at the same time)
So, let’s try to turn on a LED which is on pin 0 wirelessly. (You cannot do this using hardware serial).
Now, modify your program to as shown below.
[sourcecode language=”cpp” wraplines=”true”]
SoftwareSerial mySerial(2,3); // RX, TX
int ledPin = 0;
mySerial.begin(9600); // begin the software serial
pinMode(ledPin, OUTPUT); // setting pin 0 as output
if (mySerial.available() > 0) // when a data was received
char value = mySerial.read(); // put the data received in to character variable
if (value == ‘1’) // if the character is "1"
digitalWrite(ledPin, HIGH); // turn on LED
mySerial.println("Received,LED ON"); // reply to transmitter
digitalWrite(ledPin, LOW); // turn off LED
mySerial.println("Received,LED OFF"); // reply to transmitter
You will get the same result as using Hardware serial, but now your LED is at pin 0, which you cannot do it using Hardware serial.
Using multiple serial
One more advantage of Cytron Xbee shield, you can stack the shield on top of Arduino. First level connecting D1D0, second level connecting D3D2, third level connecting D9D8, fourth level connecting D11D10.
So what does this means? This means that you can communicate with four different devices serially with the controller. However, as mention earlier just now, only one software serial can send or receive data at a time.
By this, we can use our Bluetooth devices to communicate with XBee radio devices indirectly. Why indirectly? Because what actually happen is, your can use your Bluetooth devices such as mobile phone to communicate with BlueBee, and the BlueBee communicate with Arduino through the hardware serial TX RX pins. The microcontroller receive and transmit the same data to the software serial TX RX pins, which are connected to other XBee radio. This XBee can further communicate with the other XBee wirelessly which match the source and destination address. Finally the communication between two different device is formed.
If you have any inquiry, please do discuss in our technical forum because we seldom check the comment section in tutorial site.