Go Down

Topic: bluetooth (Read 2230 times) previous topic - next topic

rainerunsinn

Hey,
I bought myselfe an arduino bluetooth shield. http://imall.iteadstudio.com/im120417010.html

I tried to communicate with my pc via the following code:
Code: [Select]

void setup()
{
  Serial.begin(9600);
}


void loop()
{
if (Serial.available())
  {
    Serial.write("Incomming");
  }
Serial.write("HELLO");
}


I had paired my pc with the arduino bluetooth and connected the bluetooth of my pc to /dev/rfcomm0

But I see no income and no outgoing. What am I doing wrong?

PaulS

Where did you put the jumpers?

rainerunsinn

#2
Jan 13, 2013, 07:30 pm Last Edit: Jan 13, 2013, 07:32 pm by rainerunsinn Reason: 1
I let them at the default position.

rx is at 0 and tx is at 1.

cbagz

Try 38400 Baud rate, and is your switch to CMD or DAT. 

rainerunsinn

#4
Jan 14, 2013, 06:17 pm Last Edit: Jan 14, 2013, 06:28 pm by rainerunsinn Reason: 1
Hey,

thank you for your answer. I tried it with 38400 Baud, but nothing happened:-(
my switch is at DAT, when I set it on CMD I can't find the shield with my computer.

I also tried it with software serial:
Code: [Select]

#include <SoftwareSerial.h>
SoftwareSerial ss(6,7); //I set the jumper for rx to 6 and tx to 7
void setup()
{
  ss.begin(9600);
}
void loop()
{
  if(ss.available())
  {
     ss.write("Incomming");
  }
}

But this neither worked.

Cue2

can you elaborate on how you have set up your linux machine and how you listen for incoming data on rfcomm0?

Does it make a difference if you use Serial.print("Hello") instead?

rainerunsinn

Hey,

I used blueman to connect the shield to /dev/rfcomm0
Then I used cat /dev/rfcomm0 to listen and echo hello > /dev/rfcomm0 to send.
Serial.print("Hello") and Serial.write("Hello") don't make a difference.


Cue2

#8
Jan 29, 2013, 03:52 pm Last Edit: Jan 29, 2013, 03:54 pm by Cue2 Reason: 1
I don't know what the problem could be, far too many things could be wrong and without being able to see how your linux box or shield is set up it's hard to say. when you type "rfcomm" at the command line does it show your bluetooth device?

Code: [Select]
rfcomm0: xx:xx:xx:xx:xx:xx channel 1 closed


where "xx:xx:xx:xx:xx:xx" is the address of your particular bluetooth shield?

rainerunsinn

Hey,

when I enter: rfcomm
I get this information:
Code: [Select]
rfcomm0: 00:23:4D:E5:7F:0F -> 00:12:11:12:06:48 channel 1 connected [reuse-dlc tty-attached]

Cue2

Do

Code: [Select]
cat /etc/bluetooth/rfcomm.conf

and post the output.

My one looks something like this:
Code: [Select]
rfcomm0 {
         # Automatically bind the device at startup
         bind yes;
         # Bluetooth address of the device
         device xx:xx:xx:xx:xx:xx;
         # RFCOMM channel for the connection
         channel 1;
         # Description of the connection
         comment "Arduino";
}


again where "xx:xx:xx:xx:xx:xx" would be the address for your particular bluetooth shield.

rainerunsinn

#11
Feb 12, 2013, 06:12 pm Last Edit: Feb 12, 2013, 06:21 pm by rainerunsinn Reason: 1
Hey,

my rfcomm.conf was commented out, so I edited it like yours, but it is still not working.
It looks like this:
Code: [Select]
rfcomm0 {
# Automatically bind the device at startup
bind yes;

# Bluetooth address of the device
device 00:12:11:12:06:48;

# RFCOMM channel for the connection
channel 1;

# Description of the connection
comment "arduino";
}

Cue2

OK lets do things manually, do not rely on blueman. remove any pairing there. Then do

   
Code: [Select]

    $ sudo sdptool add SP
    $ sudo /etc/init.d/bluetooth restart
    $ sudo rfcomm bind all
    $ rfcomm


you should see
Code: [Select]

rfcomm0: xx:xx:xx:xx:xx:xx channel 1 clean


then
Code: [Select]

cat /dev/rfcomm0

open another terminal and do
Code: [Select]
echo Hi > /dev/rfcomm0

let me know if you don't get a response in the first terminal.

rainerunsinn

Hey,

no I don't get a response :~

Cue2


did you see exactly this when you did rfcomm?:

Code: [Select]
rfcomm0: xx:xx:xx:xx:xx:xx channel 1 clean

(without xx:xx... of course ) Make sure you didn't get something else. It would be nice to see a complete copy of your terminal output while you are doing these things too. It's difficult to diagnose a problem without knowing what exactly happened.

Do
Code: [Select]
$ sdptool browse local


You should find something like this in the output

Code: [Select]

Service Name: Serial Port
Service Description: COM Port
Service Provider: BlueZ
[...]
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
  Channel: 1


then do

sdptool records xx:xx:xx:xx:xx:xx

(with your BT shield address)
you should see something like

Code: [Select]
Service Name: SPP
[...]
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1


make sure all the channel numbers match each other and your rfcomm.config file. Also make sure your cat and echo commands output file name match the actual rfcomm. e.g make sure it isn't >/dev/rfcomm0 when your shield is on rfcomm1.

If that still doesn't work then I've ran out of ideas, maybe your bluetooth shield is faulty.

Go Up