Maker Pro
Custom

Turn a Raspberry Pi Into Bluetooth Beacon

December 04, 2020 by Sheikh Shuhad
Share
banner

Turn a Raspberry Pi into Bluetooth Beacon using BleuIO.

Hardware

bluetooth low energy usb dongle

Bluetooth is one of the innovative technology to transfer data wirelessly, build home automation systems, control other devices etc.

In this project, I will try to turn a Raspberry Pi into Bluetooth Beacon.

Requirements

Step 1: ​Connect the Dongle

Connect the BleuIO dongle to your Raspberry Pi.

To identify which device name the dongle is connected to, you will need to run:

ls /dev

You might need to do it twice, once before you connect the dongle and once after to be able to identify which one is the device name. When starting up, the dongle will open up a COM port for the bootloader for 10 seconds to allow you to update the firmware (or flash your own application).

Afterwards it will close that port and open a new port for the BleuIO application which is the one we’re interested in here. You can run:

lsusb

bleuio raspberry pi BLE
ble port select

Step 2: Serial Communication

You will need a serial communication program to communicate with the dongle. For this tutorial we will be using Minicom. You can get Minicom by running:

sudo apt-get install minicom

Now, to start using the dongle run the following command if, for example, your dongle is connected to the device name ttyACM0:

minicom -b 9600 -o -D /dev/ttyACM0

Now try typing an AT-Command. For example

AT

If you get an OK response that means the dongle is working.

FKNEK9LKHOUG0TC.png

Step 3: Run Python Script

We have a python script ready to help turn this Raspberry Pi into Bluetooth Beacon.

To use these scripts you will need to have Python installed.

ou will also need to install the module pySerial. The easiest way to install it is through pip (which you should already have after installing Python) by running:

Python2:

pip install pyserial

Python3:

python3 -m pip install pyserial

After connecting, you can use the example sample python script to set up your own iBeacon.

the source code can be found on GitHub.

Save this script into a file called ibeacon.py or you can name anything you like.

Now open the file using a command prompt by typing

python ibeacon.py

Step 4: Scan Your Device

When you start the Python script, you should be able to see your iBeacon using a scanner App designed for Bluetooth Low Energy (BLE).

Examples of scanner App can be BLE Scanner from Bluepixel Technologies.

Here you can see , your device has started advertising.

You can also use Eddystone script. Source code available here.

ble scan result

Related Content

Categories

Comments


You May Also Like