Bluetooth Low Energy: Read-Write to Sensor Network from Raspberry Pi using Raspberry Pi

Originally published in this blog.

The goal of this tutorial is to demonstrate how you can read and write from a Bluetooth Low Energy (BLE) device. For example, if you want to read the ‘number of steps' data from your fitbit and make interesting apps with it,Bluetooth Low Energy

In this tutorial, I am using a RedBearLab Bluetooth Low Energy (BLE) shield connected to an Arduino UNO. This BLE+Arduino combo essentially represents a BLE device. We will use a Raspberry Pi to read from & write to this BLE device.

Step 1: Components Used

Arduino UNO R3

Redbear Lab BLE Shield

Raspberry Pi

BLE CSR Dongle

Some wires etc.

Step 2: Initial Setup

Install hard-float Raspberryian OS using this link.

Install Bluez using step 1, 2, 3 of this link.

I used CSR 4.0 dongle in the Raspberry Pi for BLE connection.

Make sure you have gatttool in the path using

Step 3: Bluetooth Dongle Setup, Scan and Connect

Check if the Bluetooth dongle is up and running

~/bluez/bluez-5.11 $ tools/hciconfig

If not (you will see DOWN written in the result), use below command to get it up

~/bluez/bluez-5.11 $ tools/hciconfig hci0 up

Now scan for BLE devices. The command below might continue scanning forever, so type CTRL+C when you have the device address

Bluetooth Low Energy

$ sudo hcitool lescan

Lets assume that you get the BLE device address xx:xx:xx:xx:xx:xx. Now connect with the device using gatttool

$ sudo gatttool -b xx:xx:xx:xx:xx:xx -t random --interactive

You might not need to use -t random. Also if you get device busy error, remove the dongle and reconnect it. You will see an interactive prompt. Type connect like below


For more detail: Bluetooth Low Energy: Read-Write to Sensor Network from Raspberry Pi

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation, and engineering. I have a clear and simple writing style and am skilled in using infographics and diagrams. I am a great researcher and is able to present information in a well-organized and logical manner.

Follow Us:
Scroll to Top