How to Interface Zigbee with 8051

Call for Price

How to Interface Zigbee with 8051

SKU: How to Interface Zigbee with 8051 Category:


The 8051 Development board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (89V51RD2), 8051 Development board is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 32-bit Microcontrollers.


ZigBee is a specification for a suite of high level communication protocols using small, low-power digital radios based on an IEEE 802 standard for personal area networks.

Digi ZigBee

The Digi Xbee 802.15.4 modules are the easiest to use, most reliable and cost-effective RF devices we’ve experienced. The 802.15.4 Xbee modules provide two friendly modes of communication – a simple serial method of transmit/receive or a framed mode providing advanced features. These modules can communicate point to point, from one point to a PC, or in a mesh network.

block diagram of zigbee

Fig. 1 Block diagram of Zigbee

Interfacing Zigbee

Fig. 1 shows how to interface the Zigbee with microcontroller. The Xbee modules work at the 2.4 GHz frequency which means smaller board and antenna size. Xbee modules have the ability to transmit Digital, PWM, Analog or Serial RS232 signals wirelessly. To communicate over UART or USART, we just need three basic signals which are namely, RXD (receive), TXD (transmit), GND (common ground). So to interface UART with 8051, we just need the basic signals.

interfacing zigbee to microcontroller

Fig. 1 Interfacing Zigbee to Microcontroller

Interfacing Zigbee with 8051

We now want to interface the ZigBee module with 8051 Development board for accessing the mobiles without wires through UART0. The data communication is done in internet by using the ZigBee module through MAX232 into the SBUF register of 8051 microcontroller (refer serial interfacing with 8051). The serial data from the Zigbeereceiver is taken by using the Serial Interrupt of the controller. +5V and ground is connected to provide power to the module. While TX and RX pin is connected for communication.

Pin Assignment with 8051


UART DB-9 Connector



Serial Port Section






serial port section 8051










Circuit Diagram to Interface Zigbee with 8051

Circuit Diagram to Interface Zigbee with 8051

Source Code

The Interfacing ZigBee module with 8051 program is very simple and straight forward, which communicate a mobile or any other devices with 8051 Development board Through Zigbee module by using UART0. Some delay is occurring when a single data is sent to mobile through UART. C programs are written in Keil software. The baud rate of microcontroller is 9600.

C Program to interface ZigBee with 8051

#include   //Define 8051 Registers


void serial(void); //Serial Communication Register

void DelayMs(unsigned int);    //Delay Function


unsigned int i,j;

unsigned char b[25],d;



//           Main Program


void main()


    EA=1;            //Enable All Interrupt

    ES=1;            //Enable Serial Port Interrupt

    serial();        //Serial Communication

         while(1);    //Loop Forever




//       Serial Communication Register Initialisation


void serial(void)


    TMOD=0X20;       //Timer1, Mode2

    SCON=0X50;       //Serial Mode1, Receive Enable

    TH1=0XFD;        //Baud Rate 9600bps

    TR1=1;           //Timer1 ON





//       Serial Interrupt Function


void serin (void) interrupt 4  //Serial Port Interrupt


    if(RI==1) //Receive Interrupt Gets Enabled

    {            //after Stop Bit get Received

         d=SBUF; //Serial Buffer value moved to a variable



         DelayMs(20); //Delay Function



    SCON=0X50;   //Initialising Receive and Transmit Interrupt




//               Delay Function


void DelayMs(unsigned int k)


    unsigned int i;



To compile the above C code you need the KEIL software. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In Keil, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without 8051 Development board.

The Flash Magic software is used to download the hex file into your microcontroller IC8051 through UART0.

Testing the ZigBee with 8051

Give +5V power supply to 8051 Development board; connect the +5V adapter with ZigBee module which is connected with the 8051 Development board. There are two ZigBee modules are used. One is connected with 8051 Development board UART0; other one is connected with PC.

First connect the serial cable between 8051 Development board PC. Then open the Hyper Terminal screen, select which port you are using and set the default settings. Now the screen should show some text messages.

If the messages are correctly displayed in Hyper Terminal, then only connect the ZigBee modules in 8051 Development board UART0 & PC.

If you are not reading any data from UART0, then you just check the jumper connections & just check the serial cable is working. Otherwise you just check the code with debugging mode in Keil. If you want to see more details about debugging just see the videos in below link.

How to Create & Debug a Project in Keil.

General Information

☞For proper working use the components of exact values as shown in Circuit file. Wherever possible use new components.

☞Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.

☞Use the exact value crystal shown in schematic.

☞More instructions are available in following articles,

User Manual for 8051 Development Kit

Creating & Debugging a Project in KEIL

How to Interface UART with 8051 Development Board

Additional information

Weight 1.000000 kg


There are no reviews yet.

Be the first to review “How to Interface Zigbee with 8051”

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.