# Python Bluetooth libraries

Python Bluetooth libraries scan for nearby devices, connect to them, and read or write their data. A Bluetooth Low Energy client talks to a device through GATT services and characteristics. These libraries let IoT tools, home automation systems, and test rigs control sensors and wearables.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Bleak](#bleak) | 2.4M | 2.6K | Nov 2026 | MIT |
| [habluetooth](#habluetooth) | 1.3M | 24 | Nov 2026 | Apache-2.0 |
| [Bleak Retry Connector](#bleak-retry-connector) | 852.4K | 28 | Sep 2026 | MIT |
| [Bumble](#bumble) | 169.1K | 591 | Oct 2026 | Apache-2.0 |
| [SimplePyBLE](#simplepyble) | 104.7K | 1.2K | Nov 2026 | BUSL-1.1 |
| [aioblescan](#aioblescan) | 89.9K | 127 | Jan 2023 | MIT |
| [bleak-esphome](#bleak-esphome) | 65.5K | 14 | Aug 2026 | MIT |
| [Bless](#bless) | 33.5K | 197 | Dec 2025 | MIT |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Bleak](#bleak) has the most monthly downloads in this comparison, at 2.3M.

## Capabilities

| Library | Local GATT server | Classic RFCOMM stack |
| --- | --- | --- |
| [Bleak](#bleak) | No | No |
| [habluetooth](#habluetooth) | No | No |
| [Bleak Retry Connector](#bleak-retry-connector) | No | No |
| [Bumble](#bumble) | Yes | Yes |
| [SimplePyBLE](#simplepyble) | Yes | No |
| [aioblescan](#aioblescan) | No | No |
| [bleak-esphome](#bleak-esphome) | No | No |
| [Bless](#bless) | Yes | No |

## Libraries

### Bleak

[GitHub](https://github.com/hbldh/bleak) · [PyPI](https://pypi.org/project/bleak) · [Docs](https://bleak.readthedocs.io/en/latest/api/client.html)

Connects to Bluetooth Low Energy devices as an asynchronous GATT client.

- Downloads / mo: 2.4M
- Stars: 2.6K
- Last release: 3.1.0
- License: MIT
- Capabilities: [From the Bleak docs](https://bleak.readthedocs.io/en/latest/api/client.html)

**Strengths**

- **Cleans up managed connections.** An async context manager connects and disconnects the client.
- **Reads and subscribes to characteristics.** Read values, write values, or receive GATT notifications.

**Watch out for**

- **Classic RFCOMM needs another library.** Bleak handles BLE GATT rather than classic RFCOMM sockets.
- **Address-based connections trigger discovery.** Pass a discovered BLEDevice when connecting to multiple devices.

```sh
python3.11 -m pip install bleak==3.1.0
```

**home-assistant/core** (92.3K stars)

[home-assistant/core](https://github.com/home-assistant/core) 

```python
async def _async_see_update_ble_battery(
    mac: str,
    now: datetime,
    service_info: bluetooth.BluetoothServiceInfoBleak,
) -> None:
    """Lookup Bluetooth LE devices and update status."""
    battery = None
    # We need one we can connect to since the tracker will
    # accept devices from non-connectable sources
    if service_info.connectable:
        device = service_info.device
    elif connectable_device := bluetooth.async_ble_device_from_address(
        hass, service_info.device.address, True
    ):
        device = connectable_device
    else:
        # The device can be seen by a passive tracker but we
        # don't have a route to make a connection
        return
    try:
        async with BleakClient(device) as client:
            bat_char = await client.read_gatt_char(BATTERY_CHARACTERISTIC_UUID)
            battery = ord(bat_char)
    except TimeoutError:
        _LOGGER.debug(
            "Timeout when trying to get battery status for %s", service_info.name
        )
    # Bleak currently has a few places where checking dbus attributes
    # can raise when there is another error. We need to trap AttributeError
    # until bleak releases v0.15+ which resolves these.
    except (AttributeError, BleakError) as err:
        _LOGGER.debug("Could not read battery status: %s", err)
        # If the device does not offer battery information,
        # there is no point in asking again later on.
        # Remove the device from the battery-tracked
        # devices, so that their battery is not wasted
        # trying to get an unavailable information.
        del devs_track_battery[mac]
    if battery:
        await async_see_device(mac, service_info.name, battery=battery)
```

[homeassistant/components/bluetooth_le_tracker/device_tracker.py](https://github.com/home-assistant/core/blob/eca50a4e0d47a97f44061418ffcbfb918d4d2a61/homeassistant/components/bluetooth_le_tracker/device_tracker.py) · [More projects using Bleak →](https://dashboard.exa.ai/playground/search?q=Real%20projects%20using%20bleak%20for%20Bluetooth%20device%20communication&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import asyncio
from bleak import BleakScanner

async def main():
    print(await BleakScanner.discover())

asyncio.run(main())

```

From [usage.html](https://bleak.readthedocs.io/en/latest/api/client.html)

### habluetooth

[GitHub](https://github.com/Bluetooth-Devices/habluetooth) · [PyPI](https://pypi.org/project/habluetooth) · [Docs](https://habluetooth.readthedocs.io/en/latest/)

Provides high-availability Bluetooth management.

- Downloads / mo: 1.3M
- Stars: 24
- Last release: 7.1.3
- License: Apache-2.0
- Capabilities: [From the habluetooth docs](https://habluetooth.readthedocs.io/en/latest/)

```sh
python3.11 -m pip install habluetooth==7.1.3 bleak==3.1.0
```

**home-assistant/core** (92.3K stars)

[home-assistant/core](https://github.com/home-assistant/core) 

```python
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
    """Set up a config entry for a bluetooth scanner."""
    if source_entry_id := entry.data.get(CONF_SOURCE_CONFIG_ENTRY_ID):
        if not (source_entry := hass.config_entries.async_get_entry(source_entry_id)):
            # Cleanup the orphaned entry using a call_soon to ensure
            # we can return before the entry is removed
            hass.loop.call_soon(
                hass_callback(
                    lambda: hass.async_create_task(
                        hass.config_entries.async_remove(entry.entry_id),
                        "remove orphaned bluetooth entry {entry.entry_id}",
                    )
                )
            )
            return
        address = entry.unique_id
        assert address is not None
        source_domain = entry.data[CONF_SOURCE_DOMAIN]
        if mac_manufacturer := await get_manufacturer_from_mac(address):
            manufacturer = f"{mac_manufacturer} ({source_domain})"
        else:
            manufacturer = source_domain
        details = AdapterDetails(
            address=address,
            product=entry.data.get(CONF_SOURCE_MODEL),
            manufacturer=manufacturer,
        )
        await async_update_device(
            hass,
            entry,
            source_entry.title,
            details,
            entry.data.get(CONF_SOURCE_DEVICE_ID),
        )
        return
    manager = _get_manager(hass)
    address = entry.unique_id
    assert address is not None
    adapter = await manager.async_get_adapter_from_address_or_recover(address)
    if adapter is None:
        raise ConfigEntryNotReady(
            f"Bluetooth adapter {adapter} with address {address} not found"
        )
    adapters = await manager.async_get_bluetooth_adapters()
    details = adapters[adapter]
    mode = resolve_scanning_mode(entry.options)
    # AUTO needs passive scanning support to flip on demand; without it
    # the scanner would start passive on hardware that can't do passive.
    if mode is BluetoothScanningMode.AUTO and not details.get(ADAPTER_PASSIVE_SCAN):
        mode = BluetoothScanningMode.ACTIVE
    scanner = HaScanner(mode, adapter, address)
    entry.async_on_unload(scanner.async_setup())
    if entry.title == address:
        hass.config_entries.async_update_entry(
            entry, title=adapter_title(adapter, details)
        )
    slots: int = details.get(ADAPTER_CONNECTION_SLOTS) or DEFAULT_CONNECTION_SLOTS
    # Register the scanner before starting so
    # any raw advertisement data can be processed
    entry.async_on_unload(async_register_scanner(hass, scanner, connection_slots=slots))
    await async_update_device(hass, entry, adapter, details)
    try:
        await scanner.async_start()
    except (RuntimeError, ScannerStartError) as err:
        raise ConfigEntryNotReady(
            f"{adapter_human_name(adapter, address)}: {err}"
        ) from err
    entry.async_on_unload(entry.add_update_listener(async_update_listener))
    entry.async_on_unload(scanner.async_stop)
```

[homeassistant/components/bluetooth/__init__.py](https://github.com/home-assistant/core/blob/3df93331719fcb206ab24c165cadf1e796d52c02/homeassistant/components/bluetooth/__init__.py) · [More projects using habluetooth →](https://dashboard.exa.ai/playground/search?q=habluetooth%20GitHub%20projects)

**Quickstart**

```python
import asyncio
from habluetooth import BluetoothManager

async def main():
    manager = BluetoothManager()
    await manager.async_setup()
    try:
        print(await manager.async_get_bluetooth_adapters())
    finally:
        manager.async_stop()

asyncio.run(main())

```

From [manager.py](https://github.com/Bluetooth-Devices/habluetooth/blob/1388841581abf6264cb202c6628734d96bfa1ffc/src/habluetooth/manager.py)

### Bleak Retry Connector

[GitHub](https://github.com/Bluetooth-Devices/bleak-retry-connector) · [PyPI](https://pypi.org/project/bleak-retry-connector) · [Docs](https://bleak-retry-connector.readthedocs.io/en/latest/usage.html)

Retries Bleak client connections after transient failures.

- Downloads / mo: 852.4K
- Stars: 28
- Last release: 4.7.1
- License: MIT
- Capabilities: [From the Bleak Retry Connector docs](https://bleak-retry-connector.readthedocs.io/en/latest/usage.html)

```sh
python3.11 -m pip install bleak-retry-connector==4.7.1 bleak==3.1.0
```

**sblibs/pySwitchbot** (180 stars)

[sblibs/pySwitchbot](https://github.com/sblibs/pySwitchbot) 

```python
async def _ensure_connected(self):
    """Ensure connection to device is established."""
    if self._connect_lock.locked():
        _LOGGER.debug(
            "%s: Connection already in progress, waiting for it to complete; RSSI: %s",
            self.name,
            self.rssi,
        )
    if self._client and self._client.is_connected:
        _LOGGER.debug(
            "%s: Already connected before obtaining lock, resetting timer; RSSI: %s",
            self.name,
            self.rssi,
        )
        self._reset_disconnect_timer()
        return
    async with self._connect_lock:
        # Check again while holding the lock
        if self._client and self._client.is_connected:
            _LOGGER.debug(
                "%s: Already connected after obtaining lock, resetting timer; RSSI: %s",
                self.name,
                self.rssi,
            )
            self._reset_disconnect_timer()
            return
        _LOGGER.debug("%s: Connecting; RSSI: %s", self.name, self.rssi)
        client: BleakClientWithServiceCache = await establish_connection(
            BleakClientWithServiceCache,
            self._device,
            self.name,
            self._disconnected,
            use_services_cache=True,
            ble_device_callback=lambda: self._device,
        )
        _LOGGER.debug("%s: Connected; RSSI: %s", self.name, self.rssi)
        self._client = client

        try:
            self._resolve_characteristics(client.services)
        except CharacteristicMissingError as ex:
            _LOGGER.debug(
                "%s: characteristic missing, clearing cache: %s; RSSI: %s",
                self.name,
                ex,
                self.rssi,
                exc_info=True,
            )
            await client.clear_cache()
            self._cancel_disconnect_timer()
            await self._execute_disconnect_with_lock()
            raise

        _LOGGER.debug(
            "%s: Starting notify and disconnect timer; RSSI: %s",
            self.name,
            self.rssi,
        )
        self._reset_disconnect_timer()
        await self._start_notify()
```

[switchbot/devices/device.py](https://github.com/Danielhiversen/pySwitchbot/blob/ff409b2ee70672d2f50aae51a1250a6b9a942e45/switchbot/devices/device.py) · [More projects using Bleak Retry Connector →](https://dashboard.exa.ai/playground/search?q=bleak-retry-connector%20GitHub%20projects)

**Quickstart**

```python
import asyncio, os
from bleak import BleakScanner
from bleak_retry_connector import establish_connection, BleakClientWithServiceCache

async def main():
    device = await BleakScanner.find_device_by_address(os.environ["BLE_ADDRESS"])
    if device is None:
        raise RuntimeError("Device not found")
    client = await establish_connection(BleakClientWithServiceCache, device, device.name or device.address)
    try:
        print(client.services)
    finally:
        await client.disconnect()

asyncio.run(main())

```

From [usage.html](https://github.com/Bluetooth-Devices/bleak-retry-connector/blob/0bdeaf11d91aa954ee0973ba06c9aba52ddb9971/src/bleak_retry_connector/__init__.py)

### Bumble

[GitHub](https://github.com/google/bumble) · [PyPI](https://pypi.org/project/bumble) · [Docs](https://google.github.io/bumble/)

Implements a Bluetooth stack for apps, emulation, and testing.

- Downloads / mo: 169.1K
- Stars: 591
- Last release: 0.0.236
- License: Apache-2.0
- Capabilities: [From the Bumble docs](https://google.github.io/bumble/)

```sh
python3.11 -m pip install bumble==0.0.236
```

**raspberrypi/pico-examples** (4.0K stars)

[raspberrypi/pico-examples](https://github.com/raspberrypi/pico-examples) 

```python
def make_pairing_config(security: int) -> PairingConfig:
    """Return a Bumble PairingConfig matching the given security setting."""
    # All modes use Secure Connections (sc=True) and bonding, matching the
    # sm_set_secure_connections_only_mode(true) call in the Pico client.
    common = dict(sc=True, bonding=True)
    if security == 0:
        # Just Works: no I/O capability, no MITM
        return PairingConfig(mitm=False, delegate=PairingDelegate(
            io_capability=PairingDelegate.IoCapability.NO_OUTPUT_NO_INPUT,
        ), **common)
    elif security == 1:
        # Numeric Comparison: server displays, client confirms yes/no
        return PairingConfig(mitm=True, delegate=PairingDelegate(
            io_capability=PairingDelegate.IoCapability.DISPLAY_OUTPUT_AND_YES_NO_INPUT,
        ), **common)
    elif security == 2:
        # Keyboard + Display: matches IO_CAPABILITY_KEYBOARD_DISPLAY on the Pico.
        # Pairing method depends on the other side's capabilities.
        return PairingConfig(mitm=True, delegate=KeyboardDelegate(
            io_capability=PairingDelegate.IoCapability.DISPLAY_OUTPUT_AND_KEYBOARD_INPUT,
        ), **common)
    else:
        # security == 3: Display Only - matches IO_CAPABILITY_DISPLAY_ONLY on the Pico.
        # Requires the Pico client to be built with SECURITY_SETTING=2 (KEYBOARD_DISPLAY)
        # so it can enter the passkey we display here.
        return PairingConfig(mitm=True, delegate=DisplayDelegate(), **common)

```

[bluetooth/ble_secure_temp_sensor/ble_temp_server.py](https://github.com/raspberrypi/pico-examples/blob/0d62f75bafc2c8120d3276c3343d1a9195e909e9/bluetooth/ble_secure_temp_sensor/ble_temp_server.py#L118-L143) · [More projects using Bumble →](https://dashboard.exa.ai/playground/search?q=bumble%20GitHub%20projects)

**Quickstart**

```python
import asyncio, os
from bumble.device import Device
from bumble.hci import Address
from bumble.transport import open_transport

async def main():
    async with await open_transport(os.environ["BUMBLE_TRANSPORT"]) as transport:
        device = Device.with_hci("Bumble", Address("F0:F1:F2:F3:F4:F5"), transport.source, transport.sink)
        await device.power_on()
        await device.start_scanning()
        await asyncio.sleep(5)
        await device.stop_scanning()

asyncio.run(main())

```

From [device.py](https://github.com/google/bumble/blob/a679beb4f36681c6f1b6d72b7e825c6f57f9ef83/bumble/device.py)

### SimplePyBLE

[GitHub](https://github.com/simpleble/simpleble) · [PyPI](https://pypi.org/project/simplepyble) · [Docs](https://simpleble.readthedocs.io/en/latest/simplepyble.html)

Binds the cross-platform SimpleBLE library for Windows, macOS, and Linux, with a license required for commercial use.

- Downloads / mo: 104.7K
- Stars: 1.2K
- Last release: 1.4.0
- License: BUSL-1.1
- Capabilities: [From the SimplePyBLE docs](https://simpleble.readthedocs.io/en/latest/simplepyble.html)

```sh
python3.11 -m pip install simplepyble==1.4.0
```

**javl/InstaxBLE** (121 stars)

[javl/InstaxBLE](https://github.com/javl/InstaxBLE) 

```python
def connect(self, timeout=0):
    """ Connect to the printer. Stops trying after <timeout> seconds. """
    if self.dummyPrinter:
        return

    self.peripheral = self.find_device(timeout=timeout)
    if self.peripheral:
        try:
            self.log(f"Connecting to {self.peripheral.identifier()} [{self.peripheral.address()}]")
            self.peripheral.connect()
        except Exception as e:
            if not self.quiet:
                self.log(f'error on connecting: {e}')

        if self.peripheral.is_connected():
            # check if we're using a version of simplepyble that supports reading mtu
            self.log(f"Connected")

            # self.log('Attaching notification_handler')
            try:
                self.peripheral.notify(self.serviceUUID, self.notifyCharUUID, self.notification_handler)
            except Exception as e:
                if not self.quiet:
                    self.log(f'Error on attaching notification_handler: {e}')
                    return

            self.get_printer_info()
            sleep(1)
            self.display_current_status()

```

[InstaxBLE.py](https://github.com/javl/InstaxBLE/blob/804dca8cfaba5db48bc5f961aab106006e600303/InstaxBLE.py#L194-L222) · [More projects using SimplePyBLE →](https://dashboard.exa.ai/playground/search?q=simplepyble%20GitHub%20projects)

**Quickstart**

```python
import simplepyble

adapters = simplepyble.Adapter.get_adapters()
if not adapters:
    raise RuntimeError("No Bluetooth adapter found")
adapter = adapters[0]
adapter.scan_for(1000)
print(adapter.scan_get_results())

```

From [wrap_adapter.cpp](https://github.com/simpleble/simpleble/blob/53625c90ff922256baf1a1081b9dcee263390298/simplepyble/src/simplepyble/aio.py)

### aioblescan

[GitHub](https://github.com/frawau/aioblescan) · [PyPI](https://pypi.org/project/aioblescan)

Scans for Bluetooth advertisements with asyncio.

- Downloads / mo: 89.9K
- Stars: 127
- Last release: 0.2.14
- License: MIT
- Capabilities: [From the aioblescan docs](https://github.com/frawau/aioblescan)

```sh
python3.11 -m pip install aioblescan==0.2.14
```

**custom-components/ble_monitor** (2.3K stars)

[custom-components/ble_monitor](https://github.com/custom-components/ble_monitor) 

```python
def run(self):
    """Run HCIdump thread."""
    while True:
        _LOGGER.debug("HCIdump thread: Run")
        mysocket = {}
        fac = {}
        conn = {}
        btctrl = {}
        interface_is_ok = {}
        interfaces_to_reset = []
        initialized_evt = {}
        retry_handle = None
        if self._event_loop is None:
            self._event_loop = asyncio.new_event_loop()
        asyncio.set_event_loop(self._event_loop)
        if "disable" not in self.config[CONF_BT_INTERFACE]:
            for hci in self._interfaces:
                interface_is_ok[hci] = False
                try:
                    mysocket[hci] = aiobs.create_bt_socket(hci)
                except OSError as error:
                    _LOGGER.error("HCIdump thread: OS error (hci%i): %s", hci, error)
                else:
                    fac[hci] = getattr(
                        self._event_loop, "_create_connection_transport"
                    )(mysocket[hci], aiobs.BLEScanRequester, None, None)
                    conn[hci], btctrl[hci] = self._event_loop.run_until_complete(
                        fac[hci]
                    )
                    # Wait up to five seconds for aioblescan BLEScanRequester to initialize
                    initialized_evt[hci] = getattr(btctrl[hci], "_initialized")
                    _LOGGER.debug(
                        "HCIdump thread: BLEScanRequester._initialized is %s for hci%i, "
                        " waiting for connection...",
                        initialized_evt[hci].is_set(),
                        hci,
                    )
                    try:
                        self._event_loop.run_until_complete(asyncio.wait_for(initialized_evt[hci].wait(), 5))
                    except asyncio.TimeoutError:
                        _LOGGER.warn(
                            "HCIdump thread: Something wrong - interface hci%i not ready,"
                            " and will be skipped for current scan period.",
                            hci,
                        )
                        conn[hci].close()
                        fac[hci].close()
                        mysocket[hci].close()
                    else:
                        btctrl[hci].process = partial(
                            self.process_hci_events, hci=hci
                        )
                        _LOGGER.debug("HCIdump thread: connected to hci%i", hci)
                        try:
                            self._event_loop.run_until_complete(
                                btctrl[hci].send_scan_request(self._active)
                            )
                        except RuntimeError as error:
                            _LOGGER.error(
                                "HCIdump thread: Runtime error while sending scan request on hci%i: %s.",
                                hci,
                                error,
                            )
                            conn[hci].close()
                            fac[hci].close()
                            mysocket[hci].close()
                        else:
                            interface_is_ok[hci] = True
                            self._record_hci_activity(hci)
                            _LOGGER.debug(
                                "HCIdump thread: BLEScanRequester._initialized is %s for hci%i, "
                                " connection established, send_scan_request succeeded.",
                                initialized_evt[hci].is_set(),
                                hci,
                            )
                if interface_is_ok[hci] is False:
                    self._last_hci_activity.pop(hci, None)
                if (interface_is_ok[hci] is False) and (self.config[CONF_BT_AUTO_RESTART] is True):
                    interfaces_to_reset.append(hci)
            if interfaces_to_reset:
                ts_now = time.monotonic()
                if ts_now - self.last_bt_reset > 60:
                    for iface in interfaces_to_reset:
                        _LOGGER.error(
                            "HCIdump thread: Trying to power cycle Bluetooth adapter hci%i %s,"
                            " will try to use it next scan period.",
                            iface,
                            BT_INTERFACES[iface],
                        )
                        reset_bluetooth(iface)
                    self.last_bt_reset = ts_now
            if not all(interface_is_ok.values()):
                retry_handle = self._schedule_scan_retry()
        self._schedule_watchdog()
        _LOGGER.debug("HCIdump thread: start main event_loop")
        try:
            self._event_loop.run_forever()
        finally:
            _LOGGER.debug("HCIdump thread: main event_loop stopped, finishing.")
            if self._watchdog_handle is not None:
                self._watchdog_handle.cancel()
                self._watchdog_handle = None
            if retry_handle is not None:
                retry_handle.cancel()
            if "disable" not in self.config[CONF_BT_INTERFACE]:
                for hci in self._interfaces:
                    if interface_is_ok[hci] is True:
                        try:
                            self._event_loop.run_until_complete(
                                btctrl[hci].stop_scan_request()
                            )
                        except RuntimeError as error:
                            _LOGGER.error(
                                "HCIdump thread: Runtime error while stop scan request on hci%i: %s.",
                                hci,
                                error,
                            )
                        except KeyError:
                            _LOGGER.debug(
                                "HCIdump thread: Key error while stop scan request on hci%i",
                                hci,
                            )
                    try:
                        conn[hci].close()
                        fac[hci].close()
                        mysocket[hci].close()
                    except KeyError:
                        _LOGGER.debug(
                            "HCIdump thread: Key error while closing connection on hci%i",
                            hci,
                        )
                    self._last_hci_activity.pop(hci, None)
            self._event_loop.run_until_complete(asyncio.sleep(0))
        if self._joining is True:
            break
        _LOGGER.debug("HCIdump thread: Scanning will be restarted")
        _LOGGER.debug(
            "HCI events processed for previous scan: %s", self.evt_cnt
        )
        self.evt_cnt = {}
    self._event_loop.close()
    _LOGGER.debug("HCIdump thread: Run finished")
```

[custom_components/ble_monitor/__init__.py](https://github.com/custom-components/ble_monitor/blob/a89251f8b47f25ba48176642f4fc63e4951d78d2/custom_components/ble_monitor/__init__.py) · [More projects using aioblescan →](https://dashboard.exa.ai/playground/search?q=aioblescan%20GitHub%20projects)

**Quickstart**

```python
python3.11 -m aioblescan -D 0

```

From [README.md](https://github.com/frawau/aioblescan/blob/233a402248d176f15e07335d4a0d919d4391fdb6/aioblescan/aioblescan.py)

### bleak-esphome

[GitHub](https://github.com/Bluetooth-Devices/bleak-esphome) · [PyPI](https://pypi.org/project/bleak-esphome) · [Docs](https://bleak-esphome.readthedocs.io/en/latest/usage.html)

Provides the ESPHome backend for Bleak.

- Downloads / mo: 65.5K
- Stars: 14
- Last release: 4.1.0
- License: MIT
- Capabilities: [From the bleak-esphome docs](https://bleak-esphome.readthedocs.io/en/latest/usage.html)

```sh
python3.11 -m pip install bleak-esphome==4.1.0 bleak==3.1.0 habluetooth==7.1.3
```

**home-assistant/core** (92.3K stars)

[home-assistant/core](https://github.com/home-assistant/core) 

```python
@hass_callback
def async_connect_scanner(
    hass: HomeAssistant,
    entry: ESPHomeConfigEntry,
    entry_data: RuntimeEntryData,
    cli: APIClient,
    device_info: DeviceInfo,
    device_id: str,
) -> CALLBACK_TYPE:
    """Connect scanner."""
    client_data = connect_scanner(cli, device_info, entry_data.available)
    entry_data.bluetooth_device = client_data.bluetooth_device
    client_data.disconnect_callbacks = entry_data.disconnect_callbacks
    scanner = client_data.scanner
    if TYPE_CHECKING:
        assert scanner is not None
    api_version = cli.api_version or APIVersion()
    feature_flags = device_info.bluetooth_proxy_feature_flags_compat(api_version)
    state_and_mode = bool(feature_flags & BluetoothProxyFeature.FEATURE_STATE_AND_MODE)
    # Pin mode before async_register_scanner so habluetooth spawns the AUTO worker.
    deferred_migration: CALLBACK_TYPE | None = None
    if state_and_mode:
        deferred_migration = _async_apply_scanning_mode(hass, entry, scanner, cli)
    callbacks: list[CALLBACK_TYPE] = [
        async_register_scanner(
            hass,
            scanner,
            source_domain=DOMAIN,
            source_model=device_info.model,
            source_config_entry_id=entry_data.entry_id,
            source_device_id=device_id,
        ),
        scanner.async_setup(),
    ]
    if deferred_migration is not None:
        callbacks.append(deferred_migration)
    return partial(_async_unload, callbacks)
```

[homeassistant/components/esphome/bluetooth.py](https://github.com/home-assistant/core/blob/3df93331719fcb206ab24c165cadf1e796d52c02/homeassistant/components/esphome/bluetooth.py) · [More projects using bleak-esphome →](https://dashboard.exa.ai/playground/search?q=bleak-esphome%20GitHub%20projects)

**Quickstart**

```python
import asyncio, os
from habluetooth import BluetoothManager
from bleak import BleakScanner
from bleak_esphome import APIConnectionManager

async def main():
    manager = BluetoothManager()
    await manager.async_setup()
    connection = APIConnectionManager({"address": os.environ["ESPHOME_HOST"], "noise_psk": os.getenv("ESPHOME_NOISE_PSK")})
    try:
        await connection.start()
        print(await BleakScanner.discover())
    finally:
        await connection.stop()
        manager.async_stop()

asyncio.run(main())

```

From [usage.html](https://github.com/Bluetooth-Devices/bleak-esphome/blob/d9423774aac79ed969730205bfb42da7f70fbd59/src/bleak_esphome/connect.py)

### Bless

[GitHub](https://github.com/kevincar/bless) · [PyPI](https://pypi.org/project/bless) · [Docs](https://api.github.com/repos/kevincar/bless/contents/bless/backends/server.py?ref=v0.3.0)

Creates a Bluetooth Low Energy GATT server with custom services and characteristics.

- Downloads / mo: 33.5K
- Stars: 197
- Last release: 0.3.0
- License: MIT
- Capabilities: [From the Bless docs](https://api.github.com/repos/kevincar/bless/contents/bless/backends/server.py?ref=v0.3.0)

**Strengths**

- **Serves custom BLE characteristics.** Define services and characteristics for BLE clients to read or write.
- **Routes callbacks per characteristic.** Override a characteristic callback before falling back to server-wide handling.

**Watch out for**

- **Writes need explicit callbacks.** Define a write callback to handle incoming values.
- **Windows needs another setup package.** Install pysetupdi alongside Bless on Windows.

```sh
python3.11 -m pip install bless==0.3.0
```

**Jakeler/ble-serial** (390 stars)

[Jakeler/ble-serial](https://github.com/Jakeler/ble-serial) 

```python
async def setup_chars(self, service_uuid: str, write_uuid: str, read_uuid: str, mode: str, write_response_required: bool):
    self.read_enabled = 'r' in mode
    self.write_enabled = 'w' in mode

    self.service_uuid = service_uuid
    self.write_uuid = check_fill_empty(service_uuid, write_uuid, 'write')
    self.read_uuid = check_fill_empty(service_uuid, read_uuid, 'read')

    await self.server.add_new_service(self.service_uuid)
    self.service = self.server.get_service(self.service_uuid)
    logging.info(f'Service {self.service_uuid}')

    if self.write_enabled:
        # self.write_uuid = "0000ffe1-0000-1000-8000-00805f9b34fb"
        char_flags = (
            GATTCharacteristicProperties.write if write_response_required else
            GATTCharacteristicProperties.write_without_response)
        permissions = GATTAttributePermissions.readable | GATTAttributePermissions.writeable
        await self.server.add_new_characteristic(self.service_uuid, self.write_uuid,
            char_flags, None, permissions)

        self.write_char = self.server.get_characteristic(self.write_uuid)
        logging.info(f'Write characteristic: {str(self.write_char)}')
    else:
        logging.info('Writing disabled, no characteristic to setup')

    if self.read_enabled:
        char_flags = GATTCharacteristicProperties.read | GATTCharacteristicProperties.notify
        permissions = GATTAttributePermissions.readable | GATTAttributePermissions.writeable
        await self.server.add_new_characteristic(self.service_uuid, self.read_uuid,
            char_flags, None, permissions)

        self.read_char = self.server.get_characteristic(self.read_uuid)
        logging.info(f'Read characteristic: {str(self.read_char)}')

        self.data_read_done.set()
    else:
        logging.info('Reading disabled, no characteristic to setup')

```

[ble_serial/bluetooth/ble_server.py](https://github.com/Jakeler/ble-serial/blob/cf84f02cfa90dab81635a7e13afb34ccbb72db15/ble_serial/bluetooth/ble_server.py#L34-L71) · [More projects using Bless →](https://dashboard.exa.ai/playground/search?q=Real%20projects%20using%20bless%20for%20Bluetooth%20device%20communication&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import asyncio
from bless import BlessServer, GATTCharacteristicProperties, GATTAttributePermissions

async def main():
    server = BlessServer(name="BLE example")
    service = "0000180f-0000-1000-8000-00805f9b34fb"
    characteristic = "00002a19-0000-1000-8000-00805f9b34fb"
    await server.add_new_service(service)
    await server.add_new_characteristic(service, characteristic, GATTCharacteristicProperties.read, bytearray([100]), GATTAttributePermissions.readable)
    server.read_request_func = lambda item, **kwargs: item.value
    await server.start()
    try:
        await asyncio.sleep(5)
    finally:
        await server.stop()

asyncio.run(main())

```

From [server.py](https://github.com/kevincar/bless/blob/3d639708c373a31de746d5cefe6ab512e3887386/bless/backends/server.py)

## FAQ

### Which Python Bluetooth library should I use?

[Bleak](#bleak) suits cross-platform Bluetooth Low Energy clients with asyncio. [Bless](#bless) suits code that must act as a GATT server. [Bumble](#bumble) suits emulation and testing with a full Bluetooth stack in Python.

### What is Bleak?

[Bleak](#bleak) is an asynchronous Bluetooth Low Energy client for Windows, macOS, and Linux. It scans for devices and reads, writes, and subscribes to GATT characteristics.

### How do I use Bluetooth on a Raspberry Pi with Python?

[Bleak](#bleak) runs on Raspberry Pi OS through the BlueZ stack. Classic Bluetooth serial connections use the operating system's sockets instead.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python Bluetooth libraries Bleak bluepy PyBluez Bless code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
