Once you have installed Python 3 and pip3, you are ready to install the Blinka bleio library and the base CircuitPython BLE library. In your shell, enter this command to install both:

pip3 install --upgrade adafruit-blinka-bleio adafruit-circuitpython-ble

The --upgrade will ensure that you get the latest versions, even if either library was previously installed. The adafruit-blinka-bleio library depends on a number of other libraries, which will be installed automatically, and upgraded if necessary.

 

Linux and Raspberry Pi: Add User to bluetooth Group

On Linux, including on Raspberry Pi, you must also add your user to the bluetooth group. Reboot after doing this to ensure your user is added to the group and also to ensure that ~/.local/bin is added to your path (after doing pip3 above). To add yourself to the group, do this:

sudo usermod -a -G bluetooth $USER
sudo reboot

Raspberry Pi 3B+ and 4B Firmware Fix

Raspberry Pi 3B+ and 4B boards use different hardware for BLE and WiFi than Raspberry Pi 3B and Pi Zero W boards. There was a bug in the firmware for the 3B+ and 4B boards, in the bluez-firmware package. bluez-firmware-1.2-4+rpt2 worked, but versions  rpt3, rpt4, rpt5, and rpt6 did not. Make sure your version is at least rpt8, as rpt8 includes a security fix not present in rpt7.

$ apt list bluez-firmware
Listing... Done
bluez-firmware/testing,now 1.2-4+rpt8 all [installed,automatic]
N: There is 1 additional version. Please use the '-a' switch to see it

If you need to upgrade bluez-firmware, do:

$ sudo apt upgrade bluez-firmware

This guide was first published on Oct 27, 2020. It was last updated on Sep 18, 2020.

This page (Install BLE Libraries) was last updated on Oct 17, 2020.

Text editor powered by tinymce.