Skip to main content

License PyPI version Supported Python versions PyPI downloads Code style: black pre-commit.ci status

bluepy3

This is a Python3 library to allow communication with Bluetooth Low Energy devices on Linux.

Requirements

Please be aware that this is not a beginners tool. Some experience with Linux CLI, Python3 and BT/BLE is expected.

Development of this package is done in Python 3.12. The package is considered forwards compatible at least upto Python 3.12 and probably also beyond. Backwards compatibility is not guaranteed; if it works on Python 3.9 or before consider yourself lucky. Python versions that are end-of-life are not supported.

The package has been extensively tested on a Raspberry Pi 3 Model B+ (aarch64) with Debian GNU Linux 11 w/ Python 3.9.* AND with Debian GNU Linux 12 /w Python 3.11.* and 3.12.*.

The code needs an executable bluepy3-helper which is compiled from C source automatically when first used (see below).

The bluepy3 package comes installed with lists of compatible UUIDs in uuids.json. If, for whatever reason, you want to rebuild those lists, then the Python3 modules bs4, requests and lxml need to be installed.

python3 -m pip install bs4 lxml requests

Then find where the bluepy3 package is installed and rebuild uuids.json thus:

cd some_path_name/site-packages/bluepy3/
make uuids.json

Installation

To install the currently released version, on most Debian-based systems:

sudo apt-get install libglib2.0-dev libbluetooth-dev
python3 -m pip install --upgrade bluepy3

Then test the installation using:

sudo setcap cap_net_raw,cap_net_admin+ep $(find . -name bluepy3-helper)
blescan -n
sudo hcitool lescan

This should list the (compatible) Bluetooth devices in range.

Upon the first import of bluepy3.btle the required binary is compiled. This requires the download of the BlueZ source (20MB) to /tmp (don't worry this is done automatically). The default behaviour is to compile against the version of the BlueZ source that matches the version of the installed bluetoothctl. The user may override this by forcing compilation against any of the supported source trees by running helpermaker --build <version>. You are advised NOT to use make directly, but rather use the python script helpermaker.

It may be considered to have command-line tools from BlueZ available for debugging.

Troubleshooting

Make sure the user is part of the bluetooth group. Use hciconfig to confirm that the device actually exists. This should output something like:

hci0:    Type: Primary  Bus: UART
BD Address: B8:27:EB:90:4F:F5  ACL MTU: 1021:8  SCO MTU: 64:1
UP RUNNING
RX bytes:15332515 acl:452626 sco:0 events:333729 errors:0
TX bytes:7376962 acl:438075 sco:0 commands:72113 errors:0

Use hciconfig [hci0] up to activate the BT device if the above returns an error.

Documentation

For documentation you are referred to the documentation that comes with bluepy. Be warned though that as development of bluepy3 advances some of the documentation may be off a bit.

Contributing

Your assistance to improve this package is greatly appreciated. See CONTRIBUTING for details.

Disclaimer & License

As of September 2024 bluepy3 is distributed under AGPL-3.0-or-later.

Acknowledgements

This work builds on previous work by Ian Harvey and uses code by the BlueZ project and the GitHub repository BlueZ on GitHub

Metadata

Release files for bluepy3 2.22.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bluepy3 2.22.3
File Size Uploaded
bluepy3-2.22.3.tar.gz 54.2 kB Details

Release files / bluepy3-2.22.3.tar.gz

Download URL bluepy3-2.22.3.tar.gz
Size 54.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a243a478c086c1475aae3011ea7418fbf0d30d5eedba6d980d71e4bc444c88d0
BLAKE2b-256 checksum
How to use checksums
279c9242569773f0f6ed31d47f5d7e58f2c8bfabbe3f25b28fd75e9426e40f53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

2.22.3 This release

1 release file

2.22.2

1 release file

2.22.1

1 release file

2.20.1

1 release file

2.18.1

1 release file

2.17.4

1 release file

2.16.1

1 release file

2.14.2

1 release file

2.14.1

1 release file

2.12.2

1 release file

2.12.1

1 release file

2.10.1

1 release file

2.8.4

1 release file

2.8.3

1 release file

2.8.1

1 release file

2.6.1

1 release file

2.4.2

1 release file

2.4.1

1 release file

2.2.1

1 release file

1.12.1

1 release file

1.10.4

1 release file

1.10.3

1 release file

1.10.2

1 release file

1.10.1

1 release file

1.8.1

1 release file

1.6.4

1 release file

1.6.3

1 release file

1.6.2

1 release file

1.6.1

1 release file

1.4.1

1 release file

1.2.5

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

0.6.0

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.547

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.12

1 release file

0.1.7

1 release file

0.1.0

1 release file

0.0.33

1 release file

0.0.31

1 release file

0.0.29

1 release file

0.0.27

1 release file

0.0.25

1 release file

0.0.23

1 release file

0.0.21

1 release file

0.0.19

1 release file

0.0.18

1 release file

0.0.17

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.12

1 release file

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page