Interface Zigbee with Arduino and Configure Xbee Modules

Zigbee can be easily interfaced with external devices. Zigbee can communicate with external devices such as sensors and communication devices. What if someone wants to communicate with outdoor devices using Arduino? The solution to this problem is Zigbee. There are many wireless modules available in the market, such as RF and RC transmitters and receivers, but their range is low. Zigbee has a higher range than other wireless modules. In this article, you will learn how to interface Zigbee with Arduino Uno R3. After reading this article, you will find answers to the following questions.

What is Zigbee?

The Zigbee module is a wireless communication module that utilizes the IEEE 802.15.4 standard. The IEEE 802.15.4 standard is a low-power radio frequency standard used in many products for wireless communication functionality. The Zigbee module can function as both a transmitter and a receiver, employing serial communication to send and receive data. There are two series of Zigbee modules: Series 1 and Series 2. Series 1 is recommended for beginners as it is easier to use, but it cannot operate in a mesh network.

Zigbee has gained popularity in the Internet of Things (IoT) space due to its ability to connect and control a wide array of smart devices within homes, buildings, and industrial settings, providing automation, energy savings, and improved convenience.

How does Zigbee Technology Work?

Zigbee technology works by creating wireless networks of interconnected devices that communicate using the Zigbee wireless communication protocol. Here’s a simplified explanation of how Zigbee technology operates:

Network Topology: Zigbee networks are typically organized into a mesh topology. In a mesh network, each Zigbee device, or node, can communicate directly with nearby nodes and can also act as a router to relay data for other devices in the network. This mesh structure enhances network reliability and coverage.

Communication: Zigbee devices communicate using low-power radio frequency (RF) signals, typically in the 2.4 GHz or 900 MHz frequency bands. Devices exchange data packets containing information such as sensor readings, control commands, or status updates.

Pan Coordinator: In a Zigbee network, one device serves as the “Pan Coordinator” or “Zigbee Coordinator.” This coordinator initiates and manages the network, ensuring that devices can join and leave the network as needed. It also facilitates communication between devices.

Overall, Zigbee technology enables reliable and efficient wireless communication between devices, making it suitable for various applications, including smart homes, industrial automation, healthcare, and more. Its mesh networking capabilities and low power consumption are key factors contributing to its popularity in the Internet of Things (IoT) and home automation markets.

Applications of Zigbee

Some of the famous applications are:

  • Wireless communication
  • wirelessly controlled robot
  • remote monitoring system
  • Wireless home automation system
  • wireless temperature sensor and many others.

Zigbee alone can’t do anything. You have to interface it with an intelligent device like microcontrollers, Arduino, and computers. These devices will instruct it on what to do or not to do through pre-programmed instructions inside microcontrollers and Arduino Uno R3. These digital devices are not inherently intelligent, but they can be programmed to be intelligent. Let’s continue and learn how to interface Zigbee with Arduino.

Note : Single Zigbee module is useless. We always need a pair of modules so that they can talk to each other. Oh sorry they are not human. I mean they can communicate with each other. I will discuss about it more later.

Xbee Modules Introduction

Digi International developed the XBee modules, a family of wireless communication devices. These modules support various wireless communication protocols, including Zigbee, Wi-Fi, and cellular, and they can communicate over UART (Universal Asynchronous Receiver-Transmitter) interfaces.

Xbee module introduction

These modules utilize Zigbee communication, which is a low-power wireless communication protocol commonly used in home automation, industrial control, and sensor networks. XBee Zigbee modules are capable of forming mesh networks, making them suitable for applications where reliability and long-range communication are essential.

How to Configuring the XBee Modules

The XBee modules, consisting of a transmitter and receiver, require configuration using the X-CTU Software. You can download this software from the following link, provided by DigiKey, which also includes a comprehensive configuration guide. There’s no need for reinventing the wheel, as detailed instructions are readily available in the guide:

Download X-CTU Software and Configuration Guide

Additionally, Sparkfun offers an adaptation of the X-CTU software for newer versions, which you can explore as an alternative.

For a brief overview and configuration steps, you can refer to this Instructables guide.

Please keep in mind the following important points when configuring the XBee modules:

  • Matching Series: Ensure that both XBee modules intended for communication belong to the same series.
  • Hardware Requirements: You will require a breakout board or an Explorer with a USB to UART converter to facilitate this configuration process.
  • PAN ID (Personal Area Network ID): The PAN ID should be identical for the devices intended to communicate with each other. This ensures they recognize each other as part of the same network.
  • Transmitter and Receiver: Designate one module as the transmitter and the other as the receiver. This configuration is determined by the CE (Coordinator Enable) field in the settings.
  • Baud Rate: Take note of the baud rate you set during configuration. You will need this information when configuring Serial communication with XBee in your Arduino code.
  • By following these guidelines and using the provided software and documentation, you can efficiently configure your XBee modules for seamless communication.

Commands to Configure Xbee Modules

Follow the following instructions to configure the Zigbee series 1 module :

Sure, here’s the corrected version:

  1. Connect your Zigbee module to the computer’s serial port using a serial adapter.
  2. Download a virtual terminal program like PuTTY for Windows.
  3. Configure your computer’s serial port settings to a baud rate of 9,600, 8 data bits, no parity, and 1 stop bit.
  4. Enable the “Local Echo” option.
  5. Click “OK” to save the session settings.
  6. Click the “Connect” button in the virtual terminal program.
  7. Once connected to the Zigbee module, give your session a name.
  8. Utilize AT commands to configure your module as needed.

After that, type +++ on the virtual terminal. After a few seconds, it will respond with “OK”. Then, type these commands:

  • ATMY1234
  • ATDL5678
  • ATDH0
  • ATID0
  • ANSWER

Your Zigbee module is ready to use.

Now connect the other Zigbee module to another serial port and repeat the above 10 steps. The other Zigbee module will also respond with commands and follow the instructions.

  • ATMY5678
  • ATDL1234
  • ATDH0
  • ATID0
  • ATWR

Now, both Zigbee modules are ready to talk to each other. If you like this article, please share it with your friends. Your comments are welcome.

Follow this video to see how to configure Xbee modules to communicate with each other:

How to Interface Zigbee with Arduino

After configuring the XBee module, we need to interface it with Arduino. Two Zigbee modules can communicate with each other if both are of the same type. To establish communication between the modules, connect one module to an Arduino and the other module to either a sensor, microcontroller, or computer. You should set the configuration of both modules.

Zigbee interfacing with Arduino
Zigbee interfacing with Arduino

The figure above shows the connection diagram of the module with Arduino. Remember, your module should have regulated 5 volts and 3.3 volts. If you use the Adafruit XBee Adapter, it has both voltage levels. Otherwise, you will need to use a separate power supply. In the above circuit, the TX and RX pins of the Zigbee and Arduino connect to each other. The Arduino will send instructions to the Zigbee, and the Zigbee will respond accordingly. Similarly, the Zigbee receives instructions from other Zigbees to which it has an address. After receiving instructions or data from other Zigbees, it sends the data to the Arduino through the serial pins, as shown in the connection diagram. Similarly, another module can be connected to one more Arduino or computer. The same connection diagram is used for another Zigbee and Arduino pair.

For demonstration, create two circuits, as shown above, and we will use those two to communicate with each other.

Code

To establish serial communication between two XBee modules connected to two separate Arduino boards using UART (Serial) communication, we can use the following example code for both the transmitter and receiver. In this example, we’ll assume that one Arduino is the transmitter, and the other is the receiver.

Xbee Arduino Transmitter Code

void setup() {
  Serial.begin(9600); // Set the baud rate to match your XBee configuration
}

void loop() {
  String message = "Hello, XBee!"; // Message to send
  Serial.println(message); // Send the message over serial
  delay(1000); // Wait for a moment before sending the next message
}

Xbee Arduino Receiver Code

void setup() {
  Serial.begin(9600); // Set the baud rate to match your XBee configuration
}

void loop() {
  if (Serial.available() > 0) {
    String receivedMessage = Serial.readStringUntil('\n'); // Read the incoming message
    Serial.print("Received: ");
    Serial.println(receivedMessage); // Print the received message
  }
}

Here’s what each part of the code does:

  • The baud rate of both Arduino boards is set to communicate at 9600, which should match the configuration of your XBee module. You should ensure that both XBee modules are configured with the same baud rate.
  • The transmitter code sends a message (in this case, “Hello, XBee!”) over the Serial interface every second.
  • The receiver code continuously checks if there is any data available on the Serial interface. When data is received, it reads the message and prints it to the Serial Monitor.

Make sure to power and connect both Arduino boards to their respective XBee modules. The transmitter Arduino (Arduino 1) will send messages, and the receiver Arduino (Arduino 2) will receive these messages over the XBee modules. The received messages will then be displayed in the Serial Monitor of Arduino 2.

Remember to configure your XBee modules correctly, including setting the same baud rate, PAN ID, and other relevant settings to establish communication between them.

Conclusion

In conclusion, Zigbee technology provides a reliable and efficient wireless communication solution for a wide range of applications. It offers the ability to create mesh networks and connect and control smart devices within homes, buildings, and industrial settings. Zigbee’s low-power consumption and mesh networking capabilities make it well-suited for the Internet of Things (IoT) and home automation markets. By interfacing Zigbee with Arduino, it becomes possible to establish communication between devices and create innovative projects that leverage the power of wireless connectivity. Whether it’s for wireless communication, home automation, remote monitoring, or other applications, Zigbee paired with Arduino opens up a world of possibilities for creating intelligent and interconnected systems.

Related content:

17 thoughts on “Interface Zigbee with Arduino and Configure Xbee Modules”

  1. What kind of technical information you need ? And prices of these units vary from country to country. So try to search electronics stores in your country

    Reply
  2. thank for giving this information to all , i have one doubt about zigbee please try to clear it sir , after configuring the zigbees then can we use that zigbee transmitter individually that means with out pc , and where it will show the commands . please give reply as early as possible

    Reply
  3. I am doing a project where zigbee is used. I need to use the zigbee module to broadcast information. Is it possible to broadcast using xbee?

    If u can share some information regarding zigbee broadcast.

    Reply
  4. Thanks for all the information and i am a begginer so please can yoy tell me more specifically that how I configure my both zigbee’s together.

    Reply
  5. I have to connect two zigbees (s1 and s3) with one arduino uno r3. The data received wirelessly by S1 is to be transmitted to S3 using the RX, TX (of Aduino) and DIN, DOUT (of Xigbee). Physical connection of DOUT (of S1) and DIN (of S3) is not working.

    Reply
  6. if I have several Xbees connected to sensors or appliances.
    and I need to control them through a control unit that comprises an arduino and Xbee as a coordinator ….I just have no clue how to write the code???…I used to specify the pin number in case I was connecting, for instance, a LED to the arduino….I don’t know what I have to do now

    Reply
  7. I have two xbees connected with two arduinos….Xbee is communicating…But the problem is that it is not receiving the values i m sending…I have to complete my project by next month…I request anybody’s help for our project’s betterment..

    Reply
  8. I need to transmit a voltage reading (each reading is from 1-5 volts; they will all be different) from three sources to one Arduino 2560 Mega. Do I need four ZigBees or six, and where can I find an example? Thank you.

    Reply

Leave a Comment