Bluetooth Based Home By Mobile Application Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Bluetooth wireless technology emerged in the past years until it is started spreading among users dramatically; therefore companies are interested in the manufacture of electronic devices to take as priority the inclusion of this technology in their products and marketing them through this feature.

Bluetooth is an open wireless protocol uses for transmitting and receiving data without using cable for short-range wireless distances between fixed and portable electronic devices. It creates Wireless Personal Area Networks (WPAN) that able to share several devices within the range. It uses frequency hopping technique to a void interference from other signals after transmitting or receiving a packet with a high speed (approximately 217 hop/sec) as revealed in figure 1.


Slave 1

Slave 2

623 Ms

Figure 1: Frequency Hoppinp (FH). Time Division Duplex (TDD). [mmubook]

The Bluetooth technology supports the following types of connectivity:

Point to Point: is a simple connection and connect between two devices. One of these devices plays the role of the Master while the second devices take up the role of Slave. As shown in Fig.2.


Device 2


Device 1

Figure 2: Point to Point connection.

Point to Multi Point: is a connection of more than two devices. One of these devices plays master while all others devices plays Slave. As shown in Fig.3.


Device 2


Device 1


Device 2


Device 2

Figure 3: Point to Multi Point Connection

Adhoc networking

Piconet is a user group of devices using Bluetooth technology to permit one master device to connect with seven slave devices. As shown in figure 4.

Scatternet is consisting of one or two piconets which allow many devices to share same area. As revealed in figure 4.




















Figure 4: Scatternet and Piconet( Slave = S, Master = M) [1].

There are many characteristics of Bluetooth wireless technology. Some are [1]:

Uses frequency range 2.45 GHz band.

Data transmission rate from 721 kbps to 1 Gbps.

Maximum distance 100 meter.

Cheap compare to other technologies.

Uses frequency hopping.

Transmission speed with high quality voice and data transmission.

Supports open ended list of applications such as video, audio, voice, data, and graphics.

Physical Links between Master and Slave devices

There are two different types of links between connecting devices to transfer different types of data serially are:

Synchronous Connection Less (ACL)

Master maintains link using reserved slots.

Master supports three simultaneous links.

Allocates fixed bandwidth between point to point connection of slave and master.

Asynchronous Connection Oriented (ACO)

Allow point to multipoint link between master and all slaves.

Only can exist single ACL link

Protocol Architecture

Bluetooth architecture device has been separated into different protocols. The protocols have been classified into the following [20]: as illustrated in Fig.5.

Core protocols


The baseband and link controller enable network formation by controlling physical radio frequency activities. It directly affects Bluetooth unit's synchronization and activation according to transmission frequency hopping sequence. Baseband provides infrastructure to establish and manage two different link types defined in Bluetooth SCO for voice packets and ACL for data packets.

Service discovery protocol (SDP)

SDP allows a device to discover available Bluetooth services and their Bluetooth characteristics. It provides functionality for detecting when a service is no longer available. SDP functionality based on three components; Service Discover Server (SDS), Service Discover Client (SDC), and Service Discover Database (SDD).

SSD contains information entries for all types of services offered by that specific device. A device willing to know to services offered by its remote device uses its SDC components and queries, the SDS component of its peer which in turn searches in its SDD and returns the query results to the querying unit.

Link Manager Protocol (LMP)

LMP is used for controlling of the radio link between two Bluetooth devices. It implemented on the controller.

Host Controller Interface (HCI)

HCI acts as a mediator between connection establishments related lower layers and host device resident higher layers. Thus it enables constructing extremely small sized Bluetooth hardware. HCI provides a uniform command interface to baseband controller and link manager enabling them to access hardware status and event register status.


Audio transmissions can be performed between two or more Bluetooth units using different usage models. Audio data do not go through the L2CAP layer but go directly opening a Bluetooth link and straightforward setup between the Bluetooth units.

Logical Link Control and Adaptation Protocol (L2CAP)

The L2CAP is positioned over baseband layer beside LMP or above LMP in the Bluetooth protocol stack. It provides connection-oriented and connection-less data services to upper layers. The important function of L2CAP:

Quality of Service: An L2CAP connection allows the exchange of information regarding current quality of service for the connection between the two Bluetooth devices.

Multiplexing: the L2CAP supports protocol multiplexing. Its higher protocols are provided with required type of logical channels.

Group Abstraction: The L2CAP specification supports a group abstraction that permits implementations for mapping groups on to a piconet.

Segmentation and Reassembly: Data packets exceeding a predetermined Maximum Transmission Unit (MTU) must be segmented before being transmitted.

Telephony Controls Protocols (TCS)

TCS binary and AT commands

TCS is a bit oriented protocol that defines call control signalling to establish speech and data calls between Bluetooth units. It defines signalling procedures for establishment, control and release of calls between Bluetooth units. The calls could be one-to-one or one-to-many.

While telephone Control AT Commands is a number of existing AT commands are supported for transmitting control signals for telephony control. This uses the services offered by RFCOMM for transmission.

Adopted Protocols

Point to Point Protocol (PPP)

PPP defined by Internet Engineering units Task Force (IETF) in Bluetooth technology is design to run over RFCOMM to accomplish point to point connections.

Objective Exchange (OBEX)

OBEX is an optional application layer protocol adopted to enable units supporting infrared communication to exchange a variety of data and commands in a resource sensitive standardized fashion. OBEX is based on client server architecture and is independent of transport mechanism and transport API. The protocol defines a folder listing object, which is used to browse contents of folder on remote device.


TCP/ UDP/ IP standards are defined to operate in Bluetooth units allowing them to support applications that communicate with other connected units. TCP/ UDP/ IP protocol configuration is used for all internet bridge usage scenarios in Bluetooth 1.0 and for OBEX in future versions.

Wireless Application Environment (WAE) / Wireless Application Protocol (WAP)

The users can access the web content on low speed wireless network.

Cable replacement Protocol

Radio Frequency Communication (RFCOMM)

RFCOMM is responsible for emulation of RS-232 serial port for transfer of control and data signals over Bluetooth. It used by applications that require use of serial ports of the kind used in personal computers. It provides transport capabilities for its upper level services, such as object exchange protocol.

C:\Users\Laith AL_Bayati\Desktop\Bluetooth_stack.jpg

Figure 5: Bluetooth Protocols [a1]

Bluetooth Establishing a Connection

The Bluetooth device accomplishes the following procedures for a great a connection. As shown in Fig.6.

Inquiry: is a procedure used to know device address of the devices nearby.

Inquiry Scan: that means device is listening for inquiry.

Inquiry response: that means device has been received inquiry response.

Page: Master device issued a page.

Page scan: device is searching for a page (Bluetooth area).

Master response: master device finds slave device.

Slave response: slave device connects to master device.

Figure 6: Bluetooth Transition Diagram.[mmubook]

On the other hand, microcontrollers have receiver and transmitter (P3.0 as RXD and P3.1 as TXD) pins which allows using this particular to receive signal from Bluetooth module as input and control devices as output, explained in detail in chapter 3.

Viewing of the characteristics described above, has led many scientist and researchers to develop and use Bluetooth in many areas. This project will mention one of the most important using of Bluetooth in the current time which called Bluetooth remote control.

Normal remote control have used through infrared rays to control devices. Nowadays, there are many well-established techniques used Bluetooth remote control.

For example, Bluetooth enables mobile phones to control remotely desktop computers and that can be controlling a music player, power point, access internet, etc. [2]. On the other hand group of researchers employed Bluetooth in the mobile phones to control devices by Short Message Service (SMS) for a smart home. Here, SMS control system connects to the computer and reads a short message from other remote handhelds. The short messages then send instructions to the smart home system to apply them [3].

However, in this work a solution using Bluetooth to Bluetooth technology will be used to control particular devices is provided. It would be a good choice because it is more convenient, security, reliability, and economical. This solution uses relatively inexpensive components with AT89C2051 microcontroller and Bluetooth module SMiFR Gold to achieve this goal. The python program will be use and install in a mobile phone to allow users to control devices through electronic circuit.

A practical test of Bluetooth control is also presented to verify its output response. An explanation of the recorded sending signal from the mobile phone as well as receiving this signal by microcontroller which is program by assembly language to enable control output is included.

The design system was tested in the lab to measure and transmit the signal when it works under sending the signal from mobile phone to LEDs and devices through microcontroller. The system succeeded in sending signal and receiving by microcontroller to control LEDs diode.

Aims and Objectives

The aim of this work is to use Bluetooth technology to control a number of devices. For instance, send a signal from a phone to turn on and turn off a number of Light Emitting Diode (LED). As shown in the figure 1. Almost new handheld devices have Bluetooth technology such as Nokia mobiles, Samsung mobiles, Sony Ericsson mobiles, etc. This technology allows us to write applications for these handhelds to act as remotes for our receivers.

This intended work will cover the following objectives:

To develop software for mobile applications.

Sending signal from a mobile phones and receiving by microcontroller.

Compatibility between mobile clients and electronic circuit.

Scope of the this Dissertation

This dissertation is organized into five chapters. Chapter one is intended to serve to present the problems and objectives of this work. Literature reviews pertinent to this study are presented in Chapter two. Chapter three presents the methodology parts related to the project. In Chapter four results and discussion of sending signal from Bluetooth module to Light Emitting Diodes (LED) through (AT89C2051) microcontroller are presented. Finally, conclusions and further work are given in Chapter five.

Chapter 2

Related Works

Chapter Overview

In this chapter, literature survey on the Bluetooth module, Microcontroller, and Mobile applications are described. The historical background of the Bluetooth technology methods for sending signal is described and the most common methods are briefly introduced. The second part of the survey focused on receiving signal by microcontroller. Finally, mobile applications are discussed in the third part.

Related Work

There have been a lot of researches and efforts to achieve technology which is control by Bluetooth. In this section considerable works in Bluetooth technology and its using microcontroller to control devices are described.

2.1.1 Bluetooth and Microcontroller Works.

Bluetooth has been performed by (N. Sriskanthan, F. Tan, and A. Karande) [7] to have been presented Bluetooth based home automation system. This work describes the advantages of Bluetooth technology and using in home automation and networking. This work suggests a network which includes remote, several client modules (home devices) and host controller. The home devices connect with the host controller through Bluetooth devices. As shown in Fig.2.

The system has been established to be functioning by developing a room temperature control system. Moreover it allows the user to monitor and control different appliances connected over the Bluetooth network in home environment. As shown in the figure 3. Microcontroller was used as a device controller for client modules. `

Figure 2: Bluetooth piconet including Client and Host modules. [7]

Figure 3: Room temperature control circuit. [7]

(YUAN Xiao-Chen, CHEANG Chak-Fong, and LI Jian-Qing) [3] Have been presented implementation of a remote control system for a smart home. They worked remote control system via Bluetooth and Short Message Service (SMS) to control smart home with short and long distance. SMS remote control system for smart home is composed of SMS control system and re-transmitter. SMS control system reads the received short messages from the handheld that is connected to the PC and sets up a service with a designated network port. The short messages are from the other remote mobile phone that sends instructions to the smart home system. Re-transmitter forwards the instructions to the functional elements in PRO2 which is the main processor of the smart home system. As illustrated in Fig. 4.

Figure 4: Structure of smart home system. [3]

(Fadhil T. Aula) [8] Has used Short Message Service (SMS) in mobile phone to control home appliances by using personal computer parallel port interfacing. He worked a system of a Personal Computer (PC) remote controlling with mobile phones to access computer serial and parallel ports. As shown in the figure 5, 6, 7.

Figure5: PC remote control system [8]

Figure 6: Graphical User Interface (GUI) program of the remote control system [8].


Reading and saving SMS

in temporary file

Home appliances control interfacing system

Compare with control signals

Searching for control words

Mobile phones SMS

Empty and reset the temporary file


Figure 7: The Block diagram of the remote PC control system [8].

(Serkan Inal, Yavuz Erol, Duygu Karabulut and Hasan H. Balik) [30] Have been presented Programmable Interface Controller (PIC) based remote control Application for smart houses. They implemented system to safely control electricity operated home network by the help of handset or telephone line from any place all over the world. Furthermore, the system introduced and implemented in this work has pin-check algorithm in order to expand security. As illustrated in the figure 8 and 9. The central part in this system is Programmable Interface Controller (PIC) [31] which will be as controller as shown in revealed figure 9. The controller detects number of ringing then decodes Dual Tone Multi-Frequency signal (DTMF)

PIC Based Remote Controller

Figure 8: Remote controller System.

Figure 9: Complete circuit.

(Hubert Roth, Otto J. R.osch, and Klaus Schilling) [32] Have been presented haptic interfaces for the remote control of mobile robots. They implemented software and hardware system for controlling a mobile robot over internet by using a force feedback joystick. The main input device for this system is joystick. It is enabled to control small car through internet. The microcontroller and sensor on the car. As shown in figure 10.

Figure 10: Mobile remote control and haptic interfaces system.

Chapter 3

Project Characteristics

Chapter Overview

One of the most important and modern device we used in this project is Bluetooth module SMiRF Gold. In this section we introduced all the details about project components such as types, operation, input, and output. Actually this chapter divided into three main parts. The first part focused about mobile client applications, the second part explained electronic circuit components. The final part explained Bluetooth module.

Mobile client applications

Language programs divided into high level language and low level language. As shown in the block diagram 8.

Python language has been used in this work. Python was executed in December 1989 by Guido van Rossum in Netherlands. Python language is high level programming language whose design philosophy emphasizes code readability. [9]. It is a dynamic object oriented computer programming and mobile phones language.

Python can be run on most common platforms, for instance, Mac OS, Linux, Windows, and Palm OS as well as Nokia S60 second and third edition handhelds.

S60 is a software platform for handhelds based on Symbain OS. It contains several modules particular to mobile platform, for instance, networking, Bluetooth, Graphical User Interface (GUI), elements, SMS messaging, access to the camera, etc.

It has been used in this project to be installing in Nokia smart phones which have Symbian OS. Symbain OS is an operating system created for handhelds devices.

Why chosen python language to program mobile phones?

Easy to write and learn.

Can be scalable.

High security.

There are two different ways to connect over Bluetooth with S60.

OBject Exchange (OBEX) is useful for transferring files, such as voice, or photos, or sound over Bluetooth.

Radio Frequency COMMunication (RFCOMM) is suitable for sending and receiving streams of data and text.

To send data, photos, voice, etc, over Bluetooth we have to know Bluetooth address Media Access Control (MAC) which is represented in a string, such as 00 : 13 : d3 : 40 : f1. We can find Bluetooth addresses and devices when we make Bluetooth scanning.

Language Programs

High Level Language

Low Level Language

Machine code

Assembly code



C language






Figure 8: Language programs levels.


Open Mobile program

Not Available

Search for Bluetooth module


Connecting to the circuit

Send control signal from

Mobile phone to Bluetooth module

Convert the control signal to microcontroller

Send the signal to suitable output connection





Figure 9: System Flow Chart.

Electronic circuit

Actually this part divided into two main points:


A microcontroller (also known microcomputer) is a small computer on a single integrated circuit that contains all the components comprising a controller. Typically, it contains a Central Processing Unit (CPU) that executes programs, Random Access Memory (RAM), it uses to store data, some form of Read Only Memory (ROM) where programs to be executed can be stored, timer, and input / output ports (I/O) that enable communication to be recognized with world i.e. connections to sensors, doors through relay, computers, Light Emitting Diode (LED) and other peripherals. It is designed for a specific task to control a particular system [112]. It is sometimes called embedded microcontroller which is part of an embedded system that is one part of a large system or device.

Microcontrollers are used widely in automatically controlled products and devices such as remote control, office machines robotic, automobile engine control systems, and implantable medical devices.

Microcontroller 8051 has been used in this project. The Intel 8051 is one of the most popular microcomputers in use today. Intel is a famous and biggest technology company in the world. Their produces are available in Philips, Infineon, and Atmel manufacturers. [Book]

There are a lot of types of microcontroller 8051 Atmel such as AT83EB5114, AT85C51SND3, AT87F52, AT89C1051, AT89C1051U, AT89C5115, AT89C51CC03, AT89C51RC, AT89LP2052, AT89C5130, AT89C2051, etc. The microcontroller (AT89C2051) has been used in this project. [Kiel software]

The AT89C2051 microcontroller is a low voltage from 2.7 to 6 volt, high performance Complementary metal-oxide-semiconductor (CMOS) eight bit microcontroller with 2K byte of flash programmable and erasable read only memory (PEROM). The AT89C2051 is a powerful microcontroller which provides a highly flexible and cost-efficient solution to many embedded control applications. The Atmel AT89C2051 provides the following features: 128 bytes of Random Access Memory (RAM), 2K bytes of flash, 15 Input/output lines, furthermore it provides:

Description Pins of AT89C2051 Microcontroller

VCC: Pin.20 is supply voltage.

GND: Pin.10 is Ground.

RST: Pin.1 is reset input. All input/ output pins are reset to 1 second when reset go high.

XTAL1: Pin.5 is input to internal clock operating circuit, and to the inverting oscillator amplifier.

XTAL2: Pin.4 is the inverting oscillator amplifier output.

Port 1 is an 8 bit two-way input / output port. The port 1 has pins from P1.2 to P1.7 provide internal pull ups. While P1.1 and P1.0 need external pull ups Furthermore P1.1 and P1.0 supply as the negative input (AIN1), and the positive input (AIN0). In additional Port 1 can receives code data during Flash programming and verification.

Port 3 has pins P3.0, P3.1, P3.5, P3.7, P3.2, P3.4, P3.3 are seven two-way input / output pins with internal pull ups. As shown in table below. P3.6 is an input to the output on the chip but is not reachable as a general purpose input / output pin. The output buffers of port 3 can drop 20 mA.

Table 2: AT89C0251 port 3 pins

Figure 7: AT89C0251 Microcontroller.

By reducing the cost and size, it will be used in this project and programmed by an assembly code to receive the data from the mobile phones through Bluetooth and then to control output either turn on or turn off led. [6]

Bluetooth Technology.

It is new technology. It becomes appear last two decade. It is radio technology that makes it possible to receive and transmit signals over short signal. [b1]

Bluetooth BlueSMiRF Gold Class 1 technology has been used in this project. It is small shape factor. It is a wireless cable serial which works as transmitter and receiver pipe. It supports multiple interface protocols. It supports Serial Port Profile (SPP) which is

It is necessary to enable connection between handhelds and electronic circuit. It can be designed for low power consumption about 3.3V up to 6V with a short range depends on the class module [5]. As shown in the table 1. [1]


Maximum power

Range (approximately)






100 meters




10 meters




1 meters

Table 1: Classes of Bluetooth Modem.




Blue core external






Radio Frequency Switch




Flash Memory

Figure: Bluetooth block diagram

There are many specifications for Bluetooth Modem - BlueSMiRF Gold. Some are: [5]

FCC Approved Class 1 Bluetooth Radio Modem

Extremely small radio - 0.15x0.6x1.9"

Very robust link both in integrity and transmission distance (100m)

Low power consumption : 25mA avg

Hardy frequency hopping scheme - operates in harsh RF environments like WiFi, 802.11g, and Zigbee

Encrypted connection

Frequency: 2.4~2.524 GHz

Operating Voltage: 3.3V-6V

Serial communications: 2400-115200bps

Operating Temperature: -40 ~ +70C

Built-in antenna


Led Diodesonos_CR200_angle_thumb_US.jpg

Mobile phone

Led Diode

Circuit with Bluetooth



Led Diode

Led Diode

Figure 10: Overview of the project

Mobile Device

Electronic Circuit

Users Interface




Electronic Circuit

Mobile Application

Figure 11: Project parts

Chapter 4

System Implementation, Results and Discussion

Chapter Overview

In this chapter we implemented our system and evaluated our Bluetooth remote control. We first started to send signal from my mobile phone to be enable to control output through AT89C2051 microcontroller. A discussing of the results also provided. We also discussed some of factors that affected system operation.

4.2 Overall System Results and Discussing

4.2.1 Mobile Phone Implementation

To make an ordinary Bluetooth as a future and smart phone, all output must be controllable. To do that, we have been used Nokia N95 mobile phone.

As the mobile phones are provided with Bluetooth, which make it easily to interface mobile phones with real world control applications. We have been created software which is installed in Nokia N95 mobile phone to allow uers sending signal from N95 mobile phone to electronic circuit. I called this software "MMU Control" As shown in figure 20.

Figure 21: Python Application

After installing we can see program icon on Nokia N95 screen. As shown in figure 22.

4.2.2 How to write and create "MMU Control" software.

In this section, we explain the steps to write python code for Nokia N95. As we mentioned in Chapter 3, there are two different ways to connect Bluetooth module with PS60 (OBEX) and (RFCOMM). In my project I have used RFCOMM because RFCOMM is suitable for sending and receiving serial data. First of all we scan for Bluetooth devices which are available in the range. We found our Bluetooth which is called "FireFly-A786". As shown in figure 23.We can detect available RFCOMM services by using the function:

socket.bt_discover ().

print "Discovered: %s, %s"%(address,services)

Figure 23: Searching and Discover Bluetooth module.

After we discovered our Bluetooth device, we have to choose our Bluetooth name from the list and press "Select" to connect with Bluetooth module (Bluetooth circuit). As shown in figure 23. After choosing we got main program screen, as shown in figure 24. The responsible code to make connection between two Bluetooth devices is:

print "Connecting to "+str(target)


return sock

print "OK."

Figure 24: Main screen

We have to press "Select" in the left down corner which is enable users to see buttons name. As shown in figure 25. The responsible code to achieve buttons list are: = u"MMU Control"[(u"LED 1 ON",bt_send_data1),

(u"LED 1 OFF",bt_send_data2),

(u"LED 2 ON",bt_send_data3),

(u"LED 2 OFF",bt_send_data4),

(u"LED 3 ON",bt_send_data3),

(u"LED 3 OFF",bt_send_data4),

(u"LED 4 ON",bt_send_data3),

(u"LED 4 OFF",bt_send_data4),

(u"Exit", quit)]

Figure 25: Choose LED Number.

The bt_send_data1 () function sends the ASCII character 'A11' to the electronic circuit through Bluetooth module to switch the LED 1 ON.

The bt_send_data2 () function sends the ASCII character 'A12' to electronic circuit through Bluetooth module to switch the LED 1 OFF. As shown in the code below:

def bt_send_data1():



def bt_send_data2():



4.2.3 How to sending data from Nokia N95 mobile phone

Sending signal from my mobile phone Nokia N95 is the main part of my project. The bt_send_data1 () function sends the ASCII character 'A11' to the electronic circuit through Bluetooth module to switch the LED 1 ON. I have sent character 'A11' which is received by AT89C2051 microcontroller as hex code. As shown in figure 25.



Receive code by AT89C2051








Figure 26:

While the bt_send_data2 () function sends the ASCII character 'A12' to electronic circuit through Bluetooth module to switch the LED 1 OFF. I have sent character 'A12' which is received by AT89C2051 microcontroller as hex code. As shown in the table and figure below:



Receive code by AT89C2051








Figure 27:

4.2.2 Receiving Signal by AT89C2051 Microcontroller

To install the application on the mobile phones users should have python script on their handhelds. When the users will be run an application in their mobile phones will get some buttons such as turn on, turn off, all turn on, and all turn off. The application attempts to connect to the Bluetooth module which will be in the electronic circuit. The user can only connect and continue using the application if the circuit design is found in range of the handhelds. Once the user connected to the circuit, they are presented with list of buttons to control output.

4.2.3 Bluetooth SMiRF Gold Setting Baud Rate

We have connected our Bluetooth module to the Servo Controller SSC-32. Figure 28 showed Bluetooth SMiRF connection to the board. [33]

C:\Users\Laith AL_Bayati\Desktop\project\change buad rate_files\bluessc.gif

Figure 28: Connected Bluetooth SMiRF to SSC-32 [33]

I have installed 'Lynxterm' software in my laptop to be able to change baud rate.

4.2.4 Creating SIS Application

I have been written python code and test it in the Nokia N95 mobile phone. Now, I want to make standalone application (SIS) out of my mobile phone to install in any mobile phones.

The following are the steps, how to make (SIS) file from python script (.py) file:

We have to download ensymble software.

For windows system, we have to download Stunnel OpenSSL binaries and save it in somewhere, e.g. D:\ OpenSSL\bin. I have added directory to my command search path:My Computer >>Properties >>Advanced >>Environment Variables >>System Variables >>Path

We have to type the command in DOS system in one line. As illustrated in figure 29.

C:\Users\Laith AL_Bayati\Desktop\writing folder\1.bmp

Figure 29: Write command to make (SIS) file

After typing the command line, we have to press Enter. We have make (SIS) file. As shown in figure 30.

C:\Users\Laith AL_Bayati\Desktop\writing folder\3.bmp

Figure 30: Created (SIS) file