Bluetooth Presence Detection with Raspberry Pi: A Comprehensive Guide

Hi everyone! I’ve been experimenting with Bluetooth presence detection using a Raspberry Pi, and I wanted to share my journey and some tips with you. This setup has completely transformed how I interact with my smart home, and I’m excited to dive into the details!

My Setup

I’ve been using a Raspberry Pi with a Bluetooth 4.0 Dongle (class 1) to cover my entire 100m² apartment. The dongle’s range has been outstanding, but I’d love to hear from others who’ve tested this in larger spaces or houses. The Pi runs on Raspbian, and I’ve integrated everything with my Home Assistant setup using the XMLAPI.

The Script Journey

I started with a basic script I wrote myself, but recently upgraded to a more polished solution based on a script from the Domoticz community. I’ve adapted it for Homematic, and it’s been a game-changer. The script now supports different intervals for checking presence, which means faster detection when a Bluetooth device comes into range.

Here’s what you’ll need:

  • A Raspberry Pi with Raspbian
  • A Bluetooth Dongle (I recommend Bluetooth 4.0 or higher)
  • The l2ping and arp-scan tools
  • XMLAPI on your CCU

Key Features

  • Dual Detection: The script checks both Bluetooth and Wi-Fi signals. While iOS devices disable Wi-Fi in standby, Bluetooth remains active, ensuring consistent detection.
  • Efficient Interval Management: When presence is detected, the script checks less frequently, saving resources.
  • Customizable Parameters: You can set specific intervals for presence and absence, making it adaptable to your needs.

Installation Tips

  1. Bluetooth Setup: Follow the guide here for a smooth Bluetooth configuration. Make sure l2ping works before proceeding.
  2. Wi-Fi Ping: Install arp-scan using apt-get install arp-scan for Wi-Fi detection.
  3. Automation: I’ve set up the script to run on boot using rc.local. Each Bluetooth device has its own entry, making management straightforward.

Example Script Call

bash
sh /usr/bin/homematic/anwesenheit.sh AA:BB:CC:DD:EE:FF AA:BB:CC:DD:EE:FF 1234 iPhone_Michel

Feedback and Improvements

I’d love to hear your thoughts on this setup! Have you tried similar solutions? Any suggestions for further improvements? I’m particularly curious about how others handle Wi-Fi vs. Bluetooth detection for iOS devices.

Final Thoughts

This project has been a fantastic way to enhance my smart home experience. The ability to automate actions based on presence has made my life so much easier. I hope this guide inspires others to explore the possibilities of Bluetooth presence detection!

Happy tinkering! :blush: