Python Forum
Scan for Bluetooth device - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Scan for Bluetooth device (/thread-36018.html)



Scan for Bluetooth device - korenron - Jan-10-2022

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,