Python Forum

Full Version: Scan for Bluetooth device
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello ,
I'm trying to scan for bluetooth devices around me
I'm using this simple code I have found here (
https://geektechstuff.com/2020/06/01/python-and-bluetooth-part-1-scanning-for-devices-and-services-python/
# geektechstuff bluetooth

import bluetooth

def scan():

    print("Scanning for bluetooth devices:")

    devices = bluetooth.discover_devices(lookup_names = True, lookup_class = True)

    number_of_devices = len(devices)

    print(number_of_devices,"devices found")

    for addr, name, device_class in devices:

        print("\n")

        print("Device:")

        print("Device Name: %s" % (name))

        print("Device MAC Address: %s" % (addr))

        print("Device Class: %s" % (device_class))

        print("\n")

    return
when I run it it show me a list of devices my computer allready know and connect to them in the past
1. why is it ?
2. what do I need to in order to scan and see "Live" devices?

Thanks,