You are on page 1of 9

Interfacing

Bluetooth with
8051
Microcontrollers
www.pantechsolu
tions.net
WHAT IS BLUETOOTH?

• Bluetooth is a proprietary open wireless protocol for exchanging data


over short distances (using short length radio waves) from fixed and
mobile devices, creating personal area networks (PANs). It was
originally conceived as a wireless alternative to RS-232 data cables.
• BlueTooth is a promising standard for short range wireless
communication. BlueTooth uses the same frequency as WaveLan but
with much less effect but anyhow some claim that a WaveLan can not
co-exist with a fully equiped BlueTooth environment.
• Bluetooth is a wireless technology for transmission of voice and data
over a short distance.
• RXD and TXD pin of bluetooth Evaluation kit connected with the
controller through serial port

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt


Bluetooth interface board

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt


Bluetooth interface

HELLO
blue2th

2.4GHz
RF
Communi
cation
HELLO Xbee!

8051

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt


Bluetooth interface with 8051

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt


BLUETOOTH INTERFACE ASSEMBLY
CODE
connection details
1) Connect first bluetooth module to the PC
2) Connect the second blue tooth module to 8051 using serial port cable execute the program the massage is
being transferred
Write a program to transfer the message “YES” serially at 9600 baud, 8bit data, 1 stop bit interfacing with
BLUETOOTH module.
Do this continuously.
Solution:
MOV TMOD,#20H ;timer 1, mode 2
MOV TH1,#-3 ;9600 baud
MOV SCON,#50H ;8-bit, 1 stop bit, REN enabled
SETB TR1 ;start timer 1
AGN: MOV A,#"Y" ;transfer "Y"
ACALL XMIT
MOV A,#"E" ;transfer "E"
RET
ACALL XMIT
MOV A,#"S" ;transfer "S"
ACALL XMIT
SJMP AGN ;keep doing it
;serial data transfer subroutine
XMIT: MOV SBUF,A ;load SBUF
HERE: JNB TI,HERE ;wait for last bit to transfer
CLR TI ;get ready for next byte

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt


BLUETOOTH INTERFACE C CODE
// program to accept commands from PC via Bluetooth
// USB-Bluetooth adapter is connected to PC
// here Bluetooth module is interfaced with 89C51
#include <REG51F.H>
void delay(unsigned long);
void send command(unsigned char array[]);
void transmit(unsigned char);
unsigned code char setcon[]="set connectable on";
void main()
{
send_command(setcon);
delay(50000);
while(1)
{
TMOD=0X20;
TH1=0XFD;
SCON=0X50;
TR1=1;
SBUF=dat;
while(TI==0)
{} }
void delay(unsigned long count)
{
unsigned long i;
for(i=0;i<count;i++);
}

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt


C CODE CONTD

void send_command(unsigned char array[])


{
unsigned char i;
TMOD=0X20;
TH1=0XFD; // baud 9600Kbps @ 11.0592 Mhz
SCON=0X50;
TR1=1;
for(i=0;array[i]!='\0';i++)
{
SBUF=array[i];
while(TI==0)
{
TI=0;
}

SBUF=0x0D;
while(TI==0)
{}
TI=0;
SBUF='\n';
while(TI==0)
{}
TI=0;
}

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt


For More Tutorials
www.pantechsolutions.net
http://www.slideshare.net/pantechsolutions
http://www.scribd.com/pantechsolutions
http://www.youtube.com/pantechsolutions

Technology beyond the Dreams™ Copyright © 2006 Pantech Solutions Pvt

You might also like