I developed some BLE device discovery python codes from the example given in https://github.com/pybluez/pybluez/blob/master/examples/ble/scan.py which are run on a Google AIY Raspberry pi.

from bluetooth.ble import DiscoveryService

service = DiscoveryService()

devices = service.discover(2)

for address, name in devices.items():

print("name: {}, address: {}".format(name, address))

The problem is, my python codes can only catch 2 BLE & classic Bluetooth devices nearby while the Bluetooth panel in Raspberry Pi shows 5 devices. Why is there such a big difference?

Or how can I or which library should I use for developing a BLE device discoverer which can catch as many as devices as the OS does?

  • Why is there such a big difference? ... different code works differently – jsotola Aug 5 '18 at 1:27
  • How different can they be? This sounds like a BLE discovery sensitive issue? If this is the case, should the senitivity be a function of hardware and DSP only? – Shu Aug 5 '18 at 2:08
  • what is 2 in service.discover(2)? – Jaromanda X Aug 5 '18 at 2:38
  • What is the context of service.discover(2)? If it tells you that it's a man page, part 2 are system calls. For a full definition of all the man sections, do a "man man" – NomadMaker Aug 5 '18 at 3:00
  • @Jaromanda The '2' in ' service.discover(2) ' is an example of the discovering duration in seconds. I changed it to be 10 seconds and it didn't change the result. – Shu Aug 5 '18 at 6:22

I never got PyBluez to work correctly, seeing all the devices that bluetoothctl was finding. But PyBlue seems to work a lot better, at least on Raspberry Pi Zero W.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.