Bluetooth has become Ubiqutios these days Bluetooth Wireless technology is present is Most mobile phones today as well as in laptops and in desktop PCs.And If your PC or laptop doesn’t have it then you can get a Bluetooth USB dongle for cheap(like 2-3$ )!
Wouldn’t it be interesting if your mobile phones /PCs could talk to your Micro-controller Projects??
Lets find out how to add Bluetooth capability easily to your existing Micro-controller projects with out many hardware or software changes.
Bluetooth has many ‘profiles’ for communication with various kinds of devices.The profile in which we will be interested in is the Serial Port Profile or SPP for short.This profile simply emulates a standard Serial port over a wireless bluetooth link.
I was working on a arduino project and wanted to eliminate the wired connection to the arduino form my laptop.The laptop had a GUI running which sent data over a serial COM port to the arduino.I got a Bluetooth module from Lamington road,Mumbai for around 850 INR. You could find it for less on ebay or something.The model number of the bluetooth module is AUBTM-20 .Its a Class 2 Bluetooth SPP module (Class 2 meaning that its range is around 10 meters/ 30 feet).
I added a relimate connector to make it easy to connect it a breadboard or to connect jumper wires.I had the following connections on the module taken to the connectorGND,VCC and the RX and TX connections of the serial port.
Step one : Test the module
Just power up the Bluetooth module(I Fed in power to the Bluetooth Module from the 3.3v output of my arduino ) and scan the bluetooth devices on your PC/laptop.If everything’s done correctly you will be able to find a bluetooth device named AUBTM-20 or something simliar.You will be asked for a pairing code in case of the above model (AUBTM-20)it is 8888 but it might be different if you are using a bluetooth module from another vendor.On my WINDOWS 7 Laptop it showed up as “AUBTM-20” under devices and printers.
Right Click on the device name in the devices and printers folder under the hardware tab .You will find a Standard Serial over Bluetooth Link and the COM port number writeen in brackets. Note down the COM port number.This completes the Basic test.
Step Two: Verify The COM link.
you will need to verify if you are able to send and receive data over the serial port to be able to use the device in your project for that. I used the FT232RL USB to serial converter chip on-board the arduino. But remember to remove the ATmega processor chip from the socket.(You’re out of luck if you have one of those SMD versions of the arduino 😦 .In this case you will need to get hold of a 3.3V power source such as the lm1117-3.3 and a FT232RL breakout board from here or here ) before you connect the bluetooth module to the arduino. Now Connect the RX line of the Bluetooth module to the TX line of the FT232RL module or you arduino DIgital Pin 1 and the TX line to the RX line of the module or to that of the arduino.
Now open a terminal application such as TeraTerm (You can download it from here) select the serial port on which you connect your arduino/FT232 module(you can get the com port number of the FTDI device in the device manager under COM ports -> USB serial Port).Open a terminal with the COM port number of the The FTDI device and set the baud rate to 9600 ,8bit -data,Parity- none,1 -stop bit,Flow control -None.
Now open another COM port,this time with the for the serial COM port of your bluetooth device that you had noted down in the first step. The settings of this COM port will also be the same as above FTDI device. IF all the connections are proper and the link is established then anything you type in the FTDI COM terminal should appear on the Bluetooth COM terminal and vice-versa
The +CON:1 is something that the Bluetooth module gives out on the COM port whenever a device is connected .This Proves that the device can successfully communicate over the serial port
Step Three: Finally connecting the Bluetooth module to the Micro-controller.
Here’s a quick arduino script to verify everything’s fine .
void setup() { Serial.begin(9600); // open the serial port at 9600 bps: } void loop() { if( byte( Serial.read() == 'a' )) { Serial.print("\nHey!"); // print Hey } }
Just open the arduino IDE and open the serial terminal.Set the COM port number that you noted down in the First Step and the baud rate to 9600. Just type an “a” without the quotes in the terminal and you should get a reply with a ‘Hey!’.A word of caution the Bluetooth module works at the CMOS voltage range of 3.3V and can take only upto 3.7v max so while interfacing with TTL level devices such as the ATmega8/168/328 of the arduino level conversion will be required (check out this app note from NXP).I chose to use the 3.3v Level Atmega8L instead since the device can work at 3.3V no level conversion would be required.This is the final device that i made uses the LM1117-3.3 as the power regulator to regulate the 12v from the wall wart.
For microcontrollers such as LPC1768 and LPC2148 which run at 3.3v levels no level conversion or modification would be required at all.All that would be needed to be done is to connect the rx,tx and the ground lines of the Microcontroller to the Bluetooth module and you would have a Bluetooth enabled microcontroller project!
The board was first designed with the Atmega8 then i added the 3.3v regulator and switched over to the Atmega8L.The Mosfets and other devices onboard are for another project that i’m currently working on.Will Post about the project in my next post.Post in the Comments below what you think about it !