Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Interfacing Bluetooth Modules with 8051 Microcontroller

26,400 views

Published on

Interfacing Bluetooth Modules with 8051 Microcontroller

Published in: Education, Technology, Business

Interfacing Bluetooth Modules with 8051 Microcontroller

  1. 1. Interfacing Bluetooth with 8051 Microcontrollers www.pantechsolutions.net
  2. 2. <ul><li>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. </li></ul><ul><li>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. </li></ul><ul><li>Bluetooth is a wireless technology for transmission of voice and data over a short distance. </li></ul><ul><li>RXD and TXD pin of bluetooth Evaluation kit connected with the controller through serial port </li></ul>WHAT IS BLUETOOTH?
  3. 3. Bluetooth interface board
  4. 4. Bluetooth interface 8051 HELLO Xbee! 2.4GHz RF Communication HELLO blue2th
  5. 5. Bluetooth interface with 8051
  6. 6. <ul><li>connection details </li></ul><ul><li>Connect first bluetooth module to the PC </li></ul><ul><li>Connect the second blue tooth module to 8051 using serial port cable execute the program the massage is being transferred </li></ul><ul><li>Write a program to transfer the message “YES” serially at 9600 baud, 8bit data, 1 stop bit interfacing with BLUETOOTH module. </li></ul><ul><li>Do this continuously. </li></ul><ul><li>Solution: </li></ul><ul><li>MOV TMOD,#20H ;timer 1, mode 2 </li></ul><ul><li>MOV TH1,#-3 ;9600 baud </li></ul><ul><li>MOV SCON,#50H ;8-bit, 1 stop bit, REN enabled </li></ul><ul><li>SETB TR1 ;start timer 1 </li></ul><ul><li>AGN: MOV A,#&quot;Y&quot; ;transfer &quot;Y&quot; </li></ul><ul><li>ACALL XMIT </li></ul><ul><li>MOV A,#&quot;E&quot; ;transfer &quot;E&quot; </li></ul><ul><li>RET </li></ul><ul><li>ACALL XMIT </li></ul><ul><li>MOV A,#&quot;S&quot; ;transfer &quot;S&quot; </li></ul><ul><li>ACALL XMIT </li></ul><ul><li>SJMP AGN ;keep doing it </li></ul><ul><li>;serial data transfer subroutine </li></ul><ul><li>XMIT: MOV SBUF,A ;load SBUF </li></ul><ul><li>HERE: JNB TI,HERE ;wait for last bit to transfer </li></ul><ul><li>CLR TI ;get ready for next byte </li></ul>BLUETOOTH INTERFACE ASSEMBLY CODE
  7. 7. <ul><li>// program to accept commands from PC via Bluetooth </li></ul><ul><li>// USB-Bluetooth adapter is connected to PC </li></ul><ul><li>// here Bluetooth module is interfaced with 89C51 </li></ul><ul><li>#include <REG51F.H> </li></ul><ul><li>void delay(unsigned long); </li></ul><ul><li>void send command(unsigned char array[]); </li></ul><ul><li>void transmit(unsigned char); </li></ul><ul><li>unsigned code char setcon[]=&quot;set connectable on&quot;; </li></ul><ul><li>void main() </li></ul><ul><li>{ </li></ul><ul><li>send_command(setcon); </li></ul><ul><li>delay(50000); </li></ul><ul><li>while(1) </li></ul><ul><li>{ </li></ul><ul><li>TMOD=0X20; </li></ul><ul><li> TH1=0XFD; </li></ul><ul><li> SCON=0X50; </li></ul><ul><li> TR1=1; </li></ul><ul><li> SBUF=dat; </li></ul><ul><li> while(TI==0) </li></ul><ul><li> { } } </li></ul><ul><li>void delay(unsigned long count) </li></ul><ul><li>{ </li></ul><ul><li>unsigned long i; </li></ul><ul><li>for(i=0;i<count;i++); </li></ul><ul><li>} </li></ul>BLUETOOTH INTERFACE C CODE
  8. 8. <ul><li>void send_command(unsigned char array[]) </li></ul><ul><li>{ </li></ul><ul><li> unsigned char i; </li></ul><ul><li> TMOD=0X20; </li></ul><ul><li> TH1=0XFD; // baud 9600Kbps @ 11.0592 Mhz </li></ul><ul><li> SCON=0X50; </li></ul><ul><li> TR1=1; </li></ul><ul><li>for(i=0;array[i]!='0';i++) </li></ul><ul><li> { </li></ul><ul><li> SBUF=array[i]; </li></ul><ul><li> while(TI==0) </li></ul><ul><li> { </li></ul><ul><li> TI=0; </li></ul><ul><li>} </li></ul><ul><li>SBUF=0x0D; </li></ul><ul><li> while(TI==0) </li></ul><ul><li> {} </li></ul><ul><li> TI=0; </li></ul><ul><li> SBUF='n'; </li></ul><ul><li> while(TI==0) </li></ul><ul><li> {} </li></ul><ul><li> TI=0; </li></ul><ul><li> } </li></ul>C CODE CONTD
  9. 9. For More Tutorials <ul><ul><li>www.pantechsolutions.net </li></ul></ul><ul><ul><li>http://www.slideshare.net/pantechsolutions </li></ul></ul><ul><ul><li>http://www.scribd.net/pantechsolutions </li></ul></ul><ul><ul><li>http://www.youtube.net/pantechsolutions </li></ul></ul>

×