How to use BLE on raspberry pi 3 ?

by Tom | Posted on May 18, 2017, 6:06 a.m.

Introduction

 In this tutorial, we are going to test the BLE capabilities of the Raspberry Pi 3. Raspberry Pi 3 has an inbuilt wifi and BLE, we can directly program it.

Prerequisites

You should have the following hardware in order to complete this tutorial

  1. raspberry pi 3 (I have configured ssh so that I can control it from my Laptop)
  2. A BLE peripheral device can be a BLE emulator on a smartphone or BLE hardware, Here I am using CC2650 BLE Launchpad from Texas Instruments.

   You must have to configure the initial setup of Pi, including OS installation(Raspbian or similar), software update etc. Also, you must have the basic knowledge in Linux terminal and command line interface

Let's Start

 

The first step is to setup BLE module since I am using pi3, it has inbuilt BLE otherwise check the device using the command lsusb

open the terminal and type the command 

sudo hciconfig

Output:

raspberry pi3 hciconfig

 

Now we got the BLE device Type the following command to activate the BLE

sudo hciconfig hci0 up

Output:

hci config up

 

For scanning BLE devices use the following command with superuser permission.

sudo hcitool lescan

Output:

ble scan 

Now connect to a BLE device using BLE Mac ID

gattool

 Establish connection between piand the BLE device using the command connect

ble connect