Raspberry Pi 3 provides a built-in Bluetooth module. The latest Raspbian has been bundled with tools for enabling Bluetooth connection. The Bluetooth icon will be shown up on the top right corner of the desktop. It's a tool to discover available Bluetooth devices and connect Pi with Bluetooth devices. It is easy to connect any Bluetooth-enabled electronic device with Pi. But, sometimes Pi will fail to connect, especially for Bluetooth device that has no standardized services.
From a terminal, we can use the
From a terminal, we can use the
bluetoothctl
tool to scan and connect with a Bluetooth device. You should make sure that the BlueZ protocol stack has been installed by running $ apt-get install bluez
- Run
bluetoothctl
to enter the tool command window - Turn the power on by running
power on
- (Optional) You can set
AutoEnable=true
in/etc/bluetooth/main.conf
if you want to make the Bluetooth auto power-on after reboot. - Run
devices
to see which devices have been paired - Run
scan on
if your desired device has not been paired yet. - Run
agent on
- Run
pair <mac_address>
to start pairing. Then, you need to enter the device PIN if it's needed. - Run
trust <mac_address>
manually if the device has no PIN. - Run
connect <mac_address>
to establish a connection.
The last step can fail for certain devices. I also failed to connect my Pi with my Arduino with the HC-06 Bluetooth module. If you use the GUI tool for Bluetooth, it may show you a notification message, "Connection failed: No usable services on this device". If you use the CLI tool (
bluetoothctl
), it may show you an error message, "Failed to connect: org.bluez.Error.NotAvailable". For the solution, you can try the following steps.- Edit the Systemd configuration of the Bluetooth service by:
$ sudo nano /etc/systemd/system/dbus-org.bluez.service
- Add compatibility flag "-C" and create a serial port profile. Find and edit or insert these lines.
ExecStart=/usr/lib/bluetooth/bluetoothd -C ExecStartPost=/usr/bin/sdptool add SP
- Save and reboot your Pi then run again previous steps for pairing Bluetooth device using
bluetoothctl
. - After the device is paired, you can run
sudo rfcomm watch hci0
orsudo rfcomm connect 0 <mac_address> 1
. This command will create an access channel in/dev/rfcomm0
. - On another terminal, you can run
rfcomm
to see any created connection.
This was huge information for all those who need this. That was a really good blog and of course knowledgeable. Thank you for sharing this much information with us. How to send large videos
ReplyDeleteExcellent job, this is great information which is shared by you. This info is meaningful and factual for us to increase our knowledge about it. about Discount Nikai Home Appliances for Sale So please always keep sharing this type of information.
ReplyDelete