Adafruit Python BluefruitLE works on Raspberry Pi.

Introduction

We distributed the first stray badge in a limited quantity in Technical Book 7, but we received a comment from the purchaser about "Integration with Raspberry Pi", so we decided to make it an article in Technical Book 8. .. Anyway, with a development policy that works with the same library and source code on both Mac and Linux (Raspberry Pi), make a note of the problems you faced and how to solve them.

After all it did not move

Since there was a sample code (C) for ESP32, a sample code (JavaScript) using the Web Bluetooth API of the Chrome browser, and a message display program (Python) for the USB-HID version LED Badge in Technical Book 7, node.js I decided to develop with Python.

environment

--Mac: macOS Mojave version 10.14.6 (18G1012) + Xcode 11.3 (11C29)

Adafruit Python BluefruitLE library

node.js worked fine with the noble library and Python worked fine on the Mac with Adafruit Python BluefruitLE, but on the Raspberry Pi " Adafruit Python Bluefruit LE didn't work ", and as expected, it didn't work either.

BlueZ (5.38) and later patches

As we investigated, Linux uses BlueZ (5.50), and since BlueZ (5.38), the specifications of D-Bus Object Manager have changed, so it was necessary to apply a patch. As of January 26, 2020, it was not merged into the original home and should be resolved by: (reference) Fixed incompatibility with BlueZ version >= 5.38

environment

--Linux: Python 3.7.3 + BlueZ (5.50) + Adafruit Python BluefruitLE (donatieng patch)

It worked

There are two solutions.

--If you already have the Adafruit Python BluefruitLE library installed, apply the patch manually. Alternatively, uninstall and install the patched Adafruit Python BluefruitLE library. --If you have not already installed the Adafruit Python BluefruitLE library, install the patched Adafruit Python BluefruitLE library.

Manually patch

$ cd /usr/local/lib/python3.7/dist-packages/Adafruit_BluefruitLE/bluez_dbus/
$ sudo mv gatt.py gatt.py_org
$ sudo wget https://raw.githubusercontent.com/donatieng/Adafruit_Python_BluefruitLE/master/Adafruit_BluefruitLE/bluez_dbus/gatt.py

Uninstall the Adafruit Python BluefruitLE library

$ sudo pip3 uninstall Adafruit-BluefruitLE

Installing the patched Adafruit Python BluefruitLE library

$ git clone https://github.com/donatieng/Adafruit_Python_BluefruitLE
$ cd Adafruit_Python_BluefruitLE/
$ sudo python3 setup.py install

Summary

Technical Book 8 is being written with the theme of "hacking light and sound"! (As of January 27, 2020) The store will open on the second day, "Ka 40", so let's meet on the day! !! img_005.png

Recommended Posts

Adafruit Python BluefruitLE works on Raspberry Pi.
Detect "brightness" using python on Raspberry Pi 3!
Run servomotor on Raspberry Pi 3 using python
Detect temperature using python on Raspberry Pi 3!
Working with GPS on Raspberry Pi 3 Python
pigpio on Raspberry pi
Cython on Raspberry Pi
Detect slide switches using python on Raspberry Pi 3!
Detect magnet switches using python on Raspberry Pi 3!
Make DHT11 available on Raspberry Pi + python (memo)
Sound the buzzer using python on Raspberry Pi 3!
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
Try debugging Python on Raspberry Pi with Visual Studio.
Raspberry Pi + Python + OpenGL memo
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
raspberry pi 1 model b, python
Install pyenv on Raspberry Pi and version control Python
Output to "7-segment LED" using python on Raspberry Pi 3!
Introduced pyenv on Raspberry Pi
Use NeoPixel on Raspberry Pi
Install OpenCV4 on Raspberry Pi 3
Install TensorFlow 1.15.0 on Raspberry Pi
VScode intellisense doesn't work on Raspberry Pi OS 64bit! (Python)
Run AWS IoT Device SDK for Python on Raspberry Pi
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
Access google spreadsheet using python on raspberry pi (for myself)
Testing uart communication on Raspberry Pi
Use vl53l0x with Raspberry Pi (python)
MQTT on Raspberry Pi and Mac
raspberry pi 4 centos7 install on docker
Install ghoto2 on Raspberry Pi (memo)
Try using ArUco on Raspberry Pi
OpenCV installation procedure on Raspberry Pi
Power on / off Raspberry pi on Arduino
Detect switch status on Raspberry Pi 3
Install OpenMedia Vault 5 on Raspberry Pi 4
L Chika on Raspberry Pi C #
[Raspberry Pi] Changed Python default to Python3
Build wxPython on Ubuntu 20.04 on raspberry pi 4
Resolved an error when putting pygame in python3 on raspberry pi
Use python on Raspberry Pi 3 to illuminate the LED (Hello World)
How to play music (wav / mp3) files on Raspberry Pi python
"Honwaka Notification Lamp" on Raspberry Pi Part 2
Raspberry Pi Security Infrared Camera (Python Edition)
"Honwaka Notification Lamp" on Raspberry Pi Part 1
Enable UART + serial communication on Raspberry Pi
Accelerate Deep Learning on Raspberry Pi 4 CPU
Set swap space on Ubuntu on Raspberry Pi
Programming normally with Node-RED programming on Raspberry Pi 3
Use the Grove sensor on the Raspberry Pi
Install 64-bit OS (bate) on Raspberry Pi
Install docker-compose on 64-bit Raspberry Pi OS
"Honwaka Notification Lamp" on Raspberry Pi Part 3
Working with sensors on Mathematica on Raspberry Pi
Build OpenCV-Python environment on Raspberry Pi B +
Mount Windows shared folder on Raspberry Pi
Matrix multiplication on Raspberry Pi GPU (Part 2)
How to install NumPy on Raspberry Pi
I installed OpenCV-Python on my Raspberry Pi
Use BME280 temperature / humidity / barometric pressure sensor from Python on Raspberry Pi 2