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
cd pygattlib
sudo python 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
cd pybluez
sudo python 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…


Raspberry pi Network Discovery

In this post we will be configuring the raspberry pi to start up a script we created when it boots, this is more of a reminder for me for when I will want to do it again in the future.

Now we will be launching a python script, what the script does is that it starts up udp server that sits and waits for a client to send a specific message, If it receives that message it will give back a reply and then exit, or else it will ignore the message and then go back to waiting for another message. Now you will need access to the raspberry pi. The script is hosted on github. So you will need to install git. Open terminal and type in the command below.

sudo apt-get install git

After the the git installation, clone the script from github by typing the command below.

git clone

Inside the folder we just clone the is a script called, copy that script to the pi folder. Then make it executable then execute the script.
chmod 755

press CTRL-C to stop the script. Now add the luncher script to cron tab for it to run when the pi boots up.

create a folder that will hold the logs if anything goes wrong.

mkdir logs

sudo crontab -e

after opening the file at the end of the of it add there the line below.

@reboot sh /home/pi/ >/home/pi/logs/cronlog 2>&1

Now reboot the pi. And lets test it. On another computer download the script that will be use to find our pi, cd into the directory then execute the script.
git clone
cd find-pi

Now just enter an ip that the network is using, for instance if your network is using ip enter, make sure that both the computer you are using the raspberry are on the same network.