Converting Raspberry Pi 3 into Beacon

DIY Beacon with Raspberry pi 3

Bluetooth 4.0 and iBeacon

Bluetooth is a short-range wireless communication technology that allows devices such as mobile phones, computers, and peripherals to transmit data or voice wirelessly over a short distance. The purpose of Bluetooth is to replace the cables that normally connect devices, while still keeping the communications between them secure.

Developed in 1994, Bluetooth was intended as a wireless replacement for cables. It uses the same 2.4GHz frequency as some other wireless technologies in the home or office, such as cordless phones and WiFi routers. It creates a 10-meter (33-foot) radius wireless network, called a personal area network (PAN) or piconet, which can network between two and eight devices.

More can be found at — https://www.bluetooth.com/

Bluetooth Low Energy (BLE) is a feature of Bluetooth 4.0. The Bluetooth 4.0 specification was officially adopted on July 6, 2010. Bluetooth version 4.0 features apart from low energy consumption include low cost, multivendor interoperability, and enhanced range.

This also called “Bluetooth Smart”. This technology allows peripherals to communicate by consuming much less energy than regular Bluetooth.

They are two communication modes in BLE:

  • Advertising mode: the peripheral sends information to be available to all the central around. This mode allows a peripheral to be known by central, thus the term “advertising”. In this mode, simple information can be exchanged using GAP broadcasting. In the perspective of a peripheral, this is a one-to-many mode.
  • Connected mode: allows a central to exchange complex data with a peripheral. The GATT protocol describes how the conversation is made in this mode. In the perspective of a peripheral, the connected mode is a one-to-one mode.

More on GATT Specification — https://www.bluetooth.com/specifications/gatt

‘Beacons’ are based on Bluetooth Low Energy (part of the new Bluetooth 4.0 standard), and at its heart is a way to advertise location-specific data one-way, or provide basic indoor navigation via individual Beacon nodes.

The way it works is actually very simple. Any BLE device typically advertises a certain amount of data to let other devices (like your phone) know that they exist and they’re available. The advertising packet that these devices send out might include information like key services offered by the device, a human-readable short devices name, etc.

Beacons take this short advertising frame, and appends a custom payload in the “Manufacturer Specific Data” field which includes a unique 128-bit UUID to identify companies or unique entities, as well as two 16-bit values (‘Major’ and ‘Minor’, or whatever you’d like to call them) that allow you to differentiate specific stores/premises (Major) and individual Beacon nodes (Minor).

Convert Raspberry Pi into Beacon:

  1. We need to install Raspbian Jessie.

Need help? Refer my blog for same — https://medium.com/@bhargavshah2011/raspberry-pi-3-raspbian-jessie-headless-setup-5eadd21da1ab

2. Now assign UUID and Major / Minor using a tool called “hcitool”. Rasbian Jessie has “hcitool” by default. Get your UUID. You can use many online available tools.

3. Convert your Major & Minor into Hex values. Best we can set the value to 1. Hex value will be “00 01”.

4. Now run following command

sudo hcitool cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 17 6F FA 9D 2E B1 44 EA B4 34 57 30 C2 41 D6 1A 00 01 00 01 C8

Where, UUID = 17 6F FA 9D 2E B1 44 EA B4 34 57 30 C2 41 D6 1A

Major = 00 01

Minor = 00 01

5. That’s it you have successfully converted your raspberry pi into DIY beacon.

6. Now to send “Advertise Packet” use following command

For On, sudo hcitool cmd 0x08 0x000A 01
For Off, sudo hcitool cmd 0x08 0x000A 00

7. You can use many free application which can now detect your DIY beacon. iOS device I recommend Locate iBeacon.

hcitool

hcitool is the swiss army knife for Bluetooth in Linux. It is aptly named hcitool as it communicates via a common HCI (Host Controller Interface) port to your Bluetooth devices. You can utilize the utility to scan for devices and send commands/data for standard Bluetooth and Bluetooth Low Energy.

BlueZ

BlueZ is an official Linux Bluetooth protocol stack. It is an Open Source project distributed under GNU General Public License (GPL). BlueZ kernel is part of the official Linux kernel since version 2.4.6.

More on — http://www.bluez.org/

Thanks for Reading :-) Happy Do It Yourself.

Cloud Solution Architect at Walmart Japan