Let's Make Robots!

Cheap bluetooth module for an Arduino

mogul's picture
Gives a robot bluetooth capability
Time to build: 
8 hours
Cost to build: 
$6.49

Some time ago I ordered a cheap bluetooth module on ebay for my Arduino. I went for a no-name module, when I say cheap I mean it. (well after all it were only a few dollars cheaper than the branded ones)

Anyway, module arrived and I tried to communicate with an internal command processor, which I expected to be there. Hooked up serial lines to the TX(1) and RX(2) pins on the module, 3.3V VCC(12) and GND(13). Nothing happened, no response to AT commands. I read multiple web pages, all describing how it should be done. I think I tried all possibilities. Many people mention that I should pull high pin 34 or 26 to actually enable the command processor.All this were tried and much more too. Nothing, no response to my attempts.

On the other hand, I could see the module on the bluetooth "ether", both on my primary linux box and on an old XP box, so some sort of life were detected. From the web I have learned that the pin code most likely would one of 0000, 1234 or 12345.

Well, after some time I gave up, and cried my failed attempts on the shoutbox. Birdmun asked why I were so eager on speaking to the command processor, well I thought that changing the pin or something would be necessary. Next day aaronsuper1 gave me yet another link (http://arduino-projects.co.uk/tutorials/connect-arduino-android-phone-bluetooth/ which now redirects to http://www.therobotlab.co.uk/2011/arduinoandandroid/) to people using their androids to control an Arduino. Somehow that link were a little better which helped me!

All my struggle to get the command processor speaking where waste of time. I simply skipped that part. Used the XP to wake up the module and pair my USB-bluetooth dongle with the module. 1234 were the correct pin code in the case of this particular module. When the initial pairing were done I moved back to linux where I'm more comfortable.

Right now I have a test setup consisting of the following chain

  1. linux system
  2. terminal program (minicom, putty or something like that)
  3. usb->rs232 converter, showed up as /dev/ttyUSB2 on my system
  4. rs232->logic converter (home made, http://letsmakerobots.com/node/29207)
  5. bluetooth module
  6. air with radio waves. "the ether"
  7. bluetooth->usb dongle
  8. terminal program (connect to /dev/rfcomm4)
  9. linux (actually the same machine as in step 1)

The linux is an older ubuntu box, 10.4 I think. It should not be that important.

Since the terminal program in step 2 is using a real serial communication link, baud rate is important. I figured out that my module is operating at 38400 bits per second. This finding were made by trial and error, and when that failed, I fired up my good old oscilloscope were the bit rate were easily visible)

To get step 7 and 8 working I had to prepare the bluetooth system on the linux a little:

  1. Scan the "ether" for bluetooth devices type: hcitool scan. returned a address and a name
  2. Bind address to a linux device (I picked number 4): sudo rfcomm bind rfcomm4 00:19:5D:24:B7:63

The last one does not make an actual connection between the two bluetooth devices but only prepares them. When a program opens the device file the actual connection gets established.

Now type something and watch it show up in the other window, transmitted via bluetooth.

As seen on the picture, there is a 5'th wire (pin 31) going out from the module. It's a status line, able to drive a LED. If LED is flashing there is no connection. When it is steady on there is a bluetooth connection established.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ro-Bot-X's picture

Will 10 of these be controlable from a computer (with a USB Bluetooth stick) at the same time? I mean the computer should send commands and the modules should listen to the messages addressed to their own ID. The comuter is the Master, the modules are the Slaves, Master can communicate and get response from the Slaves, the Slaves can communicate only with the Master by request. I know this works with xBees, but does it work with Bluetooth modules?

Aaronsuper1's picture

Glad to be of help to you, mogul. So, any plans on a bluetooth controlled bot coming soon?

mogul's picture

Not remote control, but wireless software upload and debug. Right now I have to get up from the chair, to grab the bot on the floor, plug in a cable, press "upload" button, unplug cable, get up again, back to the testing grounds, etc... too much exercise.

And if I somewhere in the program want see the value of a few variables I will be able to simply print them now. Thats a feature I miss a lot with my Wood&Glue maze solver. It overshoot some turns and I'm not sure why. Does it misinterpret a corner as a intersection or something else. With a bluetooth link on the serial output I will be able to watch the debug statements roll over my screen, without leaving my chair.

Aaronsuper1's picture

Seems like a pretty good idea... though I wouldn't reccomend it to the younger generation. I prefer doing the longer method myself. 

You look cool if someone sees you doing it...

rogue's picture

Yeah but it can be very practical for tuning a PID loop and tweaking parameters on the fly.

kingkong95's picture

Interesting post!  It's nice to see my tutorial is still being used too, even if it's only a tiny piece of it! By the way I've moved the tutorial to the new website and added a redirect, I never knew people were still looking at it otherwise I would've moved it ages ago!

 

mogul's picture

Link updated.

I got a question to your schematic. You do not level shift the RX and TX lines between the 5v signals on the Arduino side to the 3.3v signals used on the bluetooth module side. I would be afraid of the the blue smoke but perhaps there is no risk. Do you have any facts on this or are you just running on luck and liquid nitrogen?

At the moment I run my atmega328p chip at 3.3v on a breadboard but were planing on using a few resistors at voltage dividers when moving back to the 5v Arduino. Waste of time?

kingkong95's picture

We were just running on luck and didn't get any blue smoke either! It hadn't even occurred to me that we should use level shifters, but now you mention it, it would probably be a good idea! I'll update the tutorial with a level shifter and a different android app when I get time, in the mean time I'll add a note :)

I found this which uses a couple of resistors and a mosfet transistor, looks like a good cheap way of making a level shifter :) 

GroG's picture

Making progress I see .. that is great.

I have worked on the little cheap BT units a while back - some docs I have here ..

The paired units I have were designed to "plug and play" one is a host and the other a slave.  Unfortunately I was interested in the slave units and the distributor give me all hosts except for one :P

I was frustrated with attempting to program it with AT commands.
The have the command accepted in some strange loop - CR LF is not accepted and I have found you can not type the commands in you must copy/paste because whatever is digesting them is doing so in ~1 second loop

birdmun's picture

I believe you could/should be able to remove your modules frome their carriers and use them like mogul is using his.