Once you have your RPi paired with another device you have a Bluetooth link, but you still need to set up another protocol over the Bluetooth called "RFCOMM" to provide an emulated serial connection between the two devices.

Setting The RPi to create a serial connection to a Bluetooth device at startup

Enter the command:


sudo nano /etc/bluetooth/rfcomm.conf

Add the connection details:


rfcomm1 {
    # 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 "My Bluetooth Connection";
}

Creating A Serial Link Via Bluetooth To A PC Running Windows

Follow the RPI steps to setup the rfcom link at its end.

Open the Windows Control Panel.  In search box, type "Bluetooth", and then click "Change Bluetooth settings".

In the Bluetooth Settings dialog box, click the COM Ports tab, select a port, and then click OK.  If no COM port is listed, then setup Windows to accept a connection by pressing "Add", and then select "Incoming".  OK and exit.  Windows should then see the RPi serial connection after a few seconds and create a serial port automatically for it (you see a taskbar message its happened and the new COM port appears in device manager).

Adding The RPi From Windows

In Devices and printers use 'Add Device' and if the RPi is in pairing mode it should find the RPi.

Once the device is added and windows has finished adding drivers (can take quite a a while – wait for the taskbar device added message), right click the RPi in device and select properties.  In the 'Services' tab there should be a servicee for serial, e.g. 'serial port SSP'.  Ensure it is enabled.  If there isn't then there is likely a problem. <<< We got stuck here and had to give up due to time constraints as this was the case for us

Send serial from the RPi command line


echo "Hello" > /dev/rfcomm0

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

  1. Shayan Shiri

    7 years ago

    is it possible to use this command to connect to two bluetooth devise in the same time

    rfcomm0 {
    # Automatically bind the device at startup
    bind yes;

    # Bluetooth address of the device
    device yy:yy:yy:yy:yy:yy;

    # RFCOMM channel for the connection
    channel 1;

    # Description of the connection
    comment “My Bluetooth Connection”;
    }

    rfcomm1 {
    # 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 “My Bluetooth Connection”;
    }

    1. paula

      3 years ago

      can you tell me if this worked? because I’m trying to connect two devices to the pi simultaneously

  2. Andrew Chandler

    7 years ago

    I’d love to see a tutorial on how to do it the other way around on a RPI3 with built in bluetooth. The goal is to connect to a headless pi from my android phone/tablet and pull open a terminal on the pi. Doesn’t have to be serial if I can figure out how to do it with ssh and a bluetooth network between the phone and the pi.

    1. Theodore Swanson

      3 years ago

      For that I suggest using Realvnc, which is built in on Raspbian and will work on android.

    2. Jan Bergner

      2 years ago

      I have done this with bluetooth NAP and do a roll-out to all my pis.
      In any case, it is much easier to do this, now, than it was 5 years ago.

      You are free to use my ansible role that will do the setup for you, but it is still work in progress:
      https://gitlab.com/jbergner/pi-bluetooth-groupnet

      (Don’t get irritated by the name “groupnet”. This is what I got to work before I managed to set up NAP, which will work with an android phone.

      Currently, I am working on the other direction. So I would specify the Android’s MAC and the pi would auto-connect.

      Furthermore, there is no pairing security, yet.

      If you have any questions on how to use the role, please contact me on gitlab!

Comments

Your email address will not be published. Required fields are marked *