Raspberry Pi

How to Connect Bluetooth Device to Raspberry Pi from Terminal

Raspberry Pi is a single-board computer, which is beneficial for creating several DIY projects, including home automation, robots, web servers and more. However, since the device doesn’t have much power to run a GUI, most people use the Raspberry Pi OS lite version to speed up the efficiency of the work. If you need help connecting a Bluetooth device to Raspberry Pi for a project, you can easily use the command-line terminal to connect the device.

In this article, you will find an easy way to connect a Bluetooth device with Raspberry Pi from the terminal.

How to Connect Bluetooth Device to Raspberry Pi from Terminal

To connect a Bluetooth Device with Raspberry Pi on terminal, use the following steps:

Step 1: Open Bluetooth on Raspberry Pi

Open the Bluetooth command-line tool using the following command:

$ sudo bluetoothctl

 

Step 2: Scan Bluetooth Devices

Use the following command to scan Bluetooth devices near to your Raspberry Pi device:

$ scan on

 

You will see different Bluetooth devices appear in the search.

Step 3: Pair a Bluetooth Device

To pair a Bluetooth device with Raspberry Pi, use the following command:

$ pair <Bluetooth Device Mac Address>

 
Note: You have to find your device with the name or using the Mac Address.


In my case, I am connecting a Bluetooth device with the name “Lenovo A7010”. The Bluetooth device could be your mobile phone, speaker, controller, or air pods. Type “yes” to send a connection request.


Wait till the connection is established and once it’s done, you will see a successful pairing notification on the terminal.


Note: You have to allow pairing requests from mobile or laptop if you are paring them to Raspberry Pi:

Conclusion

Raspberry Pi system allows users to connect a Bluetooth device directly from the terminal using the “bluetoothctl” command. Once the agent is registered, you must search for Bluetooth devices using the “scan on” command and connect to your device using its MAC address. Wait till the connection is established, which may require your approval for the connection request. Once the connection is made, you can use a Bluetooth device with Raspberry Pi.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.