Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Python GATT Module

Project description

pygatt - Python Module for Bluetooth LE Generic Attribute Profile (GATT).

This Module allows reading and writing to GATT descriptors on devices such as
fitness trackers, sensors, and anything implementing standard GATT Descriptor behavior.

pygatt wraps BlueZ's `gatttool` command-line utility with a Pythonic API.


`gatttool` has an interactive mode but it is difficult to use programatically.
Ideally we could use BlueZ directly, but that's a much bigger task.

* Currently only tested under Linux as it requires `gatttool` which is included with BlueZ which is a Linux library.
* BlueZ >= 5.5
* Tested on 5.18 and 5.21
* Ubuntu is stuck on BlueZ 4.x and does not work - you need to build BlueZ
from source.

* Install via pip: `$ pip install pygatt`

Usage Example
Connect to a bGeigie Nano using BLEBee and decode sensor data (NMEA-like):

.. code:: python

import pygatt

str_buf = ''
def print_str_buf(x,y):
global str_buf
str_y = "%s" % y
if str_y == '$':
print str_buf
sb = str_y
str_buf = str_buf + str_y

bgn = pygatt.pygatt.BluetoothLEDevice('00:07:80:71:D5:89')
bgn.char_write(32, bytearray([0x03, 0x00]))
bgn.subscribe('a1e8f5b1-696b-4e4c-87c6-69dfe0b0093b', print_str_buf)

This should print something like:

.. parsed-literal::


Greg Albrecht <>

Derived from the work of several others, see NOTICE.

Apache License, Version 2.0. See LICENSE.

Copyright 2015 Orion Labs, Inc.


Project details

Download files

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

Files for pygatt, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size pygatt-1.2.0.tar.gz (6.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page