Microtube Docs
Developers / Guides / Python integration

Python integration

Drive the HEXR glove directly from Python over Bluetooth (BLE) with the HaptGlovePython library.

Install

Clone the library and install its dependencies:

shell
git clone https://github.com/MicrotubeTechnologies/HaptGlovePython.git
cd HaptGlovePython
pip install -r requirements.txt
Note

The library talks to the glove over BLE using bleak. It runs from a clone — it isn't published to PyPI yet, so there's no pip install haptglove (adding a pyproject.toml to the repo would enable it).

Find your glove

Run the discovery script to list nearby gloves and get the Bluetooth address, then set it in your example:

shell
python AddressDiscovery.py

Your first pulse

Connect and send pressure to every finger for a few seconds:

python
import asyncio
from bleak import BleakClient
from Haptics import Haptics

ADDRESS   = "EC:C9:FF:45:92:86"   # your glove (AddressDiscovery.py)
CHAR_UUID = "0000ff01-0000-1000-8000-00805f9b34fb"

async def main():
    haptics = Haptics("right")
    async with BleakClient(ADDRESS) as client:
        F = Haptics.Finger   # enum members, not strings
        data = haptics.hexr_pressure_multiple(
            [F.Thumb, F.Index, F.Middle, F.Ring, F.Pinky, F.Palm],
            [True]*6,   # apply
            [0.8]*6,    # intensity 0.1-1.0
            [1.0]*6)    # ramp speed 0.1-1.0
        await client.write_gatt_char(CHAR_UUID, data)
        await asyncio.sleep(5)

asyncio.run(main())
Tip

Start from ExampleHaptics.py in the repo — it's a ready-to-run version of the above.