Software apps and online services
Hand tools and fabrication machines
Zigbee is a popular wireless communication protocol used to transfer a small amount of data with very low power. It is widely used in applications where data has to be shared among many nodes within personal space and with the advent of the Internet of things (IoT). Let’s take that a step further and learn how to establish Zigbee communication using Arduino and NodeMCU boards.Supplies
Hardware Requirements for Establishing Zigbee Communication (Affiliate links are provided)
- 1 x Arduino Nano: https://amzn.to/3gKuoMW
- 1 x NodeMCU : https://amzn.to/3mI64PJ
- 2 x XBee Pro S2C modules: https://amzn.to/3Dud1d2
- 1 x XBee explorer board (to program XBee) : https://amzn.to/3kzivdV
- LEDs: https://amzn.to/3zrbWQN
- Push Button: https://amzn.to/3mPEobw
It is important to clarify at the beginning that XBee is a module, a product, which supports many wireless communication protocols like ZigBee, 802.15.4, 868 MHz modules, etc. Whereas, Zigbee is a standard protocol used to establish wireless networking (ZigBee communication). Often people use these two terms interchangeably but it shouldn’t be done so. To establish Zigbee communication, we need a receiver (endpoint). For this, an XBee module connected with Arduino/NodeMCU will do, and this will communicate wirelessly with another XBee module (coordinator) that sends data, will be connected to another Arduino board.Step 2: Making Xbee compatible with Breadboard
To reduce the cost and to make XBee compatible with a breadboard, solder 4 wires from XBee module pins to header pins and use that to connect to the breadboard as shown in the figure above. [First 3 pins and the last pin of the left side of the board]
- Black wire -> Ground
- Red Wire -> VCC
- White Wire -> Tx
- Yellow Wire -> Rx
For this side of the connection, we’ve used Arduino Nano. Arduino Uno or NodeMCU boards could also be used. The complete circuit diagram to interface XBee with Arduino nano is shown below.
Connect VCC (pin 1) of XBee module to 3.3V of Arduino Nano and GND (pin 10) of XBee to GND of Arduino Nano. These two connections make up for powering the transmitting side XBee module. Connect Dout (pin 2) to D2 of Arduino Nano and Din (pin 3) to D3 of Arduino Nano.Step 4: Interfacing XBee With NodeMCU (Receiving Side)
For this, we’ve used NodeMCU, but it has certain constraints. You can also use Arduino Nano or Arduino Uno for the purpose. We used NodeMCU for showing the compatibility of XBee with different microcontrollers. Also, NodeMCU can be used to send data to the internet in case if we transmit sensor data. The complete circuit diagram to interface XBee with NodeMCU is as shown below.
Connect Gnd(pin10) of XBee to GND of NodeMCU and Connect Vcc (Pin1) of XBee to 3.3V of NodeMCU. The above-mentioned two connections supply the power to the XBee module as well. Then connect Dout (pin2) of XBee to D6 pin of NodeMCU and Din (pin3) of XBee to D7 pin of NodeMCU for receiving data.
As an indication of whether the data is received or not, we’ve used LED. For this, connect LED anode to D2 of NodeMCU and LED cathode to GND through a 220ohm resistor of NodeMCU.Step 5: Downloading and Installing XCTU Software
Basically, the XBee module can be configured as Coordinator, Router, or End device.
To set up, configure and test your XBee devices, you need XCTU software. It’s an easy-to-use, free, multi-platform application for RF XBee modules. Download the XCTU software here and it’ll guide you to install it as well. After that, open the application and connect your XBee using a USB to serial converter or an explorer board. Check the COM port of the Xbee in the device manager.Step 6: Installing Firmware to XBee Modules
Firmware should be installed in both the XBee modules first, for that we’re using the XBee development board.
Step 1: Open XCTU software and click on “Discover boards”.
Step 2: Select the COM port to which the XBee module is connected and click on “Next”.
Step 3: Keep the default settings and click on “Finish”.
Step 4: Now, on the pop-up window, click on “Add Selected Devices”.
Step 5: Now, the XBee module will appear on the left side of the window. Click on it to update the user interface.
Step 6: To update the firmware, click on “Update”, select “802.15.4 TH” in the Function set and select the newest firmware in the Firmware version and click on update. After this, a pop-up window will appear. Click on YES.
Step 7: Enter any 4 digits as PAN ID. PAN ID is a personal area network (PANs) identifier. Each network must be given a unique ID. Make sure that for both the XBee modules, the same PAN ID is entered. This indicates that both the XBee modules are in the same network.
Step 8: Give any 4 digits for the Destination Address. This same number must be entered as Source Address for the other XBee module.
Step 9: Give any 4 digits for the Source Address. This same number must be entered as the Destination Address for the other XBee module.
Step 10: Set one device as “Coordinate ” and the other device as “End Device ”.
Step 11: Now, click on Write in the top bar. After that is successful, the Symbol changes from “E” to “C” (End Device to Coordinator, as we have set. For the other XBee module, it should be “E”).Step 7: Note and COM Port Used
Note: As mentioned in the steps, this must be carried out for both the XBee modules. The only difference between both will be that the Source and Destination Addresses are opposite for the End Device and Coordinator and one must be selected as the End Device and the other as “Coordinator”. In the “Coordinator Enable” drop-down list, make sure both the XBee modules are given the same PAN ID.
COM 5 is for nodeMCU (receiving side) and COM 14 is for Arduino nano (Sending side).Step 8: Complete Code for Both Receiver Side and Transmitter Side
CODE: Receiver side
int led = 2;
int received = 0;
//For communicating with zigbee
//check if the data is received
if (zigbee.available() > 0)
received = zigbee.read();
//if the data is 0, turn off the LED
if (received == '0')
Serial.println("Turning off LED");
//if the data is 1, turn on the LED
else if (received == '1')
Serial.println("Turning on LED");
CODE: Transmitter side
int BUTTON = 5;
boolean toggle = false; //this variable keeps track of alternative click of the button
//When button is pressed (GPIO pulled low) send 1
if (digitalRead(BUTTON) == LOW && toggle)
Serial.println("Turn on LED");
toggle = false;
//When button is pressed second time (GPIO pulled low) send 0
else if (digitalRead(BUTTON) == LOW && !toggle)
Serial.println("Turn off LED");
toggle = true;
This tutorial is aimed at giving proper instructions on establishing your first Zigbee communication using just two XBee modules and different microcontrollers boards.