Skip to main content

Python library for Bluetooth Low Energy (BLE) on Linux

Project description

Build Status PyPI Version MIT License docs

A simple Python interface to BlueZ stack

Name and aim

The aim of this library is to provide an API to access to Bluez with zero boilerplate code.

Goal

To provide a simplified API to people that want to use Bluetooth functionality in their code. The library will use calls to the BlueZ D-Bus API and use ‘sensible’ defaults to help with that simplification. It aims to support the ability to create interesting STEM activities without needing to explain the BlueZ API or write an event loop.

In addition to the API, it will contain examples of how to connect to common Bluetooth Smart (BLE) objects around them (or at least easily accessible to them). These examples will need to be written without the need to sign (or break) non-disclosure agreements.

Status

While we want this to be easy to use it does not mean it easy to create. This library is still in the early stages so things might change and break. Apologies in advance! We will try to make it as stable as possible. However much of the functionality that is in BlueZ is still flagged as experimental. The library assumes you are using a Linux release with BlueZ 5.50. For example Raspberry Pi OS Buster

Getting Started

If you are here for the time, and especially if you are new to Bluetooth Low Energy, then a tutorial might be a good place to start. The following tutorial has been created based on the readily available hardware of a Raspberry Pi and a micro:bit. More details available at: https://ukbaz.github.io/howto/ubit_workshop.html

Examples

There are some other examples in the library if you are feeling adventurous

Adapter

adapter_example.py

This will check that it can find the Bluetooth adapter on the computer running the code. It will print to screen various information and check it is powered before scanning for nearby devices

GATT Client (Central role)

microbit_poll.py

This example uses the micro:bit API that has been written in bluezero. You will need a buzzer attached to pin 0 to get play_beep to work.

Beacon

eddystone_url_beacon.py

A Simple Eddystone URL beacon. You can be read the URL being broadcast with any Physical Web application on your Phone

Scanner

eddystone_scanner.py

This example scans for beacons using the common beacon formats of Eddystone URL, Eddystone UID, AltBeacon and iBeacon.

GATT Server (Peripheral role)

You will need to have modified the dbus configuration file to open the permissions for ‘ukBaz.bluezero’. This is covered in the System Setup section of the documentation

cpu_temperature.py

This example transmits the temperature of the CPU over the single characteristic. The method get_cpu_temperature() function creates randomly generated temperature values. Values are only updated when notification are switched on.

ble_uart.py

This example simulates a basic UART connection over two lines, TXD and RXD.

It is based on a proprietary UART service specification by Nordic Semiconductors. Data sent to and from this service can be viewed using the nRF UART apps from Nordic Semiconductors for Android and iOS.

It uses the Bluezero peripheral file (level 10) so should be easier than the previous CPU Temperature example that was a level 100.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bluezero-0.9.1.tar.gz (49.7 kB view details)

Uploaded Source

Built Distribution

bluezero-0.9.1-py2.py3-none-any.whl (41.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file bluezero-0.9.1.tar.gz.

File metadata

  • Download URL: bluezero-0.9.1.tar.gz
  • Upload date:
  • Size: 49.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bluezero-0.9.1.tar.gz
Algorithm Hash digest
SHA256 82488a9dc264f6114bb9727cc7e8939fa3a8d08fd71384cdab31419a80d25f97
MD5 2c567d4a6bf2bf03c9131b69695700ac
BLAKE2b-256 ca092aec91949397d15acb794648d65646e27f0e9f999a0da962e73023198663

See more details on using hashes here.

Provenance

The following attestation bundles were made for bluezero-0.9.1.tar.gz:

Publisher: release.yml on ukBaz/python-bluezero

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bluezero-0.9.1-py2.py3-none-any.whl.

File metadata

  • Download URL: bluezero-0.9.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 41.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bluezero-0.9.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 253c2aacce9d18d99780c3195dd77a5002fea8d74a1ada3152b2c041b48b586e
MD5 38b45fe04019edc626bd07fe474fa831
BLAKE2b-256 5ad034d7d4f224aec600f54f2c57d24f8199608b5ad7c3fe4f740b759a1008b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for bluezero-0.9.1-py2.py3-none-any.whl:

Publisher: release.yml on ukBaz/python-bluezero

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page