Skip to content

Instantly share code, notes, and snippets.

Last active February 18, 2023 21:59
What would you like to do?
Setting up Raspberry Pi 3+ to transmit iBeacon signals

Setting up Raspberry Pi 3+ to transmit iBeacon signals

Hardware Prerequisites

  • At least a Raspberry Pi 3, which has its own Bluetooth 4.0 device embedded

Set-up the OS

  1. Download the Raspberry Pi OS image and unzip the downloaded file.

  2. Use either Rufus or Win32DiskImager to install the .img file on a new SD card.

  3. Open the boot drive in VS code.

  4. Create an empty file titled ssh.

  5. 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.

        ssid="Your WiFi Name"
        psk="Your WiFi Password"
  6. 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

  1. Win+R, and type in PowerShell to open it.

  2. Connect to the Raspberry Pi.

    ssh pi@raspberrypi.local
  3. Navigate to raspi-config.

    sudo raspi-config
  4. Navigate to Advanced Options and press enter.

  5. 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
  6. Click on enable to enable VNC.

VNC Viewer

  1. Open up VNC viewer and connect to the Raspberry Pi.

VNC server: raspberrypi.local Default password: raspberry Changed password: raspberrypi

Install pre-requisite libraries

  1. Run sudo apt-get install update on a newly installed Raspberry Pi.

  2. 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

  1. Check current Bluetooth version

    bluetoothd -v
  2. We only install Bluez 5.36.

    sudo apt-get --purge remove bluez
    sudo apt autoremove
  3. Download BlueZ.

    mkdir bluez
    cd bluez
  4. 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

Install pi-bluetooth and start hciuart.service

  1. Install pi-bluetooth.

    sudo apt-get install pi-bluetooth
  2. Start hciuart.service using systemctl.

    systemctl start hciuart.service
  3. Check if hciuart.service is running.

    systemctl status hciuart.service
  4. Check that hci0 is enabled as a Bluetooth device.

    hcitool dev


  1. Turn on the Bluetooth device.

    sudo hciconfig hci0 up
  2. Configure the Bluetooth device.

    sudo hciconfig hci0 leadv 3
    sudo hciconfig hci0 noscan

Broadcasting the iBeacon signal

  1. 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.
  2. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment