Install bluez on the Raspberry Pi



Similar documents
Bluefruit LE Python Library

Adafruit NFC/RFID on Raspberry Pi

Raspberry Pi Kernel-o-Matic

How to Install Multicraft on a VPS or Dedicated Server (Ubuntu bit)

Setting up a Raspberry Pi as a WiFi access point

Adding a Real Time Clock to Raspberry Pi

Adafruit's Raspberry Pi Lesson 6. Using SSH

Monitor Your Home With the Raspberry Pi B+

Cloud Homework instructions for AWS default instance (Red Hat based)

Adafruit's Raspberry Pi Lesson 1. Preparing an SD Card for your Raspberry Pi

Playing sounds and using buttons with Raspberry Pi

WebIOPi. Installation Walk-through Macros

Adafruit's Raspberry Pi Lesson 7. Remote Control with VNC

Adafruit's Raspberry Pi Lesson 3. Network Setup

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable

Preparing Raspberry Pi

7inch HDMI LCD (B) User Manual

How To Connect A Raspberry Pi To The Internet On A Microsoft Moonstone 2 (Microsoft) Microsoft Powerbook 2 (Powerbook 2) (Powerboard 2) And Powerbook 3 (Powerstation 2)

Setting up WiFi with BeagleBone Black

5inch HDMI LCD User Manual

PiFace Control & Display

Cassandra Installation over Ubuntu 1. Installing VMware player:

Adafruit NFC/RFID on Raspberry Pi. Created by Kevin Townsend

Installing Ubuntu on Darwin OP

Raspberry Pi Android Projects. Raspberry Pi Android Projects. Gökhan Kurt. Create exciting projects by connecting Raspberry Pi to your Android phone

Adafruit's Raspberry Pi Lesson 5. Using a Console Cable. Created by Simon Monk

Raspberry Pi radio player with touchscreen

Raspberry Pi Webserver

AlienVault Unified Security Management (USM) 4.x-5.x. Deploying HIDS Agents to Linux Hosts

Installation Guide. Copyright (c) 2015 The OpenNMS Group, Inc. OpenNMS SNAPSHOT Last updated :19:20 EDT

Imprint. ecodms Version: (krusty) Manual Build Number: 20 Language: Copyright 2016: ecodms GmbH Salierallee 18a Aachen Germany

BeagleBone Black: Installing Operating Systems

Shearwater Research Dive Computer Software Manual

Code::Blocks Student Manual

Wireless Security Camera with the Arduino Yun

Student installation of TinyOS

Solr Bridge Search Installation Guide

SETTING UP RASPBERRY PI FOR TOPPY FTP ACCESS. (Draft 5)

Computer Science and Engineering Linux Cisco VPN Client Installation and Setup Guide

2. Boot using the Debian Net Install cd and when prompted to continue type "linux26", this will load the 2.6 kernel

USB Driver. Installation Guide for LTE Devices

Adafruit's Raspberry Pi Lesson 9. Controlling a DC Motor

Mac System Setup Guide (Pre-Class)

Embedded Based Web Server for CMS and Automation System

Matrix and 7-Segment LED Backpack with the Raspberry Pi

DraganFly Guardian: API Instillation Instructions

Android: Setup Hello, World: Android Edition. due by noon ET on Wed 2/22. Ingredients.

Intel Do-It-Yourself Challenge Lab 2: Intel Galileo s Linux side Nicolas Vailliet

Connections and wiring Diagram

Chapter 1 Hardware and Software Introductions of pcduino

Getting Started With! CGminer/BFGminer!

MapGuide Open Source Repository Management Back up, restore, and recover your resource repository.

Running Knn Spark on EC2 Documentation

Installing VMware Tools on Clearswift v4 Gateways

Cloud Cam: Internet-Connected Security Camera

Adafruit's Raspberry Pi Lesson 11. DS18B20 Temperature Sensing

Secure Browser Installation Manual

Introduction. Created by Richard Bell 10/29/2014

Partek Flow Installation Guide

SSH to BeagleBone Black over USB

CISE Research Infrastructure: Mid-Scale Infrastructure - NSFCloud (CRI: NSFCloud)

Laboration 3 - Administration

Waspmote. Quickstart Guide

Installing (1.8.7) 9/2/ Installing jgrasp

TSM for Windows Installation Instructions: Download the latest TSM Client Using the following link:

Waspmote IDE. User Guide

python-escpos Documentation

Using pcduino's WiFi Dongle With the Pi a

Installing Ubuntu LTS with full disk encryption

Setting up IO Python Library on BeagleBone Black

Comodo MyDLP Software Version 2.0. Endpoint Installation Guide Guide Version Comodo Security Solutions 1255 Broad Street Clifton, NJ 07013

Title: Documentation for the Pi-UPS-Monitor-App

Android: How To. Thanks. Aman Nijhawan

AzMERIT Secure Browser Installation Manual For Technology Coordinators

1. Introduction. 2. Installation and Configuration. 2.1 Linux

Setting up PostgreSQL

Arduino Lesson 1. Blink

Updates Click to check for a newer version of the CD Press next and confirm the disc burner selection before pressing finish.

Information Security Training. Assignment 1 Networking


User Manual - Help Utility Download MMPCT. (Mission Mode Project Commercial Taxes) User Manual Help-Utility

Introducing the Adafruit Bluefruit LE Sniffer

SETTING UP A LAMP SERVER REMOTELY

CDH installation & Application Test Report

Building graphic-rich and better performing native applications. Pro. Android C++ with the NDK. Onur Cinar

Setting up a Web Server using Raspbian Wheezy on the Raspberry Pi ( Kenneth A Spencer)

Moxa Device Manager 2.3 User s Manual

AdRadionet to IBM Bluemix Connectivity Quickstart User Guide

My name is Robert Comella. I am a SANS Technology Institute (STI) student who is nearly finished with my master of science in engineering degree.

Installing F-Secure Anti-Virus (FSAV) Table of Contents. FSAV 8.x and FSLS 7.x End of Life. FSAV 9.x and FSLS 9.x End of Life

secucam User Manual Version 1.1.x Darhon Software

BACKUP YOUR SENSITIVE DATA WITH BACKUP- MANAGER

Set up and Blink - Simulink with Arduino

Version control. HEAD is the name of the latest revision in the repository. It can be used in subversion rather than the latest revision number.

Installation of OpenMPI

Installing Virtual Coordinator (VC) in Linux Systems that use RPM (Red Hat, Fedora, CentOS) Document # 15807A1-103 Date: Aug 06, 2012

INASP: Effective Network Management Workshops

Transcription:

Install bluez on the Raspberry Pi Created by Tony DiCola Last updated on 2016-03-11 08:03:30 PM EST

Guide Contents Guide Contents Overview Installation Download Source Install Dependencies Compile & Install bluez Setup bluez Service Enable Bluetooth Low Energy Features 2 3 4 4 5 5 7 8 Adafruit Industries https://learn.adafruit.com/install-bluez-on-the-raspberry-pi Page 2 of 10

Overview This guide will walk through how to compile and install bluez (http://adafru.it/ede) on the Raspberry Pi. Bluez is the Linux Bluetooth system and allows a Raspberry Pi to communicate with Bluetooth classic and Bluetooth low energy (LE) devices. Although bluez is quite full-featured it can be somewhat challenging to install and use. However this guide will show you step-by-step what you need to do to compile and install the latest version of bluez. Grab a Bluetooth USB adapter, like this handy Bluetooth 4.0 USB module (http://adafru.it/ecb), and follow this guide to get setup using bluez in almost no time. As a companion to this guide, check out the following video (http://adafru.it/lec) which dives into Bluetooth low energy and installing and using bluez on the Pi: In addition you might want to read this Introduction to Bluetooth Low Energy (http://adafru.it/ics) guide for more information on BLE. You will also want to be familiar with the basics of using a Raspberry Pi, like loading an operating system on a microsd card and connecting to a command terminal on the Pi. Check out the learn Raspberry Pi series (http://adafru.it/dpe) for more information on the basics. Adafruit Industries https://learn.adafruit.com/install-bluez-on-the-raspberry-pi Page 3 of 10

Installation Follow the instructions below to download, compile, install, and configure bluez on the Raspberry Pi. Before you get started you'll need to make sure your Raspberry Pi has access to the internet, either through a wired or wireless connection. In addition you'll want to be familiar with accessing a command terminal on the Pi, like with the SSH tool (http://adafru.it/jse). You will also need to make sure your Raspberry Pi is running the latest version of the Raspbian Jessie (http://adafru.it/fqi) operating system (either the full or lite version). These instructions won't work with the older Wheezy release--make sure you're running Jessie and its systemd service host. Download Source To install bluez (http://adafru.it/ede) you'll need to download and compile the latest version of its source code. You could install bluez from a prebuilt package in the Raspbian repository however the version in the repository almost certainly is out of date. If you're using Bluetooth low energy features you really want to be running the absolute latest version of bluez to get the latest bug fixes and features. Compiling bluez from source will ensure you have the latest and greatest release. Visit the bluez download page (http://adafru.it/led) and copy the link to the latest source release (under the User Space BlueZ Package section). For example at the time of this guide's writing the latest version of bluez is 5.37 and can be downloaded from: http://www.kernel.org/pub/linux/bluetooth/bluez-5.37.tar.xz Connect to a terminal on your Pi and execute the following command to download and open the bluez source archive. Remember, find the latest version of bluez from its homepage and use that download URL--the instructions below show using version 5.37 of bluez. cd ~ wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.37.tar.xz tar xvf bluez-5.37.tar.xz You might need to change the tar command above to specify the filename for the version of bluez you're using. After the command runs you should see it unzip the bluez source into a new folder, like bluez-5.37. Now change into that directory to continue with the installtion by running (note change the cd command to use the directory for the version of bluez you downloaded): cd bluez-5.37 Adafruit Industries https://learn.adafruit.com/install-bluez-on-the-raspberry-pi Page 4 of 10

Install Dependencies Now you'll need to install a few dependencies that the bluez library uses. Run the following commands to install these dependencies: sudo apt-get update sudo apt-get install -y libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev After the commands run you should see them install a few dependencies and finish without any error messages. Compile & Install bluez To compile bluez you'll use the standard configure, make, and sudo make install commands as most other Linux software. From inside the bluez source directory run the configure script as follows:./configure You should see the script finish without any error messages like below: If you do see an error message it likely means you need a dependent library installed. Go back and Adafruit Industries https://learn.adafruit.com/install-bluez-on-the-raspberry-pi Page 5 of 10

check you installed all of the libraries mentioned in the install dependencies section above. Also check what library the configure script detected as missing and see if you can install it from the Raspbian repository (most libraries are named 'libx-dev' where X is the name of the library, like GLib or readline). You can rerun the configure script until it finishes successfully. Once the configure script has successfully run you're ready to compile the bluez code. This compilation will take about 10-20 minutes on a Raspberry Pi 2 (and slightly longer on a Pi 1 or Zero). Start the compile by running: make You should see output as the make command compiles different parts of bluez. Once it's finished you should see no error messages like the following: If you do see errors check that the configure script ran without any errors, and make sure all the dependencies are installed and try again. After bluez has been compiled it can be installed by running the following command: sudo make install You should see the command finish with no errors like the following: Adafruit Industries https://learn.adafruit.com/install-bluez-on-the-raspberry-pi Page 6 of 10

That's all there is to installing bluez from source! Now you'll learn a few tips about configuring bluez to run on the Pi. Setup bluez Service After installing bluez from source there's one more step to enable the bluetoothd service in bluez. This service talks to a part of bluez in the kernel and exposes bluetooth devices to user programs. The bluez service must be running for its tools and libraries to work! With Raspbian Jessie the bluez service is run with systemd. Systemd is a process that controls other processes on the Pi, like the bluez service. First you can check that the bluez service is installed and in a good state by running the following command: systemctl status bluetooth You'll likely see the bluez service is loaded but not active, like: bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; disabled) Active: inactive (dead) Docs: man:bluetoothd(8) Adafruit Industries https://learn.adafruit.com/install-bluez-on-the-raspberry-pi Page 7 of 10

You can manually start the bluez service by running the following command: sudo systemctl start bluetooth After running the above, run the status command again and you should see the service is now active: bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; disabled) Active: active (running) since Mon 2016-02-29 04:56:27 UTC; 1s ago Docs: man:bluetoothd(8) Main PID: 715 (bluetoothd) Status: "Running" CGroup: /system.slice/bluetooth.service 715 /usr/local/libexec/bluetooth/bluetoothd You can stop the service by running: sudo systemctl stop bluetooth And again the status command should now show the bluez service as inactive. If you just want to intermittently use bluez tools & programs you could manually start and stop the service as shown above. Make sure to start the bluez service before running programs that depend on it. However you probably want the bluez service to run automatically when the Raspberry Pi boots. To enable the bluez service to run at boot run the following command: sudo systemctl enable bluetooth Now reboot the Pi and run the status command again to check the bluez bluetooth service is running. If you ever want to disable the bluez service from automatically starting, run the following command: sudo systemctl disable bluetooth Enable Bluetooth Low Energy Features One final configuration change you can make is to enable the bluetooth low energy features in bluez. These are special APIs that allow bluez to interact with bluetooth low energy devices, however they're still in development and put behind an experimental flag that must be enabled first. To enable bluez's experimental features like BLE you can modify the bluez service configuration. Edit this configuration by running: sudo nano /lib/systemd/system/bluetooth.service Adafruit Industries https://learn.adafruit.com/install-bluez-on-the-raspberry-pi Page 8 of 10

You should see a configuration file similar to the following: [Unit] Description=Bluetooth service Documentation=man:bluetoothd(8) ConditionPathIsDirectory=/sys/class/bluetooth [Service] Type=dbus BusName=org.bluez ExecStart=/usr/local/libexec/bluetooth/bluetoothd NotifyAccess=main #WatchdogSec=10 #Restart=on-failure CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE LimitNPROC=1 [Install] WantedBy=bluetooth.target Alias=dbus-org.bluez.service Enable the experimental features by adding --experimental to the ExecStart line, for example the configuration should look like: [Unit] Description=Bluetooth service Documentation=man:bluetoothd(8) ConditionPathIsDirectory=/sys/class/bluetooth [Service] Type=dbus BusName=org.bluez ExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimental NotifyAccess=main #WatchdogSec=10 #Restart=on-failure CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE LimitNPROC=1 [Install] WantedBy=bluetooth.target Alias=dbus-org.bluez.service Save the file and exit the editor by pressing Ctrl-o, enter, then Ctrl-x. Now tell systemd to reload its configuration files by running: Adafruit Industries https://learn.adafruit.com/install-bluez-on-the-raspberry-pi Page 9 of 10

sudo systemctl daemon-reload If the bluez service was previously running you'll want to restart it by running: sudo systemctl restart bluetooth Or if the service wasn't running you can start it with the start command previously shown. Once the bluez service is running you can check the experimental features are enabled by running the status command again. You should see output similar to the following (notice the --experimental on the last line): bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; disabled) Active: active (running) since Mon 2016-02-29 05:15:55 UTC; 4s ago Docs: man:bluetoothd(8) Main PID: 1022 (bluetoothd) Status: "Running" CGroup: /system.slice/bluetooth.service 1022 /usr/local/libexec/bluetooth/bluetoothd --experimental That's all there is to configuring and running bluez on the Raspberry Pi! At this point you're ready to start using bluez tools like bluetoothctl, hcitool, etc. Adafruit Industries Last Updated: 2016-03-11 08:03:31 PM EST Page 10 of 10