Device Control Through Bluetooth PDF
Device Control Through Bluetooth PDF
Bluetooth has replaced the standard serial ports in case of computing. Nowadays wireless mouse, keyboard and printers are found all aided with Bluetooth. The range of the Bluetooth device may depends upon the lower transceiver chip embedded within the device which may range from a meter to hundreds of meter. As radio signal are used, no distinct line of sight can be traced.
1.2 OBJECTIVES
The main objective behind our project: To develop professionalism, teamwork, management and organizational skills. To provide easy access to various home appliances through Bluetooth device. Increase the comfortably in ones life. To promote technology for general public use in an economical way.
Low power consumption is especially important in this project because the software system requires the Bluetooth on the mobile phones to be turned on all the time. This helps to prolong battery life which is scarce in mobile phones. The inherent security features and medium range of Bluetooth makes Bluetooth relatively secure as compared to other wireless radios such as wireless LAN. The security features makes it hard to listen to the data transmissions. The medium range means that hackers would have to be within close physical range to the Bluetooth radio in order to listen to its traffic. All these features are important because this project deals with access control of various appliances in which security plays a very important role.
Register. When a byte of data is available on Serial Buffer, Receive Interrupt flag is raised indicating data must be picked up now or it will be lost.
Before the serial port can be used it is necessary to set various registers: SCON: This is the serial port control register. It should be set to hexadecimal 0x50 for 8-bit data mode. TMOD: This register controls the timers for baud rate generation and it should be set to hexadecimal 0x20 to enable timer 1 to operate in 8-bit auto reload mode. TH1: This register should be loaded with a constant so that the required baud rate can be generated. TR1: This register starts/stops the timer and it should be set to 1 to start timer 1. TI: This register should be set to 1 to indicate ready to transmit.
19.53 mV rise in the analog input; the output varies by 1 unit. To set a particular voltage level as the reference value, this pin is connected to half the voltage. For example, to set a reference of 4V (Vref), pin9 is connected to 2V (Vref/2), thereby reducing the step size to 15.62 mV (4V/255). ADC0804 needs a clock to operate. The time taken to convert the analog value to digital value is dependent on this clock source. An external clock can be given at the Clock IN pin. ADC0804 also has an inbuilt clock which can be used in absence of external clock. A suitable RC circuit is connected between the Clock IN and Clock R pins to use the internal clock.
2.4 IC 7805
7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed linear voltage regulator ICs. The voltage source in a circuit may have fluctuations and would not give the fixed voltage output. The voltage regulator IC maintains the output voltage at a constant value. The xx in 78xx indicates the fixed output voltage it is designed to provide. 7805 provides +5V regulated power supply. Capacitors of suitable values can be connected at input and output pins depending upon the respective voltage levels.
register stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.
10
11
The circuit consists of the following components: Bluetooth Module Microcontroller Analog to Digital Converter Temperature Sensor LCD Display Relays
AUBTM-22 is Bluetooth Core V2.0 compliant module with serial port interface. The module is designed to be embedded in a host system which requires cable replacement function. Typically the module could interface with a host through the UART port. This module is used to establish connection between mobile device and micro controller. It acts as a SPP (Serial Port Profile) slave when it receives commands from mobile phones and it acts as a SPP master when it sends message from microcontroller to mobile phones. AT89S52 microcontroller from Atmel is used in the circuit. The main function of microcontroller is to send command to control the device as per command send from mobile phone and receive status of devices and send the information to mobile phone. Temperature Sensor LM35 is used to obtain the current room temperature and Analog to Digital Converter ADC0804 converts the analog data obtained from temperature sensor into digital data before sending the data to microcontroller. Relay is an electromagnetic device used to switch ON or OFF devices connected to it. 16*2 LCD Display is used to show the status of the device whether it is ON or OFF.
12
3.1.2 Software The commands to switch on/off devices is send from mobile phones to the microcontroller through Bluetooth module and similarly the information regarding the status of the device is send from the microcontroller to the mobile phones through Bluetooth module. So, the software was created to send and receive information between mobile phones and microcontroller.
Start
Initiate Relays
A 13
False 1 True
True
sta_3=1
C F
15
F B C
Device flag==y
Stop
Figure 3.2: Flowchart of Circuit Operation Above flowchart shows the how the commands are executed and the programs are running in the microcontroller.
16
MASTER
Inquiry
SLAVE
Inquiry Scan
Page
Inquiry Response
Page Scan
Master Response
Slave Response
Connection
Connection
Figure 3.3: Bluetooth Connection Procedure The inquiry procedure is an important part of Bluetooth. It is a process where one Bluetooth device tries to find all neighboring Bluetooth devices. A device that is trying to scan for other devices is said to be in inquiry mode. The device that listens for an inquiry request is in inquiry scan mode. This inquiry scan mode is usually set in a Bluetooth device by setting it to be discoverable. When inquiry is initiated, the device goes into inquiry mode and accelerates its hopping frequency. On the other hand, the device in the inquiry scan mode reduces its hopping frequency. This algorithm will allow the inquirer to catch up with the transmit frequency of devices that is in inquiry scan mode. This is important because of the frequency hopping algorithm employed in Bluetooth. When the frequencies coincide, the scanned device will act as slave and send its address and clock information to the master.
17
After inquiry, the inquirer will be able to initiate connection to the inquired device. Since the connection is initiated by the inquirer, it will act as the master. This initial connection is called paging. Paging is done by the master by sending paging requests to possible slave frequency slots. This frequency slots are calculated from the Bluetooth address and the clock information received during inquiry. At the time of connection establishment, the slave will synchronize its timing to that of the masters. Throughout the connection, the master never changes its hopping sequence or phase (current hop slot, determined by the masters clock). In contrast, the slave will have to synchronize with the masters clock all the time.
18
Some of the screenshots of the mobile application used in this project can be seen below:
Figure 3.4: Screenshots of Mobile Application From left in the above screenshot, it is the view of the application when it is initialized. Next image shows the view of the mobile application when we go to the settings of the mobile application. And final image shows the list of devices to be switch ON/OFF in the mobile application.
19
CHAPTER 4: EPILOGUE
4.1 Problems Faced
Several problems have been encountered during this project: No Bluetooth module for simulation purpose in software like Proteus Lack of prior knowledge of creating software in mobile operating system Lack of timely availability of hardware components Since our project is mainly based on Symbian OS but recently after takeover of Microsoft on Nokia, Nokia removed all the Symbian related SDKs so it took us long time to find an alternative Components used in this project are delicate so it took us long time to study about it so that no components gets damaged while making hardware
20
4.2 Conclusion
Device Control through Bluetooth is a good example and a practical application of microcontroller and Bluetooth based device control. It uses Bluetooth module which are now available in small dimension and low price. Bluetooth module receives the data from mobile phones and directs it to serial port and is read by the microcontroller. Microcontroller then sends commands to switch to the relays to turn on/off the devices and sends data regarding the status of the device through the Bluetooth module to the mobile phones. This project has proved to be very informative and practical. It has wide range of practical application at an unimaginably cheaper cost. Since, Bluetooth connectivity doesnt require line of sight, the devices can be control from any corner within the range of Bluetooth module. This kind of the system can be used in various sectors such as controlling the home appliances, in the shopping malls and many more.
21
4.3 References
Books Paul Barry, 2010, Head First Python, First Edition, OREILLY, Tokyo, ISBN: 978-1-449-38267-4 Jurgen Scheible, Ville Tuulos, 2008, Mobile Python, Second Edition, Wiley, New Delhi Dogan Ibrahim, 2000, Microcontroller Projects in C for the 8051, Newnes, Jordan Hill, Oxford Wei-Meng Lee, 2011, Beginning Android Application Development, Wiley, Indianapolis Internet http://en.wikipedia.org http://www.bluetooth.org
22
CHAPTER 5 APPENDIX
23