Setting up Raspberry Pi 3+ to transmit iBeacon signals
- Hardware Prerequisites
- Set-up the OS
- SSH Connection via PowerShell
- VNC Viewer
- Install pre-requisite libraries
- Configuring Bluetooth Settings
- Install
pi-bluetooth
and starthciuart.service
hciconfig
- Broadcasting the iBeacon signal
Hardware Prerequisites
- At least a Raspberry Pi 3, which has its own Bluetooth 4.0 device embedded
Set-up the OS
-
Download the Raspberry Pi OS image and unzip the downloaded file.
-
Use either Rufus or Win32DiskImager to install the .img file on a new SD card.
-
Open the boot drive in VS code.
-
Create an empty file titled
ssh
. -
Create another file named "wpa_supplicant.conf” in the boot partition, add the following data, and make sure to save it with the .conf extension.
country=SG update_config=1 ctrl_interface=/var/run/wpa_supplicant network={ scan_ssid=1 ssid="Your WiFi Name" psk="Your WiFi Password" }
-
Replace the “SSID” with the name of your Wi-Fi network and “password” with the password to connect to the network.
SSH Connection via PowerShell
-
Win+R, and type in PowerShell to open it.
-
Connect to the Raspberry Pi.
ssh pi@raspberrypi.local
-
Navigate to
raspi-config
.sudo raspi-config
-
Navigate to Advanced Options and press enter.
-
Navigate to VNC and press enter. If this option is not available, you can install VNC from the command line:
sudo apt install realvnc-vnc-server realvnc-vnc-viewer
-
Click on enable to enable VNC.
VNC Viewer
- Open up VNC viewer and connect to the Raspberry Pi.
VNC server: raspberrypi.local Default password: raspberry Changed password: raspberrypi
Install pre-requisite libraries
-
Run
sudo apt-get install update
on a newly installed Raspberry Pi. -
Install the following libraries.
sudo apt-get install libusb-dev sudo apt-get install libdbus-1-dev sudo apt-get install libglib2.0-dev — fix-missing sudo apt-get install libudev-dev sudo apt-get install libical-dev sudo apt-get install libreadline-dev sudo apt-get install libdbus-glib-1-dev
Configuring Bluetooth Settings
-
Check current Bluetooth version
bluetoothd -v
-
We only install Bluez 5.36.
sudo apt-get --purge remove bluez sudo apt autoremove
-
Download BlueZ.
mkdir bluez cd bluez wget www.kernel.org/pub/linux/bluetooth/bluez-5.36.tar.xz
-
Unzip and install it.
tar xvf bluez-5.36.tar.xz cd bluez-5.36 # Fix errors in files cd tools nano rctest.c # Navigate to line 507, column 19 # Replace 'SIOCGSTAMP' with 'SIOCGRARP' ^X Y Enter nano l2test.c # Navigate to line 909, column 19 # Replace 'SIOCGSTAMP' with 'SIOCGRARP' ^X Y Enter sudo ./configure --disable-systemd sudo make sudo make install
pi-bluetooth
and start hciuart.service
Install -
Install
pi-bluetooth
.sudo apt-get install pi-bluetooth
-
Start
hciuart.service
usingsystemctl
.systemctl start hciuart.service
-
Check if
hciuart.service
is running.systemctl status hciuart.service
-
Check that
hci0
is enabled as a Bluetooth device.hcitool dev
hciconfig
-
Turn on the Bluetooth device.
sudo hciconfig hci0 up
-
Configure the Bluetooth device.
sudo hciconfig hci0 leadv 3 sudo hciconfig hci0 noscan
Broadcasting the iBeacon signal
-
Determine the UUID of the signal. An example would be
0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8 00
- 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 is the visible proximity UUID
- 00 00 00 00 : the doubled zero-pairs from the left represent your Major and Minor values respectively. Those are specific variables assigned arbitrarily in order to maintain your devices’ uniqueness.
- C8 00: RSSI power and Tx Power.
-
Activate the iBeacon.
sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8 00