Recent

Wednesday, May 17, 2017

The 5 Minute Guide to Setup a Raspberry Pi for Bluetooth Development

Pre-requisites

The pre-requisite for this guide is to have a stock Raspberry Pi 3 running the latest version of Raspbian. To do this simply:

1) Download the official latest image here.

2) Follow the official instructions to transfer the image to an SD card.

Raspberry Pi Development Setup

There are three ways to setup your development environment. One option is to hook up an HDMI monitor, keyboard and mouse and develop directly on the Raspberry Pi. The other two options are to use a laptop and remotely connect to the Raspberry Pi either using Ethernet (or WiFi) or serial to USB connection.

I strongly recommend purchasing a Raspberry Pi Serial to USB cable and setting up a serial to USB connection because it allows you to develop offline, allowing you the freedom to develop in a coffee shop or anywhere because you don't need to have the Raspberry Pi connected to a network.

 Raspberry Pi Environment Setup

Once you have setup your physical development environment here are some key packages to install using the command line.

VI Improved (VIM)

sudo apt-get install vim

There are people that wear it as a Badge of Honor that they know VI the Unix text editor inside and out. I am not one of those people and for me, VIM is the defacto.

Bluetooth Development Header Files

sudo apt-get install libbluetooth

This package contains the necessary headers used to compile Bluetooth related packages. Install this package will fix the situation when you see the following error: fatal error: bluetooth/bluetooth.h: No such file or directory

Python Development Header Files

sudo apt-get install python-dev

This package contains the necessary headers to compile Python related packages. Install this package will fix the situation where you see the following error: fatal error: Python.h: No such file or directory

Python Wrapper for BlueZ

sudo pip install PyBluez

BlueZ is the official Bluetooth stack for Linux. BlueZ utilizes the C programming language. PyBluez is a wrapper around the BlueZ to allow the use of Python to interface with the Bluetooth stack.

Albert Huang wrote a great introduction to Bluetooth programming that provides a good high level overview. What I found particular helpful was his PyBlueZ examples

10 comments:

  1. Nice and very helpful information i have got from your post : learn more

    ReplyDelete
  2. I had to use sudo apt-get install libbluetooth-dev then I could install the Wrapper

    ReplyDelete
  3. The BLuetooth Development headers gave me a problem until I went here.
    https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=187871&p=1184190&hilit=libbluetooth#p1184190

    ReplyDelete
  4. E: Unable to locate package libbluetooth
    Should it be libbluetooth3?

    ReplyDelete
  5. I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    thesis Writing Service

    ReplyDelete
  6. New web site is looking good. Thanks for the great effort. click here

    ReplyDelete
  7. Flutter Programming is one of the most popular in the cross platforms industry. Offshore Flutter Development Service
    We build excellent flutter mobile app and also learn how to overcome performance issues. is the best choice for all startups to discuss and get their project quotation. We also enable many startups to do Proof of concept and help them to learn about business decisions.

    ReplyDelete
  8. Thanks for sharing such a great information. Flutter framework is mostly used nowadays, as every business is building apps for both Android and iOS. It is the best known cross platform framework for app development in Austin.

    ReplyDelete
  9. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. Kopar at Newton at Newton MRT Station

    ReplyDelete