HC-05 BLUETOOTH TO BLUETOOTH COMMUNICATION(MASTER-SLAVE USING 8051 WITH PROTEUS SIMULATION)

  We can easily communicate between two 8051 microcontrollers using hc-05 bluetooth module and Uart of 89c51. This simulation will help you to learn how serial communication takes place in Microcontrollers. The simulation is working perfectly and i have made a circuit based on this simulation so you all can directly refer to the circuit and apply. You all need to be familiar with PROTEUS and i have uploaded the proteus files and the code.

LEARN MORE in DATASHEET: Hc-05 Datasheet

FIRST OF ALL THERE IS NO HC-05 BLUETOOTH LIBRARY IN PROTEUS SO WE HAVE TO ADD IT MANUALY……ITS VERY EASY JUST GO TO THE LINK GIVEN BELOW AND FOLLOW SOME BASIC STEPS…………………………………..

LINK :::::[HC-05 BLUETOOTH MODULE LIBRARY ADD]

AFTER ADDING THE BLUETOOTH MODULES LIBRARY MAKE SURE TO INSTALL VIRTUAL COM PORT IT IS GIVEN IN THE SAME PAGE OF ABOVE LINK OR YOU CAN WATCH BELOW VIDEO………………………THIS HELPS YOU TO COMMUNICATE OR PAIR BETWEEN TWO BLUETOOTH MODULES.

VIDEO FOR COMMUNICATION BETWEEN TWO BLUETOOTH MODULES……..

CREDITS: THEENGINEERINGPROJECTS.COM

LETS BEGIN…………………………………………………………………

NOTE: WE ARE TRANSMITTING A SQUARE WAVE FROM ONE MICROCONTROLLER TO OTHER.

STEP1:

Connect the circuit as shown in the below diagram. While creating a new project use firmware project and select at89c51.

 

THE LEFT 89C51 IS THE TRANSMITTER

RIGHT 89C51 IS THE RECEIVER

HC-05 Bluetooth CIRCUIT DIAGRAM
HC-05 Bluetooth CIRCUIT DIAGRAM

Please make sure that the connection of txd pin of transmiiter 89c51 is connected to rxd of hc-

05(transmitter) and rxd pin of 89c51 receiver is connected to txd pin of hc-05

NO NEED TO SUPPLY HC-05 VCC GND PINS THEY ARE POWERED INTERNALLY.

 CRYSTAL FREQ=11.0592MHZ

STEP 2

Once the connections is completed it is required to add the code to both the microcontrollers.

I am giving you the code just right click to 89c51 microcontroller and in edit properties program files select the hex files…

Please select appropriate hex files make sure that you do not interchange the code…like of transmitter to receivers or vice versa.

TRANSMITTER CODE


#include <reg51.h>
void delay(void);
sbit pin=P1^0;
void scom(void);
void main(void)
{
scom();
delay();
while(1)
{
P1=0XFF;
SBUF=P1;
while(TI==0){}

TI=0;
P1=0X00;
SBUF=P1;
while(TI==0);
TI=0;
}
}
void delay()
{
TL0=0xE9;
TH0=0xFF;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

void scom()
{
TMOD =0x20;
TH1=0XFD;
SCON=0x50;
TR1=1;
IE=0x90;
EA=1;
}

RECEIVER CODE

#include <reg52.h>

char recievedcode;

void scominit()
{

TMOD =0x20;
TH1=0XFD;
SCON=0x50;
TR1=1;
IE=0x90;
EA=1;
}

char Read_Char()
{
while(RI==0);
RI=0;
return(SBUF);
}

void CommandReceived() interrupt 4
{

recievedcode=Read_Char();

}

void Delay()
{
TL0=0xE9;
TH0=0xFF;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

void main()
{
scominit();

while(1)
{
SBUF=recievedcode ;
P1=SBUF;

// Delay();
}

}

HEX FILES:

TRANSMITTER:8051SQ.HEX

RECEIVER:REC.HEX

STEP 3: After successfully adding all the code into microcontrollers you need to simulate.

go to debug from top bar and select run simulation.

You will see oscilloscope showing all the waveforms……..the input square wave and the output square wave….both on port pin 1.0

IT WILL LOOK LIKE THIS

OUTPUT HC-05 TO HC-05 Bluetooth
OUTPUT HC-05 TO HC-05 Bluetooth

IF YOU HAVE ANY QUESTION FEEL FREE TO COMMENT…

I WILL BE UPDATING THIS PAGE WHENEVER I GET SOME TIME SO YOU WILL GET IT MORE CLEAR…………………………………

Learn More

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here