Raspberry Pi Bluetooth In/Out Board or "Who's Home"





Introduction: Raspberry Pi Bluetooth In/Out Board or "Who's Home"

I wanted to create an electronic In/Out Board. The type you may have to record who is present or not in a company or home. It is usually placed by the front entrance so anyone can see who is in or out.

I also wanted another project for my Raspberry Pi, so that is why I am using it, but it makes a really good lower power choice of computer to drive this application. There are many extensions to this basic instructable, because of the Pi, like run a web server to show who is in and out via a web page, or run a local LCD display.

There is one major assumption here, that everyone carries a mobile phone and they are willing to keep bluetooth on (is that two assumptions? :-/). Their bluetooth must be on but it is NOT necessary to be 'discoverable' for this to work. Each person must only make there device discoverable for a short time so you can determine their bluetooth address. Once that is found, this device will just query the presence of that known bluetooth device.

I call it my "Who's Home" device.

Step 1: Raspberry Pi Setup

Let's get started.

You will need:
A Raspberry Pi computer, I tested with the 512 MB model, with internet connection.
An SD card loaded with the latest Raspbian “wheezy” software. See http://www.raspberrypi.org/downloads for how to get that setup.
A supported bluetooth USB dongle. See http://elinux.org/RPi_VerifiedPeripherals#USB_Bluetooth_adapters
Some way to access a terminal on the Pi. I used ssh, or just use the normal desktop and open Terminal.

Step 2: Install Bluetooth Software

At the terminal type the command

sudo apt-get install bluez

this will take a little while to install the bluetooth drivers and software.
Also needed is the the pybluez interface from Python to bluetooth.

sudo apt-get install python-bluez

If you have not already, insert your bluetooth dongle into a USB port on the pi.
At the terminal you can use hcitool to check your device, e.g. type

hcitool dev

Step 3: Get Bluetooth Device Addresses

You can use the inquiry.py script from the pybluez website to query the nearby discoverable devices.

At the pi terminal:
wget https://pybluez.googlecode.com/svn/trunk/examples/simple/inquiry.py
python inquiry.py

You will need the long address, numbers separated by :'s for the next step.

Step 4: Run the Basic In/Out Board

You can get my basic In/Out Board python script using this command:

wget https://raw.github.com/paulbarber/raspi-gpio/master/inoutboard.py

Insert your device addresses and person names into the script. Repeat the 'if' block for each person.
Run it with:

python inoutboard.py

Note that the devices no longer need to be discoverable for bluetooth.lookup_name to work.
Play and make it better!



    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Pro Tips Challenge

      Pro Tips Challenge
    • Paper Contest 2018

      Paper Contest 2018

    We have a be nice policy.
    Please be positive and constructive.




    pardon me sir, but i have this school project which is similar to ''who's home'' project of yours. the point of my project is the raspberry pi should push the data of any mac address from result ''python inquiry.py'' to mysql database every 1 hour. any raw suggestion how can i do that? (p.s. already configure the database)

    I'll be sure to use this in the next couple of days... Probably using the Bluetooth route.... but I'd like to be able to send the "Daniel is home/has left" command to Smartthings.... Any ideas? Thanks!

    Error 404: file not found.... please advise. https://code.google.com/p/pybluez/source/browse/trunk/examples/simple/inquiry.py

    It appears to have moved to:



    I have a Raspberry Pi 3 so now bluetooth is standard with the device. There are also built in functions. Run "hcitool scan" to scan for discoverable bluetooth devices. I am going to re-write the code to pull a user list from a JSON config file. To run bluetooth and wifi, add both sets of credentials to each user.

    Cool, I would be interested to see what you get. I am looking for a solution using BLE beacons instead of smart phones running on Raspberry Pi 3 with Jessie.

    I'd like to build this inside my car. Then when I approach the car it unlocks. When I leave it locks. Getting tired of fob not working...Any comments?

    I'm working on this right now, but instead of wiring it directly to the door locks and all that extra work, I'm just disconnecting the battery ground in my key fob and running the wires to the relay controlled from the pi (one wire from the negative of the battery and the other wire back to the ground of the key fob). So the key fob becomes powered again when phone is in range. I will probably wire it so that it sends a lock command when out of range because it won't let me lock the car with the key fob powered and inside the car. Or use a manual input to shut off the key fob when the car stops running so then the car can be locked as you get out as well.

    It could be a potential problem regarding security... the long addresses are spoofable. But then again, who is going to know that you are scanning for bluetooth in the area?

    Also, you'll have to tangle the beast that is car security systems.

    But if you do manage, let us know how you did it! Good luck!


    I like this script, but i don´t get that inquiry.py work on mi RasperyPi2, this is the error message when i type "python inquiry.py":

    performing inquiry...

    Traceback (most recent call last):

    File "inquiry.py", line 12, in <module>

    nearby_devices = bluetooth.discover_devices(duration=8, lookup_names=True, flush_cache=True, lookup_class=False)

    TypeError: discover_devices() got an unexpected keyword argument 'lookup_class'

    Thanks you for your help.