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
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.
git clone https://github.com/karulis/pybluez.git
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…
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 https://github.com/Michael-Jalloh/pi-discovery.git
Inside the folder we just clone the is a script called launcher.sh, copy that script to the pi folder. Then make it executable then execute the script.
chmod 755 launcher.sh
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.
sudo crontab -e
after opening the file at the end of the of it add there the line below.
@reboot sh /home/pi/launcher.sh >/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 https://github.com/Michael-Jalloh/find-pi.git
Now just enter an ip that the network is using, for instance if your network is using ip 192.168.1.1 enter 192.168.1.1, make sure that both the computer you are using the raspberry are on the same network.
This is your very first post. Click the Edit link to modify or delete it, or start a new post. If you like, use this post to tell readers why you started this blog and what you plan to do with it.