Introduction - Raspberry Pi 4 Model B
The Raspberry Pi 4 Model B is the most recent addition to the popular Raspberry Pi computer line. When compared to the previous-generation Raspberry Pi 3 Model B+, it provides ground-breaking improvements in processing speed, multimedia performance, memory, and connection while maintaining backwards compatibility and similar power consumption. In terms of desktop performance, the Raspberry Pi 4 Model B is equivalent to entry-level x86 PC computers.
A high-performance 64-bit quad-core processor, dual-display support at resolutions up to 4K via a pair of micro-HDMI ports, hardware video decode at up to 4Kp60, up to 4GB of RAM, dual-band 2.4/5.0 GHz wireless LAN, Bluetooth 5.0, Gigabit Ethernet, USB 3.0, and PoE capability are some of the key features of this product (via a separate PoE HAT add-on).
Launching Soon On @Kickstarter
— SB Components Ltd (@sb_ltd) December 17, 2021
𝐔𝐏𝐒 𝐇𝐀𝐓 𝐅𝐨𝐫 𝐑𝐚𝐬𝐩𝐛𝐞𝐫𝐫𝐲 𝐏𝐢
Efficient and Smart way to use your Raspberry Pi · Stable 5V Power Output · Standard Raspberry Pi 40PIN GPIO extension header, supports @Raspberry_Pi Serieshttps://t.co/kw87Ux7vMQ pic.twitter.com/3LJnw5pvxE
How to Configure the Raspberry Pi's On-Board Bluetooth
Bluetooth is built into the Raspberry Pi and may be used for communication as well as sending and receiving data.
We must first couple the Raspberry Pi with a Bluetooth-enabled device before we can communicate with it.
The process of pairing a Bluetooth device on a Raspberry Pi is the same as it is on a smartphone or laptop.
Turn on Bluetooth by doing the following:
- Make it discoverable after that.
- Choose an option now. Add a device...
We can see a mobile Bluetooth gadget named "ZUK Z1" in the window above. Select the device and then pair it. This will prompt for pairing and display the pin from Raspberry Pi to Bluetooth device (the pin that was randomly created by Raspberry Pi), which should trigger the device to ask you to confirm the connection.
Our raspberry pi and the Bluetooth device will be connected and a connection may be formed when the device accepts the connection using the pair option. Our Raspberry Pi is now ready to talk to the attached device.
How can I transfer files from a Raspberry Pi to a Bluetooth-enabled device?
Bluetooth communication between a Raspberry Pi and a device may be accomplished in two ways.
- GUI for Bluetooth (Graphical User Interface)
- The CLI (Command Line Interface) (CLI)
The following packages must be installed before we can use the GUI or CLI to access Bluetooth-based transmission.
- Blueman is a Bluetooth manager with a lot of features. It comes with a graphical user interface (GUI)-based Bluetooth manager.
- Bluez–The Bluetooth protocol stack and the bluetoothctl software are included in this package.
- Bluetooth–This package contains all of the BluezBluetooth stack's plugins.
Install the required packages using the commands below to utilise the Bluetooth service.
sudo apt-get install bluemanbluez Bluetooth
Reboot Raspberry Pi once the aforementioned packages have been installed successfully.
For Bluetooth Services, a Graphical User Interface (GUI) is used.
The Raspberry Pi does not have a graphical user interface (GUI) for accessing Bluetooth services like a laptop or mobile phone. We installed the programmes mentioned above to get a Bluetooth GUI.
We can now use the GUI to access Bluetooth services (send/receive). To do so, go to the menu and pick preferences from the drop-down menu. Select Bluetooth Manager from the options menu. As illustrated below, the Bluetooth management window now displays all of the visible Bluetooth devices.
We need to make Bluetooth visible so that other devices may find it. To do so, go to Adapter à Preferences and choose Adapter à Preferences, as seen below.
We can send files from the Raspberry Pi to a Bluetooth device of our choice.
To send a file, right-click on the device you want to send it to and select Send a File, as shown below.
Send a file by browsing through it. On the Raspberry Pi, we may also receive a file.
Bluetooth Services Command Line Interface (CLI)
The items we installed before are also required for the command line interface.
The easiest and most reliable method is to pair a Bluetooth device with shell.
- Using bluetoothctl to connect to a Bluetooth device
To pair and connect the Raspberry Pi's Bluetooth with another Bluetooth device, follow the instructions below. For pairing and creating connections between Raspberry Pi and Bluetooth devices, we use the bluetoothctl software.
To start bluetoothctl, use the following command.
bluetoothctl
Using the following instruction, switch on the controller's power.
power on
To acquire the mac address of the device with which we wish to pair, type devices. This command displays a list of devices that are currently accessible.
devices
If no devices appear in the list, use the following search:
scan on
activate the agent
agent on
connect your Bluetooth device
pair <mac address>
e.g. pair 01:02:03:04:05:06
If you're using a device that doesn't have a PIN, you'll need to manually mark it as a trusted device, as shown below.
trust <mac address>
Finally, make a Bluetooth connection between two devices that support it.
Connect <mac address>
You may use the help command to learn more about commands.
- CLI is used to send and receive data via Bluetooth.
Using the CLI, we can send/receive data from/on the Raspberry Pi through Bluetooth. This connection is useful when we need to control a Raspberry Pi-connected item from a smartphone or laptop through Bluetooth. CLI is the most efficient mode of communication for such apps. The Bluetooth protocol RFCOMM (Radio Frequency Communication) is used here.
Example
Let's use CLI to send data between a Smartphone (Mobile) and a Raspberry Pi over Bluetooth.
Follow the instructions below to utilise CLI to communicate between two Bluetooth devices.
We've already used bluetoothctl to link a device.
We're going to use hciconfig to configure Bluetooth devices so that data may be sent between them.
For Raspberry Pi Bluetooth device details, use the following command.
hciconfig
This will give you the Raspberry Pi's Bluetooth's mac address. It also indicates if the port is open or closed.
If it's down, use the commands below to get it back up.
hciconfig hci0 up
Note: If you get an error like "operation not feasible due to RF-Kill," you may fix it using
rfkill unblock all
as follows: build a Bluetooth profile
sdptool add sp
We must connect the smartphone to the Raspberry Pi in order to get data from it. We need to utilise a Bluetooth application on the Smartphone to connect it and communicate (send/receive) data. We're utilising the Blueterm
application here.
Use the following command to connect your Raspberry Pi to your smartphone through Bluetooth.
sudo rfcomm listen hci0&
This command instructs the Raspberry Pi to wait for a device (smartphone) connection request.
We must first launch the Blueterm
programme and choose the Bluetooth device (Raspberry Pi) with which we wish to communicate.
We may get messages from our Smartphone once the device has been correctly linked.
We can now transfer characters/messages from our smartphones to the Raspberry Pi, but we can't see them on the terminal on the Raspberry Pi. Enter the following command to display the received characters/messages.
cat /dev/rfcomm0
We can now see the messages in the terminal that is receiving them.
Use the following command to transmit messages from the Raspberry Pi to a smartphone through Bluetooth.
echo “type character/message here” >/dev/rfcomm0
We can now send and receive messages through Bluetooth between the Raspberry Pi and the mobile device. This message transfer may be used to create Raspberry Pi-based apps such as operating household appliances (heating, light, door, fan) over Bluetooth using a mobile phone. We can control the gadgets linked to the Raspberry Pi simply by sending text messages from our phones.
Posts You May like:
- How to Block Ads with Pi-hole on a Raspberry Pi Zero 2 W
- Uninterruptible Power Supply UPS HAT For Raspberry Pi
- A hidden speed boost and a 64-bit option are included in the new #RaspberryPi #OS
- Using the On-Board Bluetooth on the Raspberry Pi 4 for Communication
- #ArduinoIDE 2.0 Release Candidate (RC)
- Armbian Linux on the Raspberry Pi 4: A First Look
- NeoPixel Christmas Tree Lights Controlled by a Raspberry Pi
- What Type of LoRa Modules are Available?
- Introducing The VisionFive V1 is a RISC-V Based Raspberry Pi Replacement - Available Soon
- Raspberry Pi Zero 2 W Overclocking - Boost Up To 1.2GHz, or even 1.4GHz
- The Arduino UNO Mini Limited Edition is Now Available
- Scan QR Codes with Raspberry Pi Pico
- Create Barcodes with Pure Python
- The New Version of Raspberry Pi OS, Debian "Bullseye" is Now Available.
- The Raspberry Pi Zero 2 W Arrives Six Years After The First Pi Zero
- Raspberry Pi 4 Has Been Given Vulkan 1.1 Compliance by Khronos
- The Raspberry Pi Build HAT - Complete Guide
- Raspberry Pi Officialy Announced Build HAT For Raspberry Pi
- Installing Android on a Raspberry Pi 4 with Google Play Store
- Pop OS Linux is Coming to Raspberry Pi and Other ARM Devices Soon
- How to Immediately Upgrade to Windows 11
- A Secret Update for the Raspberry Pi 4 8GB
- Raspberry Pi Introduces a New Documentation Hub
- Quick start with ESP8266 based Pico WiFi HAT
- Capture local Real-Time Air Quality Data with Raspberry Pi Pico
- How to Block Ads with Pi-hole on a Raspberry Pi Zero 2 W
- Uninterruptible Power Supply UPS HAT For Raspberry Pi
- A hidden speed boost and a 64-bit option are included in the new #RaspberryPi #OS
- Using the On-Board Bluetooth on the Raspberry Pi 4 for Communication
- #ArduinoIDE 2.0 Release Candidate (RC)
- Armbian Linux on the Raspberry Pi 4: A First Look
- NeoPixel Christmas Tree Lights Controlled by a Raspberry Pi
- What Type of LoRa Modules are Available?
- Introducing The VisionFive V1 is a RISC-V Based Raspberry Pi Replacement - Available Soon
- Raspberry Pi Zero 2 W Overclocking - Boost Up To 1.2GHz, or even 1.4GHz
- The Arduino UNO Mini Limited Edition is Now Available
- Scan QR Codes with Raspberry Pi Pico
- Create Barcodes with Pure Python
- The New Version of Raspberry Pi OS, Debian "Bullseye" is Now Available.
- The Raspberry Pi Zero 2 W Arrives Six Years After The First Pi Zero
- Raspberry Pi 4 Has Been Given Vulkan 1.1 Compliance by Khronos
- The Raspberry Pi Build HAT - Complete Guide
- Raspberry Pi Officialy Announced Build HAT For Raspberry Pi
- Installing Android on a Raspberry Pi 4 with Google Play Store
- Pop OS Linux is Coming to Raspberry Pi and Other ARM Devices Soon
- How to Immediately Upgrade to Windows 11
- A Secret Update for the Raspberry Pi 4 8GB
- Raspberry Pi Introduces a New Documentation Hub
- Quick start with ESP8266 based Pico WiFi HAT
- Capture local Real-Time Air Quality Data with Raspberry Pi Pico