Bluegiga WT12 Bluetooth Module Connection
Update 4/18/2011: you can read about the custom WT12 breakout board I designed here. The short version is that the board was almost good enough, but I’ve got a revision ordered and that one should be perfect. It will be available to others shortly.
Update 6/24/2011: the WT12 breakout boards I designed are now available on InMojo here (full, $50) and here (UART only, $40) for cheaper than you can get WT12 breakout boards anywhere else as of the time of this update. You can also download my Bluegiga Eagle library here. You may also be interested in the follow-up blog post about this.

So, after all of my experiments with BCM2042-based Bluetooth modules and the uncertainty and sparse documentation surrounding them, I decided to give Bluegiga’s WT12 module a try. I have to say, the more I learn and experiment, the more I like it. This one single module supports pretty much every Bluetooth profile ever, easily hot-switchable via a simple command. Their customer support is excellent. Their documentation, firmware, schematics, and all other development resources are readily available for free. Their modules are available for purchase cheaply in small quantities (e.g. one at a time for $27 from SemiconductorStore.com). You can control the complete behavior of the module using their capable iWRAP firmware and well-documented commands sent over the UART interface. It’s perfect.

I ordered a couple of WT12 breakout boards to go along with the two WT12 modules I ordered, but the boards are coming from BatchPCB which, while inexpensive, will take weeks to arrive, or so I’m told. So I went ahead and decided to solder wires directly onto the tiny solder pads on the WT12 itself. Of course, I forgot to notice that the datasheet diagram was showing the top view of the module, so I soldered everything (VDD, GND, TXD, RXD, RTS, CTS) onto the wrong sides. I didn’t catch that mistake for a couple of hours…oops. Fortunately, I didn’t fry anything, probably because the GND pin was still valid.


After I resoldered everything on the opposite side, I connected it, opened the serial port, and reset the module, at which point I was presented with this in my terminal:

WRAP THOR AI (3.0.0 build 165)
Copyright (c) 2003-2008 Bluegiga Technologies Inc.
READY.

Yes! Yes yes yes yes YES! One very, very simple firmware update later via their SerialDFU utility (I ordered v3.0 modules because the v4.0 modules were out of stock), and I got this:

WRAP THOR AI (4.0.0 build 317)
Copyright (c) 2003-2010 Bluegiga Technologies Inc.
READY.
at
OK
set
SET BT BDADDR 00:07:80:44:a0:89
SET BT NAME WT12-A
SET BT CLASS 001f00
SET BT IDENT BT:47 f000 4.0.0 Bluegiga iWRAP
SET BT LAP 9e8b33
SET BT PAGEMODE 4 2000 1
SET BT POWER 3 3 3
SET BT ROLE 0 f 7d00
SET BT SNIFF 0 20 1 8
SET BT MTU 667
SET CONTROL BAUD 115200,8n1
SET CONTROL CD 00 0
SET CONTROL ECHO 7
SET CONTROL ESCAPE 43 00 1
SET CONTROL GAIN 0 5
SET CONTROL MSC DTE 00 00 00 00 00 00
SET CONTROL PREAMP 1 1
SET CONTROL READY 00
SET PROFILE SPP Bluetooth Serial Port

Now I can really have some fun.

39 Comments
  1. Hi there!

    i got a wt12 too, and i have little startproblems… can i put only the RX, DX, GND’s and VDD’s to programm it over the spi? i wont use a flowcontrol, so i dont need the cts and rts?!

    • Hi Sven!

      Yes, you can use just the RX, TX, GND, and RDD. Flow control is not necessary. Just make sure you have connected RX on the WT12 to the TX pin on your controller’s UART port, and similarly TX on the WT12 to the RX pin on the controller’s UART port.

  2. good news 🙂
    but the bad is, that i dont know how to get the WRAP THOR AI (3.0.0 build 165) message 🙁
    with my atmega32 i can send data via uart to my pc. can i use this function to configure the wt12 blind? the problem is, that i cant see any reaction of the wt12.
    do you know a easy way to test it? (maybe i can see the wt12 with my bluetooth dongle as a device)

    • Assuming you haven’t made any changes to the WT12’s default configuration, it should be accessible using 115200 baud 8/N/1 port settings. Keep in mind that unless your Atmega’s clock is running at at least 16MHz, you can’t use 115200 baud.

      Connect the WT12 RX pin to the Atmega TX pin, and the WT12 TX pin to the Atmega RX pin, then monitor the data coming into the Atmega’s UART (hopefully you’re using something that makes this easy, like the Arduino IDE). Momentarily connect the VDD and RST pins together to reset the WT12, and you should see the WRAP THOR message.

  3. Hey,
    I am using WT12 interfaced with atmega 32 in my final year project. Can you help me with the code for the same? I have to get my project ready by 28/4/2011 and considering the last minute change from RF to bluetooth it would be of great if I received some help since I can not find anything for WT12 and atmega interfacing over the net.

    • Hi Janet!

      It depends a lot on how you want to use the WT12 modules in your project. Will you be using it simply to send data between the Atmega and the host, like a wireless serial port? Or are you using it as a HID-profile input device connection, or a wireless audio connection? I will email you a couple of documents that may be helpful.

      Jeff

      • hi jeff,
        i am also using wt12 module for comunicating with android device for controling the some power suplies. i am using serial communication for sendind and reciving the data. but in my project i am using spp protocal in android side can you explain how the frame is creating

        • Hi Anil,

          I’m not quite sure what you’re asking, but in the SPP profile mode (which is the factory default setting for the WT12), after a connection is made, each byte sent from the WT12 should be directly sent to the remote device–your Android device in this case. It should work as a simple wireless serial data link, and the data is not altered by the BT module when it is sent or received.

          Jeff

  4. hi jeff i asking help for such that thing …how to development radio frequency by using wt12…..or using wt12 in remote patient monitoring …plz i have not find anything about that….

    • I’m not sure exactly what you’re trying to do, but this case study might help as a starting point:

      http://www.bluegiga.com/solution?g=Healthcare&n=BodyTel

      Bluegiga also has a lot of information on how to use the WT12 in different ways (including heathcare) up on their Tech Forum, which requires registration to access, but it’s free and very easy to register. I would suggest looking there; the only real knowledge I have is on how to use it for a KB/mouse human interface device.

  5. Hi Jeff

    I have connected my WT12 in what I believe is the same way you have shown above. However, I could not manage to communicate via hyperterminal. I decided to check my pin voltages to be sure that my WT12 was connected properly, but when I connect my supply of 3.3V to VDD, I noted that the VDD pins drop to 1.9V?

    my wiring is as such:
    no flow control connected
    pin 28 to ground(common ground from serial port and supply ground)
    pin 26(TXD) to RX of serial
    pin 16 to 3.3V supply
    pin 2 to 3.3V supply
    pin 6(RXD) to TX of serial

    any advice/suggestions would be greatly appreciated as I know I am doing something wrong but I cannot figure it out for the life of me.

    regards
    Justin

    • Hi Justin!

      The voltage drop is definitely odd. It does appear that all of your wiring is correct. Just to clarify before checking other things: you don’t have this connected straight to a serial port on your computer, but instead you do have it through something like an FTDI board or other RS232 level converter, right? I don’t think it works if you plug it right into a hardware serial port.

      Also, I’ve never had much luck with Hyperterminal. Have you tried giving Realterm a shot? COM[whatever], 115200, 8/N/1 should do it. Dealing with opening/closing ports in Hyperterminal just isn’t as easy…though maybe I’m being picky. 🙂

      Jeff

  6. Hi Jeff

    Thank you for replying. I did have it connected directly into my pc serial port, I had no idea that wouldn’t work(this is my first time working with this type of hardware), so that is definately my first mistake. Thank you for the advise, I will look into the FTDI board you have suggested.

    I am still a little concerned about the voltage drop, as it happens even when not connected to the serial port, but I will assess my situation again once I have done what you have recommended.

    Thanks again for your help

    regards
    Justin

  7. Hi Jeff

    I purchased one of your wt12 on full breakout board, set it up today and am extremely happy with it so far, thank you.

    I just have one question. Im not 100% sure how to switch the wt12 into data mode. im using Realterm to communicate with the wt12. I have set it up successfully, but when I try and connect to the wt12 from my phone using a bluetooth chat application, I receive the ‘could not connect’ error. I am under the impression that the module might be stuck in command mode!? I have also set DTR low in Realterm as the datasheet suggests. I only have rx, tx and gnd connected on the serial port. my phone pairs successfully but fails to connect. Unless im mistaken i should be able to transmit data to the wt12 and see the characters appear in Realterm? Do you have any suggestions?

    thank you sincerely in advance for any ideas you may have.

    • Hi Sheldon!

      I’m glad you like the board. The WT12 can be switched into data mode using the SPP (serial profile) only by a successful pairing and subsequent opening of a connection from the host. What you should see is a “RING 01:23:45:67:89:AB” event that shows up on the WT12’s serial output, and once that happens, then the data can start flowing. If you don’t see that show up first, then the host device (your phone) is not actually opening the connection.

      I’ll email you some more info about the iWRAP protocol for reference in a moment.

    • Nevermind about sending the files…the email I sent bounced. You can sign up for Bluegiga’s tech forum for free here:

      http://www.bluegiga.com/support

      There is a lot of very helpful info on their modules and the iWRAP protocol. Check out the iWRAP User Guide and the SPP Application Notes for what will be most applicable to your situation.

  8. Jeff- I purchased two BlueGiga WT12A BT modules with breakout board and I was successfully able to connect it with my iPhone and Arduino Nano via Serial port. However, I want to simulate keystrokes (e.g., Spacebar, Cursor UP arrow), but when I send the Usage IDs (e.g.,Serial.print(0x04)) from Arduino to WT12, the data is transparently sent to the iPhone (i.e., the iPhone Notebook app writes 0x04 instead of alphabet a, which is the HID usage ID). The documentation states that I can send multiple keystrokes via a RAW mode.

    Would you have any suggestions how I could switch the BT module to RAW mode or simulate keystrokes by sending Serial commands from the Arduino to the WT12 module.
    Thanks much for your help!
    PK

    • Hello PK!

      The RAW HID report requires a special format in order to be interpreted as such. Fortunately, you don’t have to switch modes in order to use it; just send the bytes in the format required. iWRAP4’s packet structure for this purposes is a 12-byte set:

      [0x9F]
      [0x0A]
      [0xA1]
      [0x01]
      [0x??] <- modifier key byte (0 for no modifiers)
      [0x00]
      [0x??] <- key #1
      [0x??] <- key #2
      [0x??] <- key #3
      [0x??] <- key #4
      [0x??] <- key #5
      [0x??] <- key #6

      Remember that with RAW mode, you have to specifically send both the "press" and "release" reports. To release any key, just set that key byte (or modifier bit) to 0 in the report packet.

      That should do it!

    • Hi PK – I noticed you were successful in pairing the WT12 with your iphone via ssp – can you tell me what iwrap settings you used to accomplish this?
      Thanks,
      Jeff

      • Actually you can’t do it via SSP as far as I know. The only way I was able to get it to connect was to use HID mode, with BT CLASS set to 00540 (keyboard only). The 005C0 setting (mouse + keyboard) makes it invisible for some reason. I don’t think you can do a pure serial Bluetooth connection unless you have a bunch of expensive Apple hardware and licensing…which is pretty lame.

  9. Jeff- Thanks a lot for your quick response– it was very helpful! I am still struggling to send a keystroke, i.e., when I send Serial.print(0x04), it prints 4 on the screen as opposed to alphabet ‘a’ that corresponds to the HID usage ID 0x04. I think I am going to experiment a bit and figure out what the correct command it. I know you are not supposed to act as free support, so I do appreciate the time you took to respond! Thanks- PK

    • You’re welcome! I’m happy to help. If you’d like to send me a copy of the particular part of your code that is trying to send code, feel free to reply the email that I sent. You can also check out this code for reference:

      https://github.com/jrowberg/iwrap/blob/master/iWRAP.cpp#L1403

      The iWRAP::send_now() method shows the byte output order for a raw keyboard HID report using iWRAP. The “uModule -> write()” calls are the same as “Serial.write()”, just using a different object structure. The concept is the same.

  10. Jeff- You are super! I used Serial.write() instead of Serial.print() and everything came together. It now works. I’ll give you an update once I finish my project :)!. Thanks much!

  11. Hey Jeff,

    I’ve been following your bluetooth progress for a few hours now, awesome to reach this post and find you have finally had success! I’m interested in getting one of your small breakout boards to implement Bluetooth in a an old gaming controller. Please tell me, aside from wiring up the 3.3v power supply, what else will I need to make this game pad to interface with my computer? Is this a situation that will require an Arduino type micro controller or can I just connect the button leads to the breakout board and configure the firmware accordingly?

    Please excuse the noob questions, but I am truly a noob at this!

  12. hi jeff.I need help regarding WT module connection and data transfer and firmware update through UART.I came to know DFU(device firmware update)method which requires a tool and i’m having no idea whether it has to connect it to the pc (or)i can operate wireless.Please suggest Don’t know how to proceed.

    • The SerialDFU tool must use a direct wired connection to the module’s UART pins (using a SparkFun FTDI board or other RS232 level converter). As far as I know, you can’t update the firmware wirelessly.

      You can download the tool, firmware releases, and PDF guides for free from Bluegiga’s support website:

      http://www.bluegiga.com/support (free account required though)

  13. Hey, How to change the WT12 Modules baud rate to 9600?

    • To do that, once you are connected to the WT12 at whatever its current baud rate is, issue the following SET command:

      SET CONTROL BAUD 9600,8N1

      Changes take effect immediately and persist through resets, so you’ll have to change your connection settings to match right away.

  14. Hi Jeff. I’m building a Bluetooth broadcasting station using WT12. The thing is that I’m using 3 modules and they’re giving me a bit of a headache; they interfere with each other. I can only have one module send at a time. Is there a solution to have all 3 send modules send data simultaneously without interference?

  15. hi jeff ;
    i am using bluegiga WT12 i had used it on my project but now i forget the passkey . and now i want to add more devices . what to do now to change passkey .
    please reply soon .

    • Hi i am trying to develop connection between wt12 bluetooth module and android phone but i got error
      NO CARRIER 0 ERROR 311 SDC_NO_RESPONSE_DATA
      kindly help me out plzz its urgent

  16. Hi Jeff,

    Can WT12 do transfer a file to computer from a SDcard connected with microcontroller? if yes, do you know how to do that? Thanks in advance.

  17. Hi i am trying to develop connection between wt12 bluetooth module and android phone but i got error
    NO CARRIER 0 ERROR 311 SDC_NO_RESPONSE_DATA
    kindly help me out plzz its urgent

  18. Hallo Jeff,
    Can you give me some hints about my problem. I can successfully connect to WT12 and communicate with iWRAP5 on it… My goal is to enable HID protocol (via bluetooth of course) between WT12, my device (4 buttons and touch-pad) and mobile phone. I have certain c8051f340 microcontroller to bridge the connection between buttons and touch-pad and WT12. The problem is when I send some data via UART (TX and RX pins) to the WT12 nothing happens. Okay, the reason for that can be anything and you can not help me there. But could you sum up for me the procedure for enabling HID protocol? Okay, not sum up, just give me some hints? What are the things I need to do in my c program so that I can establish such a protocol. I am newbie when HID protocols are about. If you have any kind of code or something like that.
    Thank you,
    Krcevina

  19. Jeff i really need your help on this wt12.

  20. After checking out a few of the blog articles on your web site,
    I really like your way of writing a blog. I saved
    as a favorite it to my bookmark site list and will be checking back soon.
    Please visit my website too and let me know what you think.

  21. Hi Jeff,

    I recently bought BT_PRO module which is Bluegiga WT12 and Waspmote from Libelium for my project. I am developing an android bluetooth app, which should connect to this BT_Pro module that is connected to the waspmote. When I try to connect with other BT_pro module which is connected to gateway, it is fine, but when I try to pair with my phone, it is asking for pin code. I tried with different pins, but could not be successful. I sent commands manually from Waspmote like “SET BT AUTH * {PIN CODE}” and “SET BT PAIR…”, i could not pair after that too. can you please provide me what are the correct AT commands need to be sent to WT12 for pairing and when the commands need to be sent, before or after creating connection.

  22. Hello,
    I have an MPU9150 and a dsPIC with WT12. Right now I am polling the PIO6 pin of WT12 to initiate a data transfer and am using an ASCII character to identify the start of the data transmission. How does the RTS and CTS of WT12 can be used to initiate and stop a data transfer/ or can it be done in a much better way ?

    Thanks in advance 🙂

Leave a Reply