Using the BlueSMiRF

Contributors: jimblom
Favorited Favorite 12

Connecting From Another Device

In the example code section we attempted to connect to a device from the Bluetooth modem, but what if you wanted to initiate the connection from another Bluetooth device? This process varies by operating system and device, but most of the steps involved are pretty similar.

If your device (computer, phone, etc.) doesn't already have an Bluetooth modem, you'll need to connect an external module to it. The Bluetooth USB Module works for any computer with an available USB slot.

Connecting to the Modem in Windows

Go to the Control Panel and navigate to the Devices and Printers window. In the top-left section of that window, there should be an Add a device button. Click that.

Add a device window

When the Add a device window opens your computer's Bluetooth module should automatically search for any in-range, available Bluetooth devices. Those it finds should show up in the window (give the window a few seconds to search).

If you see your device in this window, double-click it to initiate a connection. You'll then be presented with the Select a pairing option window. Since the modems don't have an attached keypad, select the Enter the device's pairing code option.

Pairing options menu

On the next window, enter 1234 as the PIN code. This is the default PIN value for every RN-42 and RN-41.

Entering the PIN code

Windows will take a few moments to install drivers for your device. Once it's done, it'll pop up a notification to let you know that your device is ready to use!

But how do you actually use it? You'll need to open up a terminal emulator (check out our Serial Terminal Basics tutorial for help!). When Windows installed drivers for your new Bluetooth device, it created a new COM port for it. Opening up your device manager, and looking in the "Ports (COM & LPT)" tree, you'll find a new port named "Standard Serial over Bluetooth link (COM##)" (there may be two of them).

Device manager

To open up a connection between the Bluetooth devices, open up a terminal to that COM port at 9600 bps (8-N-1). (If you see two ports, try the lower number first). When the terminal opens up, your Bluetooth modem's green connect LED should light up. Connection successful!

If you have the sketch from the last example (the serial passthrough) still loaded up on your Arduino, you can open up a second terminal window to communicate between devices.

Bluetooth communication example

If you're within the config timer window (cycle power on the modem if you're not), you can even remotely enter command mode by sending the "$$$" string. Now you can remotely alter the settings of your Bluetooth modem. Nifty!

If your using a Mac, Linux, or even a smartphone, pairing and connecting should involve a similar process. If authentication is required, you'll want to use the PIN-code option, and enter the default PIN of "1234". Open up a serial terminal emulator -- Terminal or CoolTerm on Mac OSX, a variety of apps are available for smartphones -- to initiate the connection and start passing data.