Search Bluetooth Devices using Python.

I was trying to make some program to enable communication over Bluetooth using my Raspberry Pi 3. So I come up with this basic program to get started with this topic. I hope this will be helpful.

For Setting up Bluetooth in Raspberry Pi or in your laptop run the following command from your terminal.

sudo pip install pybluz

Now the coding part.

import bluetooth
print 'Sreaching for nearby devices...'
print 'found %d devices'%len(nearby_devices)

for addr,name in nearby_devices:
print ' %s - %s'%(addr,name)
print ' %s - %s' % (addr, name.encode('utf-8','replace'))

This will print all the nearby devices. There are many wonderful things we can do with this small piece of code. Like you can Turn on your laptop when ever you come near automatically using your phone’s Bluetooth. You can make your own chatting application using this.

This can be very useful for the embedded devices like Raspberry Pi to communicate with other devices using Bluetooth. We can control different peripherals attached to the Rasp Berry p using this.

There are enormous uses we can think of.