Seeed BlueTooth shields and Linux

This is an expansion of an earlier article originally published at
http://www.seeedstudio.com/forum/viewtopic.php?f=23&t=4586&sid=d813605d07038d3b3593f48e9587a682

After some struggles, we have managed to get an Arduino with the Seed SLD63030P BlueTooth shield:

http://www.seeedstudio.com/wiki/index.php?title=Bluetooth_Shield

and a Linux host to pair up and pass serial data between them. Details follow, since we could not find this detailed process documented anywhere else:

The host computer was OpenSuSE 12.3 32 bit, with Arduino 1.0.2 with the Seeed Studio BT shield plugged in to a Uno. We used a Targus ACB75AU Bluetooth/USB adapter from Harvey-Norman and also tested OK with a Digitech Bluetooth/USB adapter from Jaycar.

The Uno was loaded with the BlueToothShieldDemo Slave sketch, downloaded from Seeed:

http://www.seeedstudio.com/wiki/images/3/30/BluetoothShieldDemoCode.zip

Caution: you need to modify this version of the sketch to make it compile with Arduino 1.0: replace 2 instances of “NewSoftSerial” with “SoftwareSerial”

Steps:

Power up the Uno with the Seeed BT shield and BlueToothShieldDemo slave sketch installed, observe alternate red/green flashing lights on the BT shield. Open the Arduino IDE serial interface to the arduino port, see a startup message:

The slave bluetooth is inquirable!

Insert the BT/USB adapter into the OpenSuSE host. Observe that the Bluetooth icon appears in the dock.

If you open the Bluetooth icon in the dock dock, and select Add Device, a window will open: you should see the name of your BlueTooth shield (SeeedBTSlave) appear there. Dont bother trying to connect that way though, cause it wont work.

Instead open a shell terminal as root.

First, you need the MAC address of your BlueTooth shield. Enter the command:

zulu:/home/mikem # hcitool scan
Scanning ...
    00:13:EF:00:06:80       SeeedBTSlave

Here, 00:13:EF:00:06:80 is the MAC address of the shield you wish to connect to. To pair with the shield, enter the command:

rfcomm connect rfcomm4 00:13:EF:00:06:80 1

(where 00:13:EF:00:06:80 is the MAC address of your shield)
Observe:

Connected /dev/rfcomm4 to 00:13:EF:00:06:80 on channel 1 
Press CTRL-C for hangup

A popup window will appear in the dock from the Bluetooth icon, saying that the device has been paired, and containing a button that says “Intro..”. Click on this button (do it quick; the icon only appears for about 10 secs), you can then enter the PIN for the bluetooth shield (default ‘0000’).

A new device /dev/rfcomm4 will be created, which is connected to the shield and sketch. The Arduino will print some state information to its serial port:

+BTSTATE:3
CONNECT:OK
+BTSTATE:4

Pairing is now complete.

On the Linux host, connect a serial comms program to the new device /dev/rfcomm4, your preference, minicom, cutecom etc. We used cutecom. Select /dev/rfcomm4 as the device to open. Baud rates etc are irrelevant, but we used 9600 8N1.

Now when you Input text in your cutecom terminal it will appear on the Arduino serial output, and when you use the Arduino line input in its window, the text will appear in your cutecom terminal. This proves two-way serial communications between Linux and the Bluetooth equipped Arduino.

Other helpful information:

http://www.piaccess.com/trac/wiki/Linux_BlueZ_Bluetooth_Serial_Setup 
http://www.heatxsink.com/entry/how-to-pair-a-bluetooth-device-from-command-line-on-linux 

Comments are closed.