In the previous tutorial, Zigbee technology and its application in building Wireless Sensor Networks was discussed. In this tutorial, learn to perform simple Client to Client Communication over Zigbee Protocol. There will be two Xbee modules taken and will be configured to communicate data with each other over the air.
The Xbee devices communicate with each other wirelessly over the air. They do not have any microcontroller or processor in themselves, so they cannot manage the received or sent data. They can simply transfer the information what they receive. But they can be interfaced with other microcontrollers and processors like Arduino, Raspberry Pi or PC via serial Interface.
So, basically, Xbee modules are capable of two types of communication – wireless communication and serial communication. The wireless communication takes place between Xbee devices so that the devices act as radio frequency (RF) devices. For data to transmit and receive from one Xbee module to another, both devices should be on same network. The data between two devices is transmitted wirelessly. By serial communication (UART), the Xbee modules can communicate with microcontrollers and processors.
Zigbee Communication between Xbee modules
A microcontroller, processor or PC can send data through the serial interface to the Xbee module (transmitter) and the Xbee module wirelessly transmits the data to other Xbee module (Receiver). The receiver Xbee module transmits the data through the serial interface to controller, processor or PC to which it is interfaced. The controller interfaced to the Xbee module processes the information received by the Xbee devices. This way, controllers can monitor and control remote devices by sending messages through the local Xbee modules.
The Xbee modules communicate with each other in two modes – Transparent mode and API (Application Peripheral Interface) mode. This project is based on Transparent mode. In transparent mode, Xbee modules act as serial line replacement. All data received through serial input is immediately transmitted over the air. When other Xbee module receives data wirelessly, it sends that exactly as it receives through the serial interface and vice versa. Contrary to this, in the API mode, the data is transmitted with some additional information.
In this project, two Xbee modules will be interfaced with two PCs and they will be configured to communicate data with each other in transparent mode. The XCTU software can be used on the PCs to send and receive data between the PCs and the Xbee modules.
Component Required –
Component Quantity Specification
Xbee modules 2 Series 2
Xbee shield 2 Xbee Adapter board
Arduino 2 UNO or mega
Logic level converter 2 TTL to CMOS level converter (bidirectional)
XCTU (software) – 6.3.1 or later
Jumper wires – –
Software Required –
• XCTU (6.3.1 or later) or XCTU legacy
Block Diagram –
Circuit Connections –
The Xbee Series 2 modules will be used in this project. The X-Bee module is a 20-pin module with the following pin configuration –
Pin Number Name Direction Description
1 VCC – Power Supply
2 DOUT Output UART Data Out
3 DIN/CONFIG Input UART Data In
4 DO8 Output Digital Output 8
5 RESET Input Module Reset
6 PWM0/RSSI Output PWM Output 0 /RX Signal Strength Indicator
7 PWM1 Output PWM Output 1
8 Reserved – Do Not Connect
9 DTR/SLEEP_RQ/DI8 Input Sleep Control Line or Data Input 8
10 GND – Ground
11 AD4/DIO4 Either Analog Input 4/ Digital I/O 4
12 CTS/DIO7 Either Clear To Send Flow Control/ Digital I/O 7
13 ON/Sleep Output Module Status Indicator
14 VREF Input Voltage Reference for Analog/Digital Inputs
15 Associate/AD5/DIO5 Either Associated Indicator/ Analog Input 5/ Digital I/O 5
16 RTS/AD6/DIO6 Either Request to Send Flow Control/ Analog Input 6/ Digital I/O 6
17 AD3/DIO3 Either Analog Input 3/ Digital I/O 3
18 AD2/DIO2 Either Analog Input 2/ Digital I/O 2
19 AD1/DIO1 Either Analog Input 1/ Digital I/O 1
20 AD0/DIO0 Either Analog Input 0/ Digital I/O 0
For connecting the module with PC, first place the Xbee to the Xbee Shield and connect module with an Arduino. The Arduino UNO or Arduino Mega acts as a USB converter for Xbee modules. Before using Arduino UNO with Xbee modules, a bare minimum sketch must be uploaded on it or the Atmega microcontroller must be removed from the board. The Xbee module can be provided power by an external power supply or from the Arduino. The Xbee module and the Arduino board must communicate serially. The Xbee module should be connected to the Arduino according to the following table –
Arduino Xbee series 2
TX TX
RX RX
5V 3V3
GND GND
Now Arduino can be connected with the PC using a USB cable.
After connecting the module to the computer, perform the following steps –
1) Open the XCTU software. Make sure, the software is in configuration working mode.
2) Click on “Discover Radio Modules”.
3) Click on the desired COM port on which module is connected.
4) Click next, in the ‘Set port parameters’ window, change the values according to the requirements and click finish.
5) As XCTU locates radio modules after full scan, select the radio modules by clicking on ‘Add selected devices’. Now, the selected radio modules should show in radio module window.
In order to transmit or receive data on Xbee modules, they need to be properly configured on the same network. According to the Zigbee protocol one device needs to be in coordinator mode and the rest can be router or end devices. In this case, one device is coordinator and other is router.
Now, restore the default setting of all Xbee modules with the ‘Load default firmware setting’ button at the top of Radio configuration section and use XCTU to configure the following parameter –
Parameter Xbee A Xbee B Use
PAN ID 1234 1234 Must be same for all Xbee in the same network
NI Coordinator Router Node Identifier- it can be unique or same depends on the function they are working
JV – Enable[1] Join channel verification- If enable means verifying the coordinator exists on the same network to join the network
CE Enabled[1] – Coordinator Enable- Set the device as coordinator
DH 0 0 Destination address HIGH bits- define the destination address (high part) to transmit the data to & to listen for the data.
DL FFFF FFFF or 0 Destination address LOW bits- define the destination address (low part) to transmit the data to and to listen for the data. FFFF means the data is transmitted in a broadcast way.
SP 1F4 1F4 Sleeping time- defines the duration of time spent sleeping. 1F4 (hexadecimal) = 500 (decimal) * 10 ms = 5 seconds
AP Transparent mode [0] Transparent mode [0] Application mode- we are trying to establish communication between two Xbee in transparent mode.
Keep the rest of the values as default and write the settings of all Xbee modules with the ‘write radio modules’ button at the top of radio configuration. Once the configuration is completed, click on the discover radio modules on same network button of any of the radio module. Now, the radio modules for the same network can be found. After configuring both modules, the data can be sent and received among them.
The following precautions must be taken care while interfacing the Xbee modules –
1) Xbee modules operate on 3V3 with current of 40 mA to transmit and receive the data. Don’t provide 5V from Arduino.
2) Xbee modules have 3V3 tolerant signal level. For providing communication between arduino and Xbee, use CMOS-to-TTL logic level converter (Bidirectional).
3) Sometimes when trying to discover Xbee, there may occur an error like – ‘Could not find any device in port COM6 >For input string: “ERROR” or error initializing device parameter = connection timeout or could not find device parameter’ then the error may be because of the incorrect baud rate.
For this, connect the modem using FTDI cable to the PC, open XCTU, select the COM port and multiple baud rates like 9600, 115200, 57600 then search for the radio module and possibly there the radio module can be found. But if not found, then open XCTU legacy (old version), select the possible baud rate and in the modem configuration window select the correct modem firmware/ function set, then enable ‘always update firmware’ and select write. After that, when the info box (action required) appears, then reset the Xbee by connecting RST to GND or simply unseat the Xbee and again place on seat. Now info box will disappear. It will then re-flash the radio modules automatically.
4) If there comes the error of baud rate difference then the error can be that the PC and radio module are not working on same baud rate. In such case, try to change the PC and flash the firmware with another PC. The Xbee module can also be recovered this way.
5) Issue the commands properly when working in AT mode.
How the Circuit Works –
The XCTU console mode is used to provide communication between the two Xbee modules in serial communication mode. In XCTU, click the open serial connection button to start the communication. The background changes to green to indicate that the connection is open. Use the console log section to type the messages on one Xbee. It can be seen that the message is received by other Xbee which is connected in the same network.
The serial console transmits the exact same message to the Xbee modules what it received from them. This way, messages can be communicated between two PCs over Zigbee protocol using Xbee modules and XCTU software.
In the next tutorial, learn to setup IoT communication between two Arduino based devices using Xbee modules.
\
Project Source Code
Project Source Code
### //Program to /* @Application: Arduino_sends_data_to_xbee @Hardware used: Arduino UNO Xbee sereies 2 module External Power supply @Connection: Xbee VCC- External power supply 3v3 Xbee GND- EXternal power supply GND Xbee TX- Arduino digital pin 11 Xbee RX- Arduino digital pin 10 External power supply GND - Arduino GND @Brief Introduction: Transmitter side: The arduino serial sends the data to Xbee serial. And if xbee receives some data wirelessly from other xbee then it sends to arduino serial For more detail, Refer our Article! */ //include software serial to communicate with Xbee #include<SoftwareSerial.h> //Create an instance for software serial SoftwareSerial xbee(10,11); //Digital pin 10- Xbee RX, Digital pin 11- Xbee TX void setup() { // Initialize serial communicate, //we configured our XBEE devices for 9600 bps. Serial.begin(9600); xbee.begin(9600); } void loop() { //Check whether serial has something to send or not if(Serial.available()>0) { //If serial has data to write, then pass that data to Xbee xbee.write(Serial.read()); } //Check whether Xbee received something or not on software serial port. else if (xbee.available()>0) { //If it received something, pass it to Arduino serial Serial.write(xbee.read()); } } ###
Circuit Diagrams
Project Datasheet
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.