The aim of this PROJECT to control things via wireless in a Bluetooth band . Now a days Android smart phone is a buzzword and many things can be controlled by Android through Bluetooth, WiFi. So, my motive is to make a communication system via smart phone to control Robot, home appliances,etc.

Here, I am using bluetooth (HC05) for commmunicating with AVR(Atmega32) microcontroller.

The principle task of this project was to design proper circuit and programming the Microcontroller to control my device via wirelessly. The communication protocols dealing with transmission and reception of data.

Bluetooth is a standardized protocol for sending and receiving data via a 2.4GHz wireless link. It’s a secure protocol, and it’s perfect for short-range, low-power, low-cost, wireless transmissions between electronic devices. These days Bluetooth is like wireless, and Bluetooth is a big part of that wireless communication. Variety of consumer products using bluetooth, like headsets, video gamecontrollers, or remote trackers.

Bluetooth serves as an excellent protocol for wirelessly transmitting relatively small amounts of data over a short range (<100m). It’s perfectly suited as a wireless replacement for serial communication interfaces. Or we can use it to create Computer Keyboard. or Home Appliances, wireless MP3-playing speaker , robots etc.

Step 1: Bluetooth Communication

Bluetooth Connection Process:

Creating a Bluetooth connection between two devices is a multi-step process involving three progressive states:

1. Inquiry – If two Bluetooth devices know absolutely nothing about each other, one must run an inquiry to try to discover the other. One device sends out the inquiry request, and any device listening for such a request will respond with its address, and possibly its name and other information.

2. Paging (Connecting) – Paging is the process of forming a connection between two Bluetooth devices. Before this connection can be initiated, each device needs to know the address of the other (found in the inquiry process).

3. Connection – After a device has completed the paging process, it enters the connection state. While connected, a device can either be actively participating or it can be put into a low power sleep mode.

  • Active Mode – This is the regular connected mode, where the device is actively transmitting or receiving data.
  • Sniff Mode – This is a power-saving mode, where the device is less active. It’ll sleep and only listen for transmissions at a set interval (e.g. every 100ms).
  • Hold Mode – Hold mode is a temporary, power-saving mode where a device sleeps for a defined period and then returns back to active mode when that interval has passed. The master can command a slave device to hold.
  • Park Mode – Park is the deepest of sleep modes. A master can command a slave to “park”, and that slave will become inactive until the master tells it to wake back up.

Bonding and Pairing:

When two Bluetooth devices share a special affinity for each other, they can be bonded together. Bonded devices automatically establish a connection whenever they’re close enough. When I start up my car, for example, the phone in my pocket immediately connects to the car’s Bluetooth system because they share a bond. No UI interactions are required!

Bonds are created through one-time a process called pairing. When devices pair up, they share their addresses, names, and profiles, and usually store them in memory. The also share a common secret key, which allows them to bond whenever they’re together in the future.

Pairing usually requires an authentication process where a user must validate the connection between devices. The flow of the authentication process varies and usually depends on the interface capabilities of one device or the other. Sometimes pairing is a simple “Just Works” operation, where the click of a button is all it takes to pair (this is common for devices with no UI, like headsets). Other times pairing involves matching 6-digit numeric codes. Older, legacy (v2.0 and earlier), pairing processes involve the entering of a common PIN code on each device. The PIN code can range in length and complexity from four numbers (e.g. “0000” or “1234”) to a 16-character alphanumeric string.

Masters, Slaves, and Piconets:

Bluetooth networks (commonly referred to as piconets) use a master/slave model to control when and where devices can send data. In this model, a single master device can be connected to up to seven different slave devices. Any slave device in the piconet can only be connected to a single master.

The master coordinates communication throughout the piconet. It can send data to any of its slaves and request data from them as well. Slaves are only allowed to transmit to and receive from their master. They can’t talk to other slaves in the piconet.

Range is application specific and although a minimum range is mandated by the Core Specification, there is not a limit and manufacturers can tune their implementation to support the use case they are enabling. Range may vary depending on class of radio used in an implementation: Class 3 radios – have a range of up to 1 meter or 3 feetClass 2 radios – most commonly found in mobile devices – have a range of 10 meters or 33 feetClass 1 radios – used primarily in industrial use cases – have a range of 100 meters or 300 feet

Step 2: Bluetooth Communication Contd...

Device Usage
• (almost) Stand-alone wireless connection – Needs external application to drive services

[Application]<======================>[BlueTooth Device]

Device Communications
• Client/Server (Master/Slave) configuration

–Devices are inherently equal

– Application determines identity

[[Client Application]<=>[BT Device]]<=================>[[BT Device]<=>[Server Application]]

Software/Interface Stack

[Bluetooth Host] ------------------- • Bluetooth Host

^ – Host Controller Interface driver

|| – Physical Bus driver


[Physical Bus]---------------------- • Physical Bus

^ – Physical Bus Firmware



[Bluetooth Hardware]------------- • Bluetooth Hardware

– Host Controller Interface firmware
– Baseband controller

Connecting to Device
• Host Controller Interface – Allows control interaction with Bluetooth hardware

• Transport layer – Physical connection between host and Bluetooth hardware

1. Host Controller Interface

• Uniform interface to access Bluetooth hardware capabilities

• Contains sets of commands for hardware

• Contains handle to possible events

• Contains access to error codes

2. Transport Options
• Standard describes three basic transport formats – USB Transport

• Universal Serial Bus – RS232 Transport, UART Transport

• Universal Asynchronous Receiver/Transmitter

• Serial interface – Can be set to RS232 settings

Step 3: Bluetooth Network

Bluetooth Networking

• Piconet formed by up to seven active Bluetooth devices

– Master/Slave configuration

– Additional slaves can be placed in a “parked” state Devices are not active but remain synchronized

– Connection, synchronization, parked/active controlled by master

– All devices connected in a piconet share timing and frequencies

• Scatternet formed by two or more Piconets

– One master per piconet but a master in one piconet can participate as a slave in a different piconet

– Slaves are time division multiplexed into more than one piconet

– Piconets not time or frequency synchronized

Establishing a connection

• Bluetooth units transmit inquiry message to find other Bluetooth units.

Master/Slave Piconet

• One unit becomes the master and the others slaves

• Master/slave relationship establishes timing

• A slave can become a master in another Piconet. This connects two Piconets into a Scatter Net.

Bluetooth Pico and Scatter Nets

• Master in one piconet can be a slave in another

• Addressing limits number of active devices in a piconet to 7

• An indefinite number of parked devices remain synchronized with the piconet but are not active.

Step 4: Bluetooth Radio and Modulation

Bluetooth Radio

• Radio specification

Goal is a single chip radio

Relaxed RF specifications reduce cost

• Operation under unlicensed international rules

US: FCC Part 15

Europe: ESTI 300-328

• 2.4 GHz ISM band radio

Frequency Hop (FH)

spread spectrum: 1600 hops/sec

Time Domain Duplex (TDD)

Bluetooth is a 2.4 GHz ISM band spread spectrum radio

– 2400 - 2483.5 MHz allows world wide (almost) operation

– 1600 hops/sec (625 msec) frequency hopper

– 79 One MHz channels (23 in France, Japan)

– Time Division Duplex

– Tx power 0 dBm to 20 dBm

– Range 10 cm to 10 m at low power (0dBm)

– Data rates: from 108/108 kbps symmetric channel to 723/57 kbps asymmetric channel

– Isosynchronous (circuit switched) or asynchronous (packet)

Bluetooth Modulation

• Modulation: Gaussian filtered FSK (GFSK) BT=0.5

• Modulation Index: 0.28 - 0.35

• Deviation: Fmin > 115 KHz

• Ft - Fmin = “0” Ft + Fmin = “1”

• Symbol Timing: 20 ppm

Step 5: Bluetooth Baseband Controller

Baseband Controller

Baseband: baseband protocols and low level link routines

Link Manager: Link Layer messages for setup and link control

• Frequency Hop Time Division Duplex Channel
Channel based on a 625 msec time slot (1600 hop/sec) 220 msec of the slot lost to PLL settling

Bluetooth uses both circuit and packet switched channels, supports:

– Up to 3 simultaneous 64 kbps synchronous voice channels

– Simultaneous synchronous voice and asynchronous data channel

– Asynchronous data channel:

---------------721/57.6 kbps asymmetric

---------------432.6 kbps symmetric

Access Codes

• Channel Access Code (CAC): Identifies a piconet, this code is used with all traffic exchanged on a piconet

• Device Access Code (DAC): Used for signaling, e.g. paging and response to paging

• Inquiry Access Code (IAC):

– General Inquiry Access Code (GIAC) Common to all Bluetooth devices

– Dedicated Inquiry Access Code (DIAC) Common to a class of Bluetooth devices

– Inquiry process “finds” BT devices in range

Step 6: Link Manager Protocol (LMP)

• LMP runs between Link Mangers

• LMP sets up, terminates, and manages baseband connections

• LMP Functionality

– Attach and detach slaves

– Control Master-Slave switch Used when a Slave/Master participates in another piconet as Master/Slave

– Establish ACL and SCO links

– Control low power modes: Park, Hold and Sniff

Link Manager Controls BT operational modes

– Active Mode

• BT can accommodate only 7 active slaves

• AM_ADDR: 3 bit address given to each active slave

– Hold Mode

– Park Mode

– Sniff Mode

1. Hold Mode
• ACL slave placed on Hold mode

– ACL packets no longer supported

– SCO packets can still be exchanged

• Frees Slave

– When master has no data, goes to low-power sleep

– To attend another piconet

– Scanning, inquiry, paging Slave finds or is found by another piconet

• Slave keeps AM_ADDR

• Master assigns hold time After hold time slave wakes up and synchronizes with traffic on the channel

2. Park Mode
• Low activity, low power mode

– “Deeper Sleep” than Hold Mode

– Devices wake up periodically to resynchronize and check for broadcast messages

• Parked Device

– Gives up AM_ADDR

– Remains synchronized

– Receives:

>>>>PM_ADDR: 8 bit Park Member Address

>>>>AR_ADDR: 8 bit Access Request Address

• Allows multiple slaves to be connected to a Master

• Parked Member Address

>>>>Used in Master initiated reconnection

• Access Request Address

>>>>Used in Slave initiated reconnection

• Special all zero PM_ADDR

– Device must be unparked using 48 bit BM_ADDR

– Allows almost an unlimited number of parked devices

3. Sniff Mode
• Sniff Mode much like Hold Mode

– Device remains active

– Low power active mode

• Slave retains AM_ADDR and goes to sleep

– Wakes up at assigned Sniff Interval to exchange packets

Step 7: Coding for Atmega32 MCU

it is an ussrt program. We can send and receive data to/from android smart phone or PC.

Finally i'v completed hc05 bluetooth vs andriod data transfer(2 way). Very shortly I'll add android app for robot control. Wow!
<p>sorry for delay bcz. of unavailability of bluetooth module. :(</p>
<p>It is my ongoing project......So other details wiil be coming shortly. Thanks.</p>

About This Instructable




Bio: Rudra Narayan Paul. . . . . . . ., M.TECH (CSE), . . . . . . . . . . . . . BPUT, ODISHA, INDIA. . . . . . Facebook-ID: Rudra Narayan. . More »
More by RudraNarayanG:Blinking LED Using ARM7 LPC2148 Microcontroller Easy RFID MFRC522 Interfacing with Arduino Nano MICROCONTROLLER   to  PC Communication via PL2303 (USB TO UART  TTL) Converter 
Add instructable to: