What is a Bluetooth device
Bluetooth is a wireless technology that connects the different devices on a particular wavelength with each other and the data is transferred between these devices. The Bluetooth devices can be connected with each other if they are in the range of 30 meters but when the obstacles come between the devices like walls then this range may be decreased. This is the secure way to transfer data between two devices and can be used to connect mobiles, laptops, or peripheral devices like headsets and keyboards.
How to setup Bluetooth on Raspberry Pi using the terminal
It is considered a good practice that whenever you start the Raspberry Pi OS, first update as well as upgrade all the packages of the repository of Raspberry Pi using the command:
After making sure that all the packages are up to date, we will find the status of our Bluetooth service using the command:
In the output, it is cleared that the Bluetooth service is in active status, we can stop the service of Bluetooth using the command:
Again check the status of Bluetooth service using the systemctl command:
To start the Bluetooth service, we will execute the command in the Raspberry Pi terminal:
In order to find out the name of our Bluetooth through the terminal, we will use the command:
In the above output, we can see that the name of our Bluetooth device “hci0”, using this name, we will scan the devices that are in the range of our Bluetooth:
The “DESKTOP-BSDBLIB” is the device to which we want to connect and its MAC address is E4:A4:71:79:78:D5, we will initialize the Bluetooth by using the command:
Once we are in the Bluetooth environment, we will turn on the Bluetooth module using the command:
Once again scan nearby Bluetooth devices which are in the range of our Bluetooth:
Pair the device with MAC address E4:A4:71:79:78:D5 by using the trust command:
Connect the device using its MAC address:
If you want to disconnect the Bluetooth device, execute the command:
How to setup Bluetooth on Raspberry Pi using the GUI
Another way to connect the Bluetooth device is much more convenient as it is GUI (graphical user interface) based, click on the Bluetooth icon on the right top of the screen and a drop-down menu will appear, select the “Add Device”:
Click on the device to which you want to connect through Bluetooth and click on the “Pair” button, in our case the device is “DESKTOP-BSDBLIB”:
The device will be added, a red cross is showing the device is not yet connected, click on the added device, another menu will appear to choose the “Connect”:
The red color icon will turn into the green color which indicates the device is connected successfully:
For disconnection, again click on the device and choose “Disconnect” to disconnect the device with Raspberry Pi:
Conclusion
Bluetooth technology is very popular nowadays, to connect various devices such as wireless headsets, and speakers. One of the reasons behind the popularity of these Bluetooth devices is that they are easy to handle as they do not contain a mess of wires with them. In this write-up, setting up the Bluetooth devices on Raspberry Pi has been explained through the command-line interface as well as the graphical user interface.