Wednesday, April 13, 2011

TTL Bluetooth Transceiver with Linux

I recently got one of these cheap chinese TTL to Bluetooth transceivers.

http://gb.suntekstore.com/wireless-bluetooth-transceiver-module-rs232-||-ttl.html

I got mine off ebay delivered for under US$7. The seller unfortunately didn't have a pinout diagram or any real info about the module (or maybe couldn't understand enough English to work out what I was asking).

I figured that all of them on the market are probably the same design so it shouldn't be a big deal.

Luckily I was right. The best resource I found was this:

http://www.egochina.net.cn/e-shop/ebay/datasheet/Bluetooth_Module_L6.rar

A number of diagrams, manuals and pieces of software in that archive.

The only problem is they are all windows specific.

The Ubuntu Bluetooth applet let me see and pair with the device, but no clue on how to use it.

Time to learn a little more about the Linux bluetooth stack.

hcitool scan
Scanning ...
 00:19:5D:24:B7:63 OBDII

Ok so we can see it from the command line and see it's address, it's the only thing found.

Most of the other diag tools didn't return any useful info.

Eventually I found the following to work.

sudo rfcomm bind /dev/rfcomm0 00:19:5D:24:B7:63

picocom -b 38400 /dev/rfcomm0

At that point I could talk to my MCU over bluetooth!

7 comments:

  1. i just got a few of these modules and have been stressing for a day over it under linux. thanks!

    ReplyDelete
  2. actually - picocom freezes after "Terminal "ready" - did you have the same problem?

    ReplyDelete
  3. nice, I got the same device, too.

    One question: did you try to talk to the device using AT commands? I found that other people were able to talk to a device using the same chipset with AT commands and change settings, but this one does not seem to answer to any AT commands.

    ReplyDelete
  4. Hi, I got the same device. Did you use the transparent data master mode? How did you adapt the 3.3V TTL level, did you use a MAXxxx chip?

    ReplyDelete
  5. I didn't try any AT commands, just used it as is for data.

    I didn't connect it directly to a PC, but to a MSP430 launchpad - which is 3.3v TTL.

    ReplyDelete
  6. I got it working with a MAX3232 chip. By numerous experiments I found the default speed in transparent mode is 9600 bps for my device. I can transfer data in both directions with this speed. However, for my application I need 19200 bps. In AT mode, the device only reacts at 36400 bps, but only to spit out several ERROR (0) responds to each AT command. A single AT command sometimes gets an OK but as soon as I add any arguments it displays ERROR (0). This is supposed to be a AT command error, any idea?

    ReplyDelete
  7. The AT command mode is kind of weird. I you send another character ahead, it responds to the AT command with OK. I could change my speed now with command
    AT+UART=19200,0,0
    Finally it works as expected!

    ReplyDelete