Interfacing Bluetooth Module With ATMega16

Summary:
This article would give you a general idea about how to setup and interface any Bluetooth modem with your computer. There are many types of Bluetooth modems available in market, which vary in quality, cost, range, etc. Some of the well known Serial Bluetooth modems are AUBTM, BLUESMIRF, RN-41, HC-05 and HC-04.
I would be using the last one i.e. the cheap Chinese Bluetooth module. It has limited functions and it can only work in slave mode. (Remember: Two slave modules cannot directly communicate to each other so be careful when you buy them.) The top range modules have a facility to work in both MASTER and SLAVE modes. It is Class 3 module so it range is very low. (Class 2 has a range of 10 meters and Class 1 has a range of 100 meters.)
Hardware  Required:
1. A desktop/Laptop running windows XP/7/8
2. Bluetooth Adapter for PC (Not required if your PC/Laptop has inbuilt Bluetooth hardware. Refer your laptop’s manual if it has an inbuilt Bluetooth.)
3. Serial Bluetooth Modem
4. ATMega16 Development board running at 16MHz
5. 16x2 LCD


First Time Connection Setup:
Step 1: Power ON the Serial Bluetooth Modem and also turn ON the Bluetooth on your computer. You should see the below icon at the right hand corner of your computer.



Step 2: Right-click on the Bluetooth Icon and you should see the below given option. Click on “Add a Device” option.



Once you click that option you computer initiates a Bluetooth connection and starts searching for any nearby Bluetooth enable devices.
Step 3: You should next see this type of dialog box which will be loaded with the active Bluetooth devices in the surroundings. You should see something like”HC-04” or “HC-05” or “AUBTM” or some other similar names. Click on the device name and click “Next” then.
Note: I already renamed my Serial Bluetooth Modem to “RR_WIRELESS” so that’s what is appearing in the list there. Refer your modem’s datasheet to know how to rename the module’s Bluetooth Name.

Step 4: Next, the computer would ask you whether you want to create a pairing code or enter device’s pairing code or to pair without using code. Click on “Enter the device’s pairing code”. Generally, all modems would have a default pairing code (Even cheap Chinese modems). So you have no other alternative to pair the device with your computer.





Step 5: Enter your device’s pairing code as shown below. Refer your modem’s datasheet to know the default pairing code of your device. It is generally “0000” or “1234”. In my case it was “1234”. Enter the code and click “Next”.

As soon as you click “Next” you should see notifications at your right hand corner saying “Device drivers being installed”.
Step 6: If everything goes well in the end you should see a pop-up similar to one shown below. Note down the COM Port numbers since we’ll be using those only to establish future connections between your modem and your PC.

RUNNING THE DEMO PROJECT:
We are done with configuring the Serial Bluetooth Modem with the computer. Next we’ll see how to run the demo program.
BLOCK DIAGRAM:



Step 1: Burn the attached “demo.hex” file into your ATMega16 microcontroller using the necessary programmer and software.
Step 2: Connect the LCD module and Bluetooth modem to the Development Board. Note that TX pin of modem is connected to RX pin of the microcontroller and RX pin of modem to the TX pin of the controller.
Step 3: Now you’ll need Serial Communication software to communicate with the ATmega16 through Bluetooth. If you are a Windows XP user then you would have default software called “HyperTerminal” in your computer. But if you are a windows 7 user like me then you need a third party software. There are various free third party software solutions available in internet like RealTerm, Putty and TeraTerm. Or you can buy the HyperTerminal Private edition too. 
Note: I’m using a Windows Form Application which I created myself using Visual Studio 2012. I will explain you how to make one by yourself in the next tutorial.

Whichever software you use, these would be the general steps to be followed while establishing the connections.

Turn ON the controller board and Bluetooth in your computer.
Open the Serial Port software. There would be many options and configuration settings. Don’t modify any of them unnecessarily. Just change the below given settings.
Go to the Port Tab and set it as follows.
Baud: 9600
Port: <The port we previously noted down during first time setup>
Data bits: 8
Parity: None
Stop bits: 1
Hardware Flow Control: None
The below image shows you a screenshot of the configurations .



Now type something on the screen and you should see the same text being displayed on the LCD also which is connected to the controller board.
Here is my youtube video of the demo program :



This article was published by me on EngineersGarage

Please Like us to Receive updates on FB