Drone Project Help

Bluetooth Setup on Raspberry Pi Zero 2W

This section outlines the necessary procedures for enabling and configuring Bluetooth communication on a Raspberry Pi Zero 2W. It includes the installation of essential packages, service initialization, and the use of bluetoothctl to configure the device for pairing and discovery. The aim is to prepare the system to function as a Bluetooth server or client for low-level communication.

Required Software Installation

First, update the package repositories and install the necessary Bluetooth tools and services:

sudo apt update sudo apt install bluetooth bluez bluez-tools rfkill
  • bluetooth: The core Bluetooth daemon.

  • bluez: The official Linux Bluetooth protocol stack.

  • bluez-tools: Utility programs for managing Bluetooth devices.

  • rfkill: A tool to query and control wireless devices' radio transmitters.

Enabling the Bluetooth Service

Enable and start the bluetooth system service to ensure it runs on boot:

sudo systemctl enable bluetooth sudo systemctl start bluetooth

This activates the Bluetooth daemon (bluetoothd) and prepares the system to handle Bluetooth operations.

Interactive Configuration with bluetoothctl

To configure the Bluetooth interface, use the command-line utility bluetoothctl. The following commands are executed within its interactive shell:

bluetoothctl

Once inside, issue the following instructions:

bluetoothctlpower on # Turn on Bluetooth agent on # Enable pairing agent default-agent # Set as the default agent discoverable on # Make the Pi visible to other devices pairable on # Allow other devices to pair with the Pi scan on # Start scanning for nearby Bluetooth devices (optional)
  • power on: Activates the Bluetooth controller.

  • agent on: Enables an agent responsible for handling pairing and authentication.

  • default-agent: Registers the current agent as the system default.

  • discoverable on: Makes the Raspberry Pi visible to nearby devices.

  • pairable on: Allows other devices to initiate pairing with the Pi.

  • scan on: Initiates active discovery of nearby Bluetooth devices (optional for pairing as a peripheral).

10 Juli 2025