• Stars
    star
    1,527
  • Rank 30,669 (Top 0.7 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A cross platform Bluetooth Low Energy Client for Python using asyncio

bleak

Bleak Logo
Build and Test PyPI - Downloads Documentation Status

Bleak is an acronym for Bluetooth Low Energy platform Agnostic Klient.

Bleak is a GATT client software, capable of connecting to BLE devices acting as GATT servers. It is designed to provide a asynchronous, cross-platform Python API to connect and communicate with e.g. sensors.

Installation

$ pip install bleak

Features

  • Supports Windows 10, version 16299 (Fall Creators Update) or greater
  • Supports Linux distributions with BlueZ >= 5.43
  • OS X/macOS support via Core Bluetooth API, from at least OS X version 10.11
  • Android backend compatible with python-for-android

Bleak supports reading, writing and getting notifications from GATT servers, as well as a function for discovering BLE devices.

Usage

To discover Bluetooth devices that can be connected to:

import asyncio
from bleak import BleakScanner

async def main():
    devices = await BleakScanner.discover()
    for d in devices:
        print(d)

asyncio.run(main())

Connect to a Bluetooth device and read its model number:

import asyncio
from bleak import BleakClient

address = "24:71:89:cc:09:05"
MODEL_NBR_UUID = "00002a24-0000-1000-8000-00805f9b34fb"

async def main(address):
    async with BleakClient(address) as client:
        model_number = await client.read_gatt_char(MODEL_NBR_UUID)
        print("Model Number: {0}".format("".join(map(chr, model_number))))

asyncio.run(main(address))

DO NOT NAME YOUR SCRIPT bleak.py! It will cause a circular import error.

See examples folder for more code, for instance example code for connecting to a TI SensorTag CC2650

More Repositories

1

hitherdither

Dithering algorithms for arbitrary palettes in PIL
Python
196
star
2

pyefd

Python implementation of "Elliptic Fourier Features of a Closed Contour"
Python
79
star
3

pybankid

BankID Relying Party client for Python
Python
45
star
4

pymetawear

Community developed SDK around the Python bindings for the C++ SDK
Python
43
star
5

b2ac

Python and C implementations of an ellipse fitting algorithm in double and fixed point precision.
Python
19
star
6

lspopt

Python implementation of a multitaper window method for estimating Wigner spectra for certain locally stationary processes
Python
19
star
7

skboost

MILBoost and other boosting algorithms, compatible with scikit-learn
Python
13
star
8

calibraxis

Autocalibration method for accelerometer data
Python
11
star
9

xmlr

Python package for parsing very large XML files
Python
10
star
10

pyberryimu

PyBerryIMU - I2C communications lib for using BerryIMU
Python
7
star
11

dlxsudoku

Sudoku Solver written in pure Python with no dependencies
Python
7
star
12

sudokuextract

An image processing tool for extracting Sudokus from images
Python
6
star
13

imdirect

Monkey patch for PIL, performing automatic rotation of opened JPEG images
Python
3
star
14

duckdns-upd8

Python updater for duckdns.org Dynamic DNS record
Python
3
star
15

Uriel

OpenCV based Eye Tracking solution
Python
2
star
16

MongoLab-REST-GAE

A Python REST client for using MongoLab storage in Google App Engine
Python
1
star
17

tpopp

The Point of Pointless Projects
JavaScript
1
star
18

bankkonto

Python validation library for Swedish bank account numbers
Python
1
star
19

PythonBoilerplate

Python project Boilerplate creator.
Python
1
star
20

AdventOfCode

Solutions for Advent of Code 2016 - 2020, written mostly in Python
Python
1
star
21

brotherscan

Tools and documentation on how to get an old Brother Network Printer and Scanner to work
Python
1
star