How to Set Up a Raspberry Pi Eddystone Beacon?

Setting up a Raspberry Pi to broadcast an Eddystone beacon is a great way to create proximity-based experiences. Beacons enable interactions with mobile devices and websites based on location, allowing you to create contextualized and personalized content.

How to Set Up a Raspberry Pi Eddystone Beacon?

In this guide, you’ll learn how to configure your Raspberry Pi and necessary hardware to broadcast as an Eddystone beacon. We’ll cover how to install the required software, set up Bluetooth broadcasting, and customize the data broadcasted.

Prerequisites

Before we begin, you’ll need the following:

  • A Raspberry Pi (any model will work)
  • A microSD card loaded with Raspbian (the Raspberry Pi OS)
  • A BLE (Bluetooth Low Energy) USB adapter
    • Examples include the Pi Supply USB Bluetooth 4.0 Adapter or Pimoroni BLE pHAT
  • Eddystone beacon library dependencies (covered below)

Why Use a Raspberry Pi for an Eddystone Beacon?

Raspberry Pis are affordable, accessible devices great for IoT and beacon projects. Their open ecosystem, GPIO pins, and Linux environment provide flexibility for customization. And with BLE capabilities, it’s easy to configure a Rpi to broadcast BLE beacon frames.

The benefit of using a programmable device like a Raspberry Pi over off-the-shelf hardware beacons is it allows changing the beacon’s UID, advertising frequency, and broadcasted info. You have control over all aspects of the beacon behavior.

Step 1 – Install Required Software

We’ll first get the Eddystone library installed along with some dependencies on your Raspberry Pi.

Run the following commands in the terminal:

sudo apt update

sudo apt full-upgrade -y  

sudo apt install bluetooth bluez libbluetooth-dev libudev-dev -y

pip3 install pyeddystone

This installs the following:

  • Bluetooth software + libraries for the Pi to support BLE
  • The pyeddystone Python library for broadcasting Eddystone frames

What is Eddystone and how does it work?

Eddystone is an open beacon format developed by Google that uses BLE (Bluetooth Low Energy) to broadcast data. It works on top of BLE advertising frames to modulate data.

Mobile devices like smartphones can detect these broadcasts and retrieve the beacon’s info. This enables location-based use cases and interactions between devices.

There are a few frame types – UID, URL, TLM, EID. We will focus on UID frames which broadcast an identifier that devices can pick up.

Step 2 – Set Up Bluetooth Permissions

For the Raspberry Pi to broadcast as a BLE beacon, we need to set some permissions and config for Bluetooth advertising capabilities:

sudo setcap cap_net_raw+eip $(eval readlink -f `which python3`)

sudo nano /etc/systemd/system/bluetooth.target.wants/bluetooth.service

In the bluetooth config file:

  • Set ControllerMode to bredr
  • Add Advertising=true flag

It should look like:

ExecStart=/usr/lib/bluetooth/bluetoothd -C

ControllerMode = bredr

Advertising=true

Save and exit.

Finally, reboot for changes to take effect:

sudo reboot

This enables BLE advertising at the system level so our Eddystone library can now broadcast frames.

Step 3 – Broadcast an Eddystone Beacon

With dependencies installed and Bluetooth configured, we can now start broadcasting as an Eddystone beacon from the Raspberry Pi.

Run the following Python script:

python

from pyeddystone import EddystoneUID

import time

beacon = EddystoneUID(

    instance_id=“RPiBeacon1”,

    namespace_id=“AA555AAA555A555A”,

    instance_id_random=False

while True:

   beacon.broadcast()

   time.sleep(1)

We first create an EddystoneUID instance, passing a 16-byte namespace ID and instance ID. This uniquely identifies our beacon.

Inside an infinite loop, we call broadcast() repeatedly to advertise our beacon frame.

Now from any BLE scanning app, you should be able to detect a beacon with that namespace + instance ID values.

Customizing the Beacon Broadcast

There are many aspects of the broadcast you can customize programmatically:

Change Instance ID

To modify the instance ID:

python

beacon.instance_id = “NewInstance123”

Change Broadcast Interval

Broadcast less frequently by increasing the sleep timer:

python

time.sleep(5) # Broadcast every 5 seconds

Modify the TX Power

Increase or decrease the broadcasting power:

python

beacon.tx_power = 12 # -12 dBm

Switch Between Multiple Beacons

You can create multiple beacon instances and alternate between broadcasting them:

python

shop_beacon = EddystoneUID(namespace_id=“ShopNamespace”, instance_id=“Store1”

exit_beacon = EddystoneUID(namespace_id=“ExitNamespace”, instance_id=“Exit1”)

while True:

   Broadcast shop beacon for 8 seconds 

  shop_beacon.broadcast()  

  time.sleep(8)   

   Then switch to exit beacon

  exit_beacon.broadcast()   

  time.sleep(8)

This allows you to set up multiple virtual beacons for different purposes. Devices can detect the change in IDs between locations.

Applications and Use Cases

With an broadcasting Eddystone beacon, what can you build? Here are some ideas:

  • Proximity Alerts – Trigger actions on user’s phone when they are nearby
  • Contactless Checkins – Touchless attendance/checkout system
  • Micro-locations – Precise positioning for indoor navigation
  • Proximity-based Information – Contextual notifications based on location
  • Asset Tracking – Add beacons to devices for monitoring movement

Beacon tech enables all of sorts of interactions once devices are in close proximity – be creative with the types of location-based experiences you can build!

Conclusion

Setting up an Eddystone beacon on a Raspberry Pi opens lots of possibilities for Bluetooth-based projects. With just a few components and Python code, the Pi can now wirelessly broadcast frame and be uniquely recognized by devices nearby.

Customizing the identifiers, interval timings, and power levels also allows you to adapt your beacon setup to different scenarios. Monitor a single exit door, set up spatial zones across a shop floor, or create interactive worlds – a Raspberry Pi beacon makes location-triggered interactions easy and affordable.

I hope you found this guide useful! Feel free to build upon the code examples here to develop your own custom beacon applications.

Key Takeaways

  • Raspberry Pis are affordable devices great for broadcasting customizable Eddystone Bluetooth beacon frames
  • The pyeddystone Python library handles constructing and advertising UID frames
  • Permissions must be configured on the Pi to enable BLE advertising at the hardware level
  • Eddystone frames broadcast a 16-byte Namespace ID + Instance ID that uniquely identify the beacon
  • Code allows full control over the beacon behavior by modifying the ID, intervals, power level, etc
  • Use cases include proximity alerts, contactless experiences, micro-locations, asset tracking and more

FAQs

  1. What firmware/OS is required on the Raspberry Pi to broadcast as a beacon?
    Any OS supporting Bluetooth Low Energy advertising will work. We used standard Raspberry Pi OS in this guide.

  2. Can I use multiple USB Bluetooth adapters with one Pi to create more beacons?
    Yes, you can attach multiple USB BLE adapters to broadcast as more beacon instances from the same Pi. Each adapter would simulate another physical beacon.

  3. Is any special hardware required for my Raspberry Pi setup?
    For most Pi models, just a microSD card loaded with an OS is required. Optionally can add a BLE adapter if the model lacks onboard Bluetooth.

  4. Can the Eddystone frames contain any custom data – like sensor values?
    Not directly – the frame types have predefined data formats for identifiers, URLs, etc. But with the programmable Pi, you can dynamically generate frame ID values based on live data.

  5. What temperature range can the Raspberry Pi operate as a beacon in?
    Consumer-grade Pis are typically safe in the -20°C to 50°C temps. Industrial models like the Pi Compute Module can operate from -40°C to 85°C.

  6. How do I make my beacon transmit an iBeacon packet instead of Eddystone?
    Libraries like pyibeacon allow constructing and broadcasting frames using Apple’s iBeacon format instead, with small code changes needed.

  7. Do I need an iPhone or Android phone to develop with Eddystone beacons?
    Nope, any BLE scanning software on a laptop or mobile device will work to detect your Pi beacon for testing. Apps tailored for beacons may offer more functionality though.

  8. Can I extend the beacon’s range by connecting an external antenna?
    Yes, attaching an external antenna provide much better broadcast range than the Pi’s onboard antenna – useful for long-range applications. Amperf Antennas makes good high-gain antennas.

  9. Is Eddystone technology patented or proprietary?
    Nope, Eddystone is fully open-source. Google released it as an open standard for beacon broadcasting, with no licensing or royalties.

  10. Do I need to worry about MAC address randomization on my Pi beacon?
    For security, newer versions of Linux/Android randomize device MAC addresses – which would change your beacon identifiers. Best to disable randomization features for reliability.

  11. Can I run the beacon script as a background process/service on boot?
    Yes, systemctl can be used to setup your Python beacon script as a service, so after boot the broadcasting starts automatically.

  12. What real-world factors might interfere with or degrade my beacon’s signal?
    Water absorption, weather, metal structures, competing 2.4Ghz signals, etc can potentially interfere and limit range. Site surveys help optimize positioning.

  13. Can Eddystone offer spatial positioning to approximate distance from the beacon?
    Not inherently, but signal strengths could be ranged in custom apps. Bluetooth Direction Finding in newer devices also helps spatial localization.

  14. Do I need an Eddystone-compatible app to interact with my Pi beacon?
    Sort of – while basic detection just requires any BLE scanning app, customized integrations and actions would need an app with Eddystone support.

  15. Can I connect my Pi beacon to the cloud to track stats or update configs?
    Yep! IoT cloud platforms like AWS IoT Core let you remotely manage devices, update software, view live telemetry received from beacons, etc.

  16. Can I add a battery pack to make my Pi Eddystone setup portable?
    Yes, you can add battery hats or USB power banks to un-tether your Pi. Could even solar charge it and take completely mobile.

  17. What’s the typical Eddystone UUID size and format?
    16 bytes, split into a 10 byte namespace and 6 byte instance ID – expressed as hex digits grouped with dashes. The namespace helps identify an organization.

  18. Is Eddystone the most widely used and supported beacon format?
    Yes, Eddystone sees more popularity vs closed solutions given its open ecosystem and flexibility. Many products and libraries now seamlessly integrate.

  19. Can I update the Pi OS and Eddystone libraries remotely over-the-air?
    Yes, tools like BalenaCloud allow pushing remote updates to all your devices in the field – no need for manual updates.

  20. How are Eddystone frames different from traditional Bluetooth data packets?
    Eddystone uses the Bluetooth Low Energy advertisement broadcast channel specifically – which allows one-way beacon broadcasting of small frames vs two-way data connections.

Leave a Comment