PDA

View Full Version : bluetooth comm. b/w microcontrollers



htsh_shrm
05-08-2009, 02:34 AM
am using 2 atmega16 microcontrollers. i want to do serial comm. b/w them using USART through bluetooth......tried it using usb bluetooth device at both of them ........but no data recieved ( or may be not even transmitted).........
Please suggest how to use bluetooth to communicate.........

suhasm
05-08-2009, 08:03 AM
Unless you want to dabble with complex (really complex) code , you have to use a bluetooth module with inbuillt bluetooth stack support.
Here is such a module :
http://www.bluegiga.com/WT12_Class_2_Bluetooth_Module

If you use those modules or similar , you will just need to connect the RX and TX pins from the uC to the module. The inbuilt software in the module will take care of the rest.

Which kind of "USB" bluetooth module did you use?
I have never heard of anything called a USB bluetooth module other than the things you plug into your computer to communicate with mobiles etc.
If you tried using that , then it is pretty reasonable that it didnt work as such modules do not support direct USART.

htsh_shrm
05-08-2009, 11:46 AM
ya i used the same pc bluetooth device........may b thats y it didnt worked..........thnx alot.........is there any tutorial available online to implement bluetooth stack and set profiles or is there any other cheap solution for serial digital transmission b/w the Uc`s ?

suhasm
05-08-2009, 02:14 PM
You can try this tutorial :
http://www.palowireless.com/infotooth/tutorial.asp

You will have to bit bang the bluetooth transceiver through the atmega16. That will be extremely complex and it will limit your baud rate also.

Instead of that , you can go in for either a RF module or infrared transmission.

Infrared transmission would be the easiest to implement. You can finish the whole thing in less than 50rs.
You can get a range of around 10m.

RF pair would be more convenient as it is not limited by line of sight. But it will be more expensive. I think the transmitter+receiver pair would cost over 500rs. You will need 2 pairs for full duplex communication. So the cost will become over 1200rs.

I dont know much about RF pairs as i have never used them practically.
However , i can help you with code and circuit diagram if you intend to do USART communication over infrared.

htsh_shrm
05-08-2009, 04:38 PM
ya i`d appreciate your help for infrared linking ........
thnx alot........
pls suggest........

suhasm
05-10-2009, 10:19 AM
I assume that you are knowing how to do normal USART communication.
If you dont know , then check this tutorial :
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=45341

*Transmission*

The USART will have to be configured at a speed of around 300-400 baud. If you are using the default internal oscillator of the atmega16 without any external crystal , then you can use a baud rate of 302.
The UBRR value will be 206.

If you are using an external crystal , then you will have to calculate the UBRR value on your own. The formula is
UBRR value =[ Crystal Frequency/ (16 * baud rate) ] -1

The TSOP Sensor responds to signals which are modulated at 38kHz only.
So , you need to create a ~38kHz square wave and then gate the square wave and the TX pin of the uC.

To create the square wave , you can use a 16bit timer in hardware CTC mode.
Check this if you dont know how to do that :
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50106

If using the Hardware CTC mode to generate the wave is tough , then just use a 555 to generate a ~38kHz wave. It need not be exactly 38khz. Anything between 36.5 to 39.5 khz will work.

Once you have done this , just gate the TX pin of the uC with the 38kHz square wave using an AND gate.

Connect the output of the AND gate to a driver transistor which will drive an IR LED.

*reception*

You will have to use a sensor called as TSOP1738. That is the same sensor that is found in TVs to detect the signal from the TV remote. It is readily available for around 15rs.

Connect the TSOP1738 sensor as shown in page 2 of the datasheet :
http://www.datasheetcatalog.org/datasheets/208/301092_DS.pdf

Dont forget to include the capacitors and resistors mentioned in the datasheet. They are very important for the proper operation of the TSOP1738.

The TSOP sensor inverts the signal that it receives. So , you will have to add a NOT gate to its output to get the non inverted signal.

Take the output from the not gate and connect it to the RX pin of the other uC.

Thats it. You are done. Whatever data you send from one uC will be received at the other uC.

If you are having problems , then it will be a good idea to check if the proper signal is being received by the TSOP1738 sensor by using an oscilloscope.

If you have any problems with the code or anything else , please ask , we will be happy to help.

elecrom
05-11-2009, 04:18 PM
Unless you want to dabble with complex (really complex) code , you have to use a bluetooth module with inbuillt bluetooth stack support.
Here is such a module :
http://www.bluegiga.com/WT12_Class_2_Bluetooth_Module

If you use those modules or similar , you will just need to connect the RX and TX pins from the uC to the module. The inbuilt software in the module will take care of the rest.

Which kind of "USB" bluetooth module did you use?
I have never heard of anything called a USB bluetooth module other than the things you plug into your computer to communicate with mobiles etc.
If you tried using that , then it is pretty reasonable that it didnt work as such modules do not support direct USART.

You will have to use SPP profile. WT12 has iWRAP firmware inside and this firmware has huge command set.SPP is the simplest of all profiles.

I don't know about the PC side we trying with mobile bluetooth using J2ME, hopefully it will work.

atulgupta
05-24-2009, 12:16 AM
may i know from where i can get these serial bluetooth module in delhi ??

elecrom
05-24-2009, 02:39 PM
Please go to bluegiga.com and search for dealers located in delhi.

venkboy
09-05-2009, 07:06 PM
Hello
I am a newbie (I have read many articles, but just started with the practical bit). So this is just an idea, but is it possible to set up a bluetooth communication using microcontrollers.

We can connect an D/A and A/d at the pins, and connect the analog output/input to an Ariel, so that a bluetooth connection maybe established (I think using that frequency range is allowed as long as you follow the protocol, after all all other bluetooth devices use it).

Only an idea.