You can use the built‐in Bluetooth on a Raspberry Pi (such as the Pi 4, Pi 5, or Zero 2 W) to advertise as a BLE beacon without any extra dongle. One common method is to use the BlueZ stack along with a few command‑line utilities. Here’s an outline of the steps:
-
Prepare your system:
Make sure your Pi is up to date and that BlueZ is installed. For example:sudo apt-get update sudo apt-get install bluetooth bluez
-
Bring up the Bluetooth interface:
Enable the built‑in Bluetooth (usually on interfacehci0
):sudo hciconfig hci0 up
-
Set advertising mode:
Configure the device to advertise (and disable scanning so that it only broadcasts):sudo hciconfig hci0 leadv 3 sudo hciconfig hci0 noscan
-
Set the advertising data:
Use thehcitool
command to load your BLE advertisement payload. For instance, to set up an iBeacon (which uses a specific payload format) you can run:sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 00 00 00 00 C8 00
In this example:
- The first part (
1E 02 01 1A 1A
) sets up the advertising packet’s length, flags, etc. -
FF 4C 00 02 15
indicates it’s an iBeacon (Apple’s Company ID is 0x004C). - The next 16 bytes (here starting with
E2 0A 39 F4 …
) represent your beacon’s 128‑bit UUID. - The following bytes encode the Major, Minor numbers, and the calibrated Tx power (here, for example, Major and Minor are both zero, and
C8
is the Tx power value).
- The first part (
-
Test your beacon:
Use any BLE scanner app (like the BLE Scanner from Bluepixel Technologies or the Physical Web app) on your smartphone to verify that your Raspberry Pi is advertising the beacon packet. -
Stop advertising (if needed):
When you want to disable the beacon mode, you can use:sudo hciconfig hci0 noleadv
This is a straightforward way to turn your Raspberry Pi into a BLE beacon using its built‑in Wi‑Fi/Bluetooth module.
Feel free to modify the advertising payload (such as changing the UUID, Major/Minor values, or Tx power) to suit your application.