Introduction: Raspberry Pi Boss Detector (Bluetooth Early Warning System)


This is a simple but clever way to leverage Bluetooth radio signals as an early warning system for an approaching boss, sibling, parent, kid, spouse, surprise party recipient, or whomever. Once we've connected one or more LED's to the Pi, figured out your target's Bluetooth MAC address, and loaded some code I've written then you'll be alerted to the target's approach and proximity by the lights which blink faster the closer your target is.

Note also, that if you'd like to use the built-in LED on your Pi, you can skip all of the hardware and wiring requirements below.

This will work with any Raspberry Pi and can be easily ported to an Arduino or (if you're willing to give up the LED feature) any laptop or desktop computer.

For this tutorial I will focus on the Raspberry Pi version 2 model B.

Here's what you need:

If you're using a Raspberry Pi v2:

  • 1 LED of any color or size
  • 1 resistor, probably about 220 ohm but you can use this calculator tool to find out exactly for your LED
  • 1 breadboard, unless you plan to make a PCB
  • Female-to-make jumper wires
  • 1 Pi-compatible bluetooth dongle, such as this one
  • My code, available on GitHub

If you're using a Raspberry Pi v3:

  • 1 LED of any color or size
  • 1 resistor
  • Female-to-male jumper wires
  • 1 breadboard
  • My code, available on GitHub

If you're using a Raspberry Pi Zero:

  • 1 LED of any color or size
  • 1 resistor
  • 1 breadboard
  • Female-to-male jumper wires
  • A bluetooth Pi hat or other bluetooth adapter
  • My code, available on GitHub

If you're using a Raspberry Pi Zero W:

  • You've got integrated Bluetooth, so same requirements as for Raspberry Pi v3

Step 1: Load Bluetooth Tools Onto Your Pi

Connect to your Pi and run the following code to load some basic bluetooth tools we'll need.

sudo apt-get install bluetooth bluez

For good measure go ahead and restart your Pi and plugin your Bluetooth dongle or Pi Hat if you're not using Pi v3 (those of you with a v3 already have integrated Bluetooth).

Once this is done you can run the following command:

hcitool dev

To learn the name of your Bluetooth device, which is probably hci0. You'll need to know that to run my early warning system program (, found on the GitHub link in the Introduction).

Go ahead and copy my program to your Pi. You can either copy and paste the code from GitHub into a .sh file (using nano or some other text editor on your Pi), or you could clone the repository, or just download the file.

Step 2: Connect the Hardware

This part couldn't be easier, since all we're connecting is a simple LED (and a resistor, of course, since LED's are power-hungry).


  1. wire your ground from the GPIO of the Pi to the column of your breadboard with the negative LED pin and resistor.
  2. wire the column of the breadboard with the positive LED pin to a GPIO pin such as 18 on your Pi.

as show in the photo above.

There are also many guides and YouTube videos if you need more help, but I think this will take most of you under 10 seconds.

Step 3: Learn Your Target's Bluetooth MAC Address

There are any number of ways to do this.

On your Pi, Linux*** laptop/desktop, or Linux running on a VirtualBox on top of Windows, you can use

hcitool scan

To scan for nearby Bluetooth devices. Simply run this tool before and after your target comes around and the Bluetooth device (phone, laptop, etc) that only appeared when they are around is the one you want.

Another solution, which I prefer, is to use Bluelog from DigiFail. This script is more flexible, seems to get more results somehow, and can be run persistently. It's also built into Kali and other security distros, if you happen to be running one of those.

*** Bluetooth is much more limited on Windows because of how Microsoft defined the standard (except possibly on some really old versions like XP, which can at least do an inquiry via pybluez). The same Bluetooth adapter that can do anything you'd like it to on a Linux OS can only tell you which devices you've paired with under Windows.

Step 4: Run and Enjoy!

All that's left to do now is to run the program I've written (which you are more than welcome to tweak!).

Depending on how you copied it from GitHub, you may need to quickly change the permissions to make it executable, e.g.

chmod 777


chmod +x

Then, simply execute the program with the following 3 parameters:

  1. Your Bluetooth device name (i.e. hci0)
  2. Your target's Bluetooth MAC address
  3. The GPIO pin number you wired your LED to

For example:

sudo ./ hci0 40:2C:F4:29:6A:8C 18

Then sit back and enjoy!

Some next steps for me, or anyone who would like to contribute:

  • Make a simple PCB and/or sleek case to make the hardware prettier and more compact
  • Use either multiple LED's or a multi-color LED for multiple targets
  • Use Bluetooth Low Energy (BLE) devices, which there are a lot of today (e.g. smart tags, fitness bands, etc)