项目 / hbldh/bleak

hbldh/bleak

行业推荐
语言 Python标签 pythonpython3bluetoothbluetooth-low-energyplatform-independentcross-platformasyncioble数据更新 2026-11-25 06:49:28 · 仓库 2026-11-24

一段话介绍

A cross platform Bluetooth Low Energy Client for Python using asyncio

本站整理,非 GitHub 官方 description。

官方 description(GitHub API 原样)
A cross platform Bluetooth Low Energy Client for Python using asyncio
2,581累计星
376Fork
—峰值日增
0上榜次数
总榜
暂未入榜
日榜
暂未入榜
周榜
暂未入榜
月榜
暂未入榜

官方快照(gh_history.db,2026-11-25):总榜 未进 Top50 · 日榜 未进 Top50 · 周榜未满 7 天基线(官方不生成) · 月榜暂无官方口径;下方四卡为站内趋势聚合(周卡按上榜次数,非官方 7 日增量窗)。

行业与场景

按行业选型 →

能耗监测与能效优化

适配系统:能源管理系统、能耗监测平台 · 得分 1.4

面向能耗采集与负荷分析建模,可用于园区/楼宇能效诊断与用能优化建议。

更多信息

以下三段按该项目自己的 GitHub README 章节摘录(可合理截断并标明);README 没有对应章节的留空,不编造。

我的用法
bleak 用法示例说明可用 BleakScanner 发现可连接的蓝牙设备。
特点或设计要点
Bleak支持读取、写入和接收GATT服务器通知,并具备发现BLE设备的功能。
星标走势还差一天的数据,明天就能看到曲线
每天 10:30 记一次星标,连续两天后自动生成曲线
首次发现 — · 最近在榜 2026-11-21 · 语言 Python · 贡献者 —
cli

GitHub 项目主页介绍

来自 GitHub 仓库 README / 主页介绍正文,原样摘录,共 2,636 字节。

=====
Bleak
=====

.. image:: https://github.com/hbldh/bleak/workflows/Build%20and%20Test/badge.svg
    :target: https://github.com/hbldh/bleak/actions?query=workflow%3A%22Build+and+Test%22
    :alt: Build and Test

.. image:: https://img.shields.io/pypi/v/bleak.svg
    :target: https://pypi.python.org/pypi/bleak

.. image:: https://img.shields.io/pypi/dm/bleak.svg
    :target: https://pypi.python.org/pypi/bleak
    :alt: PyPI - Downloads

.. image:: https://readthedocs.org/projects/bleak/badge/?version=latest
    :target: https://bleak.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black

.. container::

    .. image:: Bleak_logo2.png
        :target: https://github.com/hbldh/bleak
        :alt: Bleak Logo

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

* Free software: MIT license
* Documentation: https://bleak.readthedocs.io.

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
------------

.. code-block:: bash

    $ pip install bleak

Features
--------

* Supports Windows 11, version 22000 and greater
* Supports Linux distributions with BlueZ >= 5.55
* OS X/macOS support via Core Bluetooth API, from at least OS X version 10.15
* 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:

.. code-block:: python

    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:

.. code-block:: python

    import asyncio
    from bleak import BleakClient

    address = "24:71:89:cc:09:05"
    MODEL_NBR_UUID = "2A24"

    async def main(address):
        async with BleakClient(address) as client:
            model_number = await client.read_gatt_char(MODEL_NBR_UUID)
            print(f"Model Number: {model_number.decode()}")

    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 <http://www.ti.com/ww/en/wireless_connectivity/sensortag/>`_
↑