Dragon12
Posts: 57
Joined: Thu Jul 18, 2013 10:33 am

Sending a digit via Bluetooth

Fri Nov 24, 2017 11:26 pm

Thank you for reading this.

I've created a simple Arduino sketch that sends data via Bluetooth to control an LED. I use Blueterm on an Android tablet to send a 1 or a 0. I'd like to do the same thing with my Raspberry pi.

After some Internet searching I find that I need to have /dev/rfcomm to either listen for or send data. However, after I've paired with my HC-05 Bluetooth module I'm informed that even though the pairing has been successful there are no services for that device. Also, /dev/rfcomm has not been created.

My aim is to to use Python to control the LED. I see that there are several Bluthooth libraries available but I'm not sure which one I need for the simple task that I have in mind.

Any suggestions will be greatfully appreciated.

User avatar
Ronaldlees
Posts: 293
Joined: Sat Apr 16, 2016 4:28 pm
Location: North Carolina, US
Contact: Website

Re: Sending a digit via Bluetooth

Sat Nov 25, 2017 7:26 pm

Is it really an HC-05? One poster has reported (possibly) getting HC-06 instead of HC-05 since the package is very close to identical, by mistake:

http://www.seeedstudio.com/forum/viewto ... =45&t=5817
I am the Umbrella man: IR3/IR5 UV a/b/c OTS specs: break free, live life. Note that red cannot be seen with IR lenses, so cross at stop lights only on white walk signals, don't drive or operate machinery with lenses on, and don't use in low light.

User avatar
Douglas6
Posts: 4370
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Sending a digit via Bluetooth

Sat Nov 25, 2017 9:12 pm

See If these instructions for setting up the Serial Port Profile on your Pi are helpful: viewtopic.php?p=947185#p947185

Dragon12
Posts: 57
Joined: Thu Jul 18, 2013 10:33 am

Re: Sending a digit via Bluetooth

Sat Nov 25, 2017 10:02 pm

Thank you for your reply, I didn't really expect to get any replies because of the vagueness of my question.

Yes, the module is definitely an HC-05 and it works perfectly with Blueterm. Since posting my question I have discovered bluez for python3 but I haven't advanced any further.

Dragon12
Posts: 57
Joined: Thu Jul 18, 2013 10:33 am

Re: Sending a digit via Bluetooth

Sat Nov 25, 2017 10:25 pm

Thank you Douglas6 for the link.

Since my previous post I have discovered bluez-utils and I now see how to send data via /dev/rfcomm.

User avatar
Douglas6
Posts: 4370
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Sending a digit via Bluetooth

Sat Nov 25, 2017 10:48 pm

Gosh, bluez-utils. You must be slightly behind on OS system updates. :D

Dragon12
Posts: 57
Joined: Thu Jul 18, 2013 10:33 am

Re: Sending a digit via Bluetooth

Sat Nov 25, 2017 11:53 pm

Thank you again douglas6 and Ronaldlees for your replies,

Early in my quest for knowledge I discovered that bluez-utils is not included in the repositories for the Linux distribution that I use on my laptop, either is bluez for python3. However, bluez-tools is included and it probably contains the same functions. I do know that bluez-utils and bluez for python2 are include in the Raspberry pi repositories.

Knowing that Linux forums, in general, are decidedly unhelpful I therefore posted my question to the more friendly Raspberry pi forum instead. Now all I have to do is put the newly discovered information to use.

User avatar
Douglas6
Posts: 4370
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Sending a digit via Bluetooth

Sun Nov 26, 2017 1:52 am

Best of luck. bluez-tools has no relationship with bluez-utils. I'm afraid I have no idea what you mean regarding 'bluez for Python'.

bluez-utils has not been in the Raspbian repositories for quite some time, leading me to believe that you are running an old version of Raspbian.

Dragon12
Posts: 57
Joined: Thu Jul 18, 2013 10:33 am

Re: Sending a digit via Bluetooth

Sun Nov 26, 2017 4:25 am

Here's something, Douglas6, that you may be able to help me with.

"hcitool scan" returns the MAC address of my bluetooth module and from that it appears that it's a simple chore to then send to or receive data from the module. The problem is that I cannot see how to create /dev/rfcomm0. From what I can determine it appears to be an automatic process just like /dev/ttyUSB0 is created when a USB device is connected but I seem to be missing something. Also /etc/bluetooth/rfcomm.conf does not exist; /etc/bluetooth does .Any ideas?

User avatar
Douglas6
Posts: 4370
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Sending a digit via Bluetooth

Sun Nov 26, 2017 4:43 am

You need to communicate through rfcomm. It will create a /dev/rfcomm0 device when it connects to your remote device. You'll need to have the SPP running, and rfcomm listening or actively connecting to the remote device.

Enable the SPP on the Pi, as I previously stated. That will get you much closer.

Dragon12
Posts: 57
Joined: Thu Jul 18, 2013 10:33 am

Re: Sending a digit via Bluetooth

Sun Nov 26, 2017 9:23 am

If anyone is interested, disregard ALL of the above information. The trick is to use bluetoothctl and once rfcomm0 is created either send to or receive data from the bluetooth module with cat or echo or use /dev/rfcomm0 as a serial device under python.

I have no idea what I might do with this information, perhaps it will be useful one day.

Return to “General programming discussion”

Who is online

Users browsing this forum: No registered users and 4 guests