树莓派蓝牙使用教程

您所在的位置:网站首页 绿联同屏器怎么连接手机蓝牙 树莓派蓝牙使用教程

树莓派蓝牙使用教程

2024-03-07 05:35| 来源: 网络整理| 查看: 265

在这里插入图片描述 The Raspberry Pi single-board computer has had built-in Bluetooth connectivity since the release of the Raspberry Pi 3 in 2016, allowing you to connect wireless peripherals such as keyboards, game controllers, headsets, and more to your device.

If you don’t have a model of Raspberry Pi that has Bluetooth built-in, you can use a third-party USB adapter to add support. You may need to install additional software packages to do this, depending on the adapter you use.

If you’re using using Raspberry Pi OS (previously Raspbian), then Bluetooth should be enabled by default, but you’ll need to follow these additional steps to connect and set up your devices.

These instructions will work for Raspberry Pi OS users, including Raspberry Pi OS Lite, which lacks a graphical desktop environment by default.

翻译: 2016年发布的树莓派3以及之后的树莓派版本内集成有蓝牙功能,可以用来连接外围设备,如键盘、游戏手柄、耳机等设备。

如果你的树莓派没有集成蓝牙,你也可以使用USB蓝牙,但是你需要安装相关的驱动软件才能使用它。

如果你使用的是官网最新的树莓派系统,默认开启了蓝牙功能,但是你需要按照其他一些步骤来配对和链接蓝牙。

这些指令适用于Raspberry Pi OS系统,如默认不带图形化桌面显示功能的Raspberry Pi OS Lite系统。

1、Installing the Bluetooth manager tool (desktop environment required)

安装蓝牙管理工具(带桌面显示的系统)

The “full” version of Raspberry Pi OS has a basic Bluetooth settings menu that allows you to enable or disable the service and connect to nearby Bluetooth devices. This is available from the taskbar at the top of your screen.

It’s quite a basic tool, however, and doesn’t allow you to easily control certain types of Bluetooth devices like game controllers or wireless speakers. You can overcome these issues by installing an additional set of packages to manage your Bluetooth settings.

While the additional Bluetooth software packages you’ll install here can be useful for Raspberry Pi OS Lite users, you won’t be able to use the Blueman Bluetooth Manager tool itself, as Lite users don’t have a desktop environment installed. You’ll need to skip to the next section and follow the instructions for setting up Bluetooth using the terminal instead if this is the case.

翻译: 完整版本的树莓派系统有一个设置菜单,可以通过它来开启或关闭蓝牙服务,此菜单位于屏幕顶部的任务栏中。

他相当于一个基础的工具,不容易实现通过它来控制别的蓝牙设备,如游戏手柄、无线音箱。但是你可以通过安装一些程序来管理树莓派蓝牙,从而解决上述问题。

在此案例中,虽然安装的蓝牙软件包对于Lite系统使用者很有用,但是因为Lite系统没有桌面显示功能,所以不能使用Blueman 蓝牙管理工具,你需要跳到下一章节通过终端来设置树莓派上的蓝牙。 在这里插入图片描述 1.To start, open a terminal window by clicking the Terminal icon on your menubar (or press the Raspberry Pi menu > Accessories > Terminal).

2.In the open terminal window, type sudo apt update && sudo apt upgrade to check for new software packages and device firmware updates.

3.Once this process has completed, type sudo apt install bluetooth pi-bluetooth bluez blueman to install the necessary additional packages.

翻译: 1.通过点击开始菜单上的终端图案打开终端(或者点击树莓派“菜单>附件>终端”)

2.在打开的终端输入: sudo apt update && sudo apt upgrade指令校验并更新固件驱动。

3.等待更新完成,然后输入:sudo apt install bluetooth pi-bluetooth bluez blueman 指令安装必要的软件包。

2、Using the Blueman Bluetooth Manager tool (desktop environment required)

使用Blueman蓝牙管理工具(带桌面显示的系统)

Once the required Bluetooth software packages have finished installing, restart your Raspberry Pi. Upon rebooting, you should see a second Bluetooth icon with a blue circular background in the top-right corner of your menu bar.

翻译: 一旦必要的安装包完成安装,请重启你树莓派。在重启时你会在顶部右侧的菜单栏看到一个圆形蓝色背景图案的蓝牙标志。

在这里插入图片描述 From here, you can begin to control your Bluetooth connectivity and connect with other nearby devices.

1.To begin controlling your Bluetooth settings, click this Bluetooth icon on the menu bar. If Bluetooth isn’t already active, click Turn Bluetooth On in the drop-down menu to switch it on.

2.Once Bluetooth is active, click the Make Discoverable option. This will allow other Bluetooth-capable devices to find your Raspberry Pi, allowing them to connect.

翻译: 到此步骤,你已经可以控制蓝牙的连通性和与附近蓝牙设计进行链接。

1.点击菜单栏上的蓝牙标志即可开始控制你的蓝牙设置,如果蓝牙没有启动,请点击蓝牙的下拉菜单,然后开启它。

2.如果蓝牙开启了,请点击“可发现”选项,这样就可以让别的蓝牙设备找到你的树莓派蓝牙并可以连接你树莓派上的蓝牙。

在这里插入图片描述 3.With Bluetooth enabled, click the Setup New Device option.

4.This will launch the Bluetooth device setup assistant, which will help you to connect with and pair a Bluetooth device. Press Next to begin.

翻译: 3.通过点击安装新设备选项可以使能蓝牙。

4.这样将会运行蓝牙驱动安装助手,它将会帮助你链接和配对一个蓝牙设备;点击下一步开始进行安装。 在这里插入图片描述 5.A list of visible local Bluetooth devices will appear at the next stage. Click the search icon in the bottom-left to scan for any additional devices.

翻译: 5.在下一步中你可以看到屏幕将附近的蓝牙设备以列表的形式显示出来,点击左下角的搜索图标可以搜索更多蓝牙设备。 在这里插入图片描述 6.Once your Bluetooth device appears, select it, then click Next.

7.Select the Pair Device option to begin pairing your Bluetooth device, then click Next to proceed.

8.If required, click Confirm to authorize the device pairing. You may need to follow similar steps on your Bluetooth device.

9.A list of available connection methods will appear at the next stage. Select the appropriate option (for instance, Handsfree to use your Bluetooth device as a handsfree headset for your Pi), then click Next.

翻译: 6.当你需要的蓝牙设备出现了,选择它,点击一下步。

7.选择配对选项进行配对你的蓝牙设备,然后继续点击下一步。

8.如果有需要,点击确认设备配对,接着可能需要在你的蓝牙设备上进行如上的简单操作。

9.一栏可链接的方法将出现在下一步,选择你需要的选项(例如,使用蓝牙设备作为你树莓派的免提耳机),然后点击一下步。 在这里插入图片描述 10.This should complete the pairing and connection process. If it doesn’t, click Close and repeat the steps above.

11.Once the pairing process has completed successfully, you’ll be able to view the device (and available services) by clicking the Bluetooth menu icon and selecting the Devices option. From here, you’ll be able to view a list of local Bluetooth devices, as well as devices you’ve paired with — press the Search button to run a new scan for additional devices.

12.You can connect to any of these devices manually by right-clicking a device and clicking Pair or Setup to begin the setup process. You can unpair any Bluetooth device by clicking Unpair instead, or Untrust to remove it from your trusted device list.

在这里插入图片描述 If your Bluetooth device successfully pairs with your Raspberry Pi, you should be able to control and use it as intended. Additional configuration may be required to use or configure your device, depending on the type of device you’re using.

3、Setting up Bluetooth using a terminal or SSH connection

If you don’t have a graphical desktop environment installed (for instance, if you’re using Raspberry Pi OS Lite) or if you want to set up Bluetooth remotely over SSH, you can use commands from the terminal to set up your Bluetooth connections.

在这里插入图片描述 You can also follow these instructions if you prefer to use the terminal from the Raspberry Pi desktop environment, or if you’re unable to connect using the Bluetooth Manager tool.

1.To start, open a terminal window by clicking the Raspberry Pi menu icon. From there, click Accessories > Terminal to open a new terminal window. If you’re connecting remotely using SSH, connect to your Raspberry Pi using your Pi’s username and password.

2.As the default Bluetooth packages are quite basic, you’ll need to install the additional Bluetooth management tools. Type sudo apt update && sudo apt upgrade to update your Raspberry Pi first. Once this process is complete, type sudo apt install bluetooth pi-bluetooth bluez to install the necessary additional packages.

在这里插入图片描述 3.Once these packages have installed, reboot your Raspberry Pi by typing sudo reboot. You’ll need to re-establish your SSH connection if you’re connecting remotely.

4.With a terminal window (or remote SSH connection) open, type sudo bluetoothctl. You may need to type your username and password again to confirm this. This will launch the Bluetooth terminal configuration tool.

5.Type scan on to begin searching for local devices. A list of visible devices will appear, with Bluetooth MAC addresses (the device’s hardware ID) and device names.

在这里插入图片描述 6.To connect to one of these devices, you’ll need the Bluetooth MAC address for your device. If you see your device in the list, type pair XX:XX:XX:XX:XX:XX, replacing this string with your device’s Bluetooth MAC address.

7.This will begin the pairing process — you may need to confirm this on your device. If instructed, type yes to confirm the Bluetooth passkey is correct.

8.If the pairing process is complete, the terminal message will change to reflect the device name, and you may see a pairing successful message.

在这里插入图片描述 9.Once the pairing process has completed, type connect XX:XX:XX:XX:XX:XX (using your Bluetooth device’s MAC address) to connect to it. If the connection is complete, a connection successful message (along with other log messages) will appear in the terminal.

10.If you want to use this device regularly, type trust XX:XX:XX:XX:XX:XX to place the device in your Bluetooth trusted devices list. This will save you time, meaning you won’t need to pair it again in the future. If this is successful, a trust succeeded message will appear in the terminal.

在这里插入图片描述 11.Type exit to close the bluetoothctl tool once you’re done.

As with the GUI Bluetooth Manager tool, you may need to follow additional steps to configure and use your device further, depending on the device itself.

4、Using Bluetooth on your Raspberry Pi

You should (at this point) be able to use your Bluetooth device with your Raspberry Pi. Your Bluetooth devices should be paired, connected, and available for you to use, however you like.

Thanks to the Bluetooth Manager and bluetoothctl tools, it’s easy to connect and use multiple Bluetooth devices on your Raspberry Pi. If you’re using an older Pi without built-in Bluetooth, many third-party USB adapters should be supported out of the box, allowing you to connect Bluetooth peripherals with little additional setup required.

There are plenty of Raspberry Pi projects that you can tweak to make full use of Bluetooth connectivity – from wireless speakers to a Raspberry Pi-powered Amazon Echo Furby, where a Bluetooth microphone could be used over a wired alternative.

结束! 后续翻译!!



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3