Search code examples
python-3.xbluetoothpython-venvgopro

I can't find Bluetooth devices using Bleak and asyncio


I am building a project using a GoPro camera I found. There is a free API from GoPro itself, I followed the tutorial on how to use BLE. To try to see if everything was working I used this simple program to find the Bluetooth device but nothing happened, it found nothing. I am using Python 3.10 on a Mac M1 and my Bluetooth is open.

import asyncio
import bleak
from bleak import BleakScanner

async def main():
    devices = await BleakScanner.discover()
    for d in devices:
        print(d,"yes i found it")

asyncio.run(main())

Solution

  • The problem might be related to the fact that Bleakscanner.discover() finishes before the advertisement from the GoPro. As per the description that is given in the example you followed from the documentation, it only scans for 5 seconds before stopping. I suggest you use the next example and play with the sleep time to see if you have any success at all.