Saturday, January 17, 2009

Getting started with Arduino and BlueSMiRF Siver


Since I had to do a lot of experimenting with my brand new BlueSMiRF Silver I thought writing something for future reference.



The first thing to note is the wiring of the two devices. As you can see the pin labeled as TX of the BT module is connected to the RX pin of the Arduino. This is pretty straightforward if you say "The Arduino receives what the BlueSMiRF transmits."



The second thing I want to mention is that the one that Sparkfun ships differs in the default configuration from the information that the "data sheet" says. I could communicate with mine using 9600 baud rate.



On the GNU/Linux part I used Tony Buser's instructions on how to create a serial device (/dev/rfcomm0) that can be used easily.

First use hcitool scan to detect your BlueSMiRF, then create a config file /etc/bluetooth/rfcomm.conf containing something like this



rfcomm0 {
bind yes;
device xx:xx:xx:xx:xx:xx;
channel 1;
}


Now you will be able to say like tail -f /dev/rfcomm0 to see what is your Arduino telling.



An other cool thing is that you can use a software serial library to debug the bluetooth module. I used Ladyada's AFSoftSerial library. Connecting the BlueSMiRF to pin 3 and 4, you can use the USB to print debug info.



This setup also can be used to configure the module with the AT command set available (see the "data sheet"). I have a little Python script command.py, that can be used with the command application for configuration. You can enter the commands on your pc and read the response of the module:



>> +++
OK
>> ATI
1SPP - Vr: 1.2.5
OK
>> AT+BTLNM="something else"
OK
>> AT+BTAUT=1, 1
OK
>> AT+BFLS
OK


This set of commands will set the name of your module to something else, enable Automatic Connection Mode, that will be saved to Flash, and these settings will be saved permanently to Flash.

2 comments:

artatwork said...

Hi peter
Can u tell me circuit 4 connecting to pc,Rx of bluesmirf to tx of pc and tx of Bsmirf to rx of pc or its vice versa. I tried both but no response

Peter said...

rajesh,

You can not connect this device directly with a pc, you need a RS232 to TTL converter circuit.

Sorry for the slow response.