Sei sulla pagina 1di 9

Interfacing Bluetooth with 8051 Microcontrollers

www.pantechsolutions.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 Ltd.

Bluetooth interface board

Technology beyond the Dreams

Copyright 2006 Pantech Solutions Pvt Ltd.

Bluetooth interface
HELLO blue2th

2.4GHz RF Communicati on
HELLO Xbee!

8051

Technology beyond the Dreams

Copyright 2006 Pantech Solutions Pvt Ltd.

Bluetooth interface with 8051

Technology beyond the Dreams

Copyright 2006 Pantech Solutions Pvt Ltd.

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:

AGN:

MOV MOV MOV SETB MOV ACALL MOV


RET XMIT MOV ACALL SJMP MOV JNB CLR

TMOD,#20H TH1,#-3 ;9600 baud SCON,#50H TR1 A,#"Y" XMIT A,#"E"


A,#"S" XMIT AGN SBUF,A TI,HERE TI

;timer 1, mode 2
;8-bit, 1 stop bit, REN enabled ;start timer 1 ;transfer "Y" ;transfer "E"
;transfer "S" ;keep doing it ;serial data transfer subroutine

ACALL

XMIT: HERE:

;load SBUF ;wait for last bit to transfer ;get ready for next byte

Technology beyond the Dreams

Copyright 2006 Pantech Solutions Pvt Ltd.

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 Ltd.

C CODE CONTD
void send_command(unsigned char array[]) { unsigned char i; TMOD=0X20; TH1=0XFD; 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; }

// baud 9600Kbps @ 11.0592 Mhz

Technology beyond the Dreams

Copyright 2006 Pantech Solutions Pvt Ltd.

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 Ltd.

Potrebbero piacerti anche