Adrián Yanes

01100110011100100110010101100101011001000110111101101101

Archive for the ‘arduino’ Category

Changing the baudrate of BlueSMiRF Gold through Bluetooth in GNU/Linux

leave a comment

One of the most popular Bluetooth modules for Arduino is the BlueSMiRF Gold (T9JRN41-1), despite its easy integration with Arduino to perform basic operations such as receiving or sending data, some use cases can require a deeper configuration of the module.

To configure the BlueSMiRF Gold module with a normal RS-232 cable is trivial but awkward, you need to have the cable, to solder/connect it to the pins, etc; however the RFCOMM protocol (a.k.a emulated RS-232 over Bluetooth) can save us time is this task.

The default serial configuration of the module is:

• Baud rate 115,200
• 8 bits
• No Parity
• 1 stop bit
• Hardware flow control enabled

Knowing this, you just need to have a machine with GNU/Linux and a bluetooth device. The easiest way to check this is to execute:

hciconfig

It should show you the bluetooth interface of your machine, together with its MAC address, status, RX & TX stats and so on.

Once we verified our machine has available the interface, we need to check the MAC address of our  BlueSMiRF Gold module; let’s assume it is:

00:06:66:08:XX:ZZ (replace this for your own MAC address)

Now let’s connect to the BlueSMiRF Gold module through RFCOMM:

sudo rfcomm connect 0 00:06:66:08:XX:ZZ

After it connects, two things should happen:

-Your BlueSMiRF Gold module shows a green light
-Your machine’s console outputs the following:

Connected /dev/rfcomm0 to 00:06:66:08:XX:ZZ on channel 1
Press CTRL-C for hangup

Now this will provide us access to the /dev/rfcomm0 interface.

The easiest way to communicate now with the module as you would do it using RS-232 is through screen or minicom, for instance:

sudo screen /dev/rfcomm0 115200

You need to have in consideration that you have 60 seconds to connect to the module before it changes its operational mode. It means that after the execution of “sudo rfcomm connect 0 00:06:66:08:XX:ZZ” you must be fast executing the “sudo screen /dev/rfcomm0 115200” command. If you performed properly the mentioned steps, another led in the module will start blinking in red colour.

When you connect to the module, the first thing you must type is “$$$” and press enter, it should show you “CMD“, after that you can execute any of the AT commands available in the manual of the BlueSMiRF Gold module.

For instance to change the default baud rate of the module (115.200bps) to 9600bps will be:

$$$
>CMD
SU,96
>AOK

Note the manual specify the following concerning baud rates:

SU,<rate> Baudrate, {1200, 2400, 4800, 9600, 19.2, 28.8, 38.4, 57.6, 115K, 230K, 460K,
921K }, only the first 2 characters are needed.

Example: SU,57 sets the baudrate to 57600 baud.

The other AT commands follow similar logic, you can check them in the vendor’s manual.

Written by Adrián Yanes

julio 19th, 2012 at 11:50 pm