How to setup Bluetooth on the Raspberry pi 3 to work with python

Hi in this post, I will be going through the process of setting up bluetooth on the pi, am actually setting up bluetooth on one of my pi 3 right now. Am starting we a clean install Raspbian os here. The python module we will be use is pybluez here. Lets get started.

We using raspbian but I think any other os should work but I haven’t tried them, so I can guarantee them.

Connect your pi3 to your network, and make sure that it has internet access. There are quite a few apps we need to download to set it up.  One the problems that have been giving people problems in the beginning, myself included were dependencies issues, The pybluez as of this writing depends of pygattlib, so all the dependencies of pygattlib should be installed,  if not sometimes the after setting up everything the some features wouldn’t work. So begin with the dependencies first.

open your terminal and install these dependencies.

sudo apt-get install mercurial pkg-config libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python-dev

When all the installation are done  now clone the pygattlib.
hg clone https://bitbucket.org/OscarAcena/pygattlib
cd pygattlib
sudo python setup.py install

That will install pygattlib now what we need next is pybluez, This is the actual module we will be using to interact with our bluetooth module on the pi 3.
cd ..
git clone https://github.com/karulis/pybluez.git
cd pybluez
sudo python setup.py install

And that my ladies and gentlemen is how we setup bluetooth on the raspberrypi 3, its as easy as pi, you can now test out if everything worked. You can try out some examples in the pybluez example folder. Remember to always use bluetooth with “`sudo“`. I will be creating a post on how to use the bluetooth module to communicate later…

Advertisements

One thought on “How to setup Bluetooth on the Raspberry pi 3 to work with python”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s