Pages

Wednesday, August 24, 2011

After receiving some emails from a few readers, I have decided to also sell some of my boards on eBay. I understand that this might be a more comfortable and care-free way of buying my boards. Currently I have posted a DEV.BO and will be posting some others soon (the list below will be updated as I post boards). If this works out well I will add other boards to my eBay account. Also, I will probably forget to remove the links when the items end; keep that in mind.

Monday, August 8, 2011

Most projects which I have seen input and output some sort of data: be it a multimedia stream, sensor data, or user inputs. In this post I will discuss how to easily make your project Bluetooth enabled. For hobbyists and professionals alike one of the most important aspects of any design is cost; in my own project I had three requirements for a Bluetooth Module, low cost, low size, and very easy to use.

The RN-42 module, which is available at SparkFun electronics and Mouser, is a very cheap and simple way to use Bluetooth in your project. The best part about the RN-42 module is that it has an integrated antennae and contains everything needed for the Bluetooth protocol. You would be surprised how many modules require a special external microcomputer that contains a Bluetooth stack to operate.

For how great the module may seen, there are a multitude of downsides. The first is not such a big deal and might not even be a downside for you. The device is in a surface mount package. For those of you who are not making your own PCBs, you can buy one at my online store and be done with it. For those of you on a budget, it is possible to solder wires onto each pad of the RN-42 even though I would not recommend it. The last, and my favorite solution, is to just make a custom PCB for your project and solder on the module yourself. The picture below is of a custom breakout board I made to evaluate the module. The schematic is shown later in this post.

My custom breakout board for the RN-42.

The other negative aspects of this module are its size and maximum baud rate. The module is a little bigger than I would like, but still reasonably small. The device also draws a bit more power than I would like, but all things considered it is not too bad for being a Bluetooth module. What bothers me the most about this device is that the maximum baud rate is very very low. I will discuss this in more detail after I show you how to integrate this device into your project.

The easiest way to send and receive data using this Bluetooth module is to use a UART connection. The first schematic below, which is based off of the datasheet and example schematic from SparkFun, is how I connected the module to my project.

A complicated example for hooking up the RN-42 to the MSP430F5510.

This shows how to connect the RN-42 to an MSP430. Please note that this is just an example and that it is much more complicated than the bare minimum; see the next schematic for the bare minimum needed. The first and most important thing I want to mention is that the device requires a supply voltage between 3V and 3.6V. Luckily I use 3.3V for most of my projects which is perfect for this module.

My custom breakout board for the RN-42

The figure above shows the schematic for the breakout board which I used for evaluating the device and shows what kind of connections the module needs in order to function properly. After testing the device thoroughly it was obvious to me that the device is so simple to use that I could have put it in my project right away. The range is quite good and the device is very reliable when using a baud rate of 115200.

Connecting

Hopefully by now it is clear that from the hardware side of things only a UART connection is needed between the Bluetooth module and your MSP430. What about from the other side of the data stream? The computer. Linking the module to the computer was surprisingly easy. On Windows 7 (I can’t speak for any other OS or version of Windows), it was plug and play. Within a few seconds the drivers were automatically installed and I could see which COM port the module was connected to in the device manager.

The device manager showing the RN-42 connected as COM6.

As I mentioned before, my terminal program of choice is Realterm. The first test I recommend completing when setting up the module is a simple echo test. Connect the RX and TX pins on the module together, then set the COM port to the correct port and the baud rate to 115200 baud in your terminal. Once everything is set up and the power is on, wait for the device to connect. If you have the status LEDs connected to the module (which are optional if you are worried about power consumption), the LED connected to PIO2 should turn on when the module is paired with the computer. The other status LED will blink if the device is not connected. Once connected, type a few characters in the terminal and you should receive back every character you typed into the terminal.

Note: If you are running off of a battery, which you probably are given that this is a post about Bluetooth, you will run into connection issues when the battery is getting low. The module will still turn on and the LEDs will still blink, but you will not be able to reliably connect. If you are having connection issues, check your battery.

That should be all that you need to know in order to add Bluetooth to your project. If you think there is something I have missed, let me know and I will add a section to this post.

Commands?

Yes, this module can accept commands which allow the user to change some important settings. I will not be discussing these commands in this post. You can find all the information you need on this topic in the Roving Networks User Manual.

Baud Rate Trouble

As I mentioned earlier I want to discuss the problems I have with the data rate of this device. My frustrations really arise from false claims on the specifications of the device from both the manufacturer and vendors.

The quotes above show where my frustrations originate. To be honest, I am not really sure where SparkFun got their numbers; if I am missing something, please point it out to me. To make things clear, this device really only functions in SPP mode, thus you have a max data rate of 240Kbps if the device is in slave mode. I'm not even sure if it's possible to put the device in HCI mode, apparently it must be done at the factory.

So the datasheet is clear about the max speeds in each mode, but I am frustrated that they do not make it abundantly clear that the device cannot work in HCI mode. I emailed Roving Networks inquiring about this dilemma I was having (I wanted to use 921600 baud sustained over the air) and though they were friendly, prompt, and reasonably helpful, I was/am not happy with how misleading their datasheets are.

“The HCI mode is a special build of firmware the needs to be programmed at the factory.” “Please understand that in HCI mode, the bluetooth stack is running on the external host processor and the module is acting as a radio.” All in all, I do commend them on their customer service, just keep in mind that realistically speaking, you will only be able to use SPP mode.

Conclusions

Despite my frustrations, this is a great solution for making your project wireless. I have found very few chips or modules that can be integrated into a project with such ease. I hope this post helps a few people successfully add Bluetooth to their projects. There are so many cool possibilities for projects when using Bluetooth; the possibilities are endless! Who wouldn't want to hook up a project to an Android phone?