Your smart home knowing when your home is empty can be really useful. You can create automations that turn off your lights, shut down heating or cooling, power down devices, and more. Knowing which room you’re in is even more useful, and a simple ESP32 microcontroller is all you need to set up your own Bluetooth presence sensor.
Why Bluetooth can beat Wi-Fi and GPS for presence detection
No reliance on phone-based geofencing
There are plenty of ways that your smart home can determine whether you’re home or away. You can use GPS to track your location and know when you’ve left your home zone. You can track your Wi-Fi connection and see when you lose connection to your home Wi-Fi network.
Bluetooth Low Energy (BLE) is arguably better than either option. GPS works best with a clear view of the sky, but phone-based geofencing can still take some time to detect when you’ve left your home zone because location updates aren’t continuous.
Wi-Fi is also far from ideal. You can also remain connected to your home Wi-Fi after you’ve left the house, so Wi-Fi-based presence detection can be slow to mark you as away. Wi-Fi presence updates can also be fairly slow, and you may temporarily lose connection even when you’re still at home.
BLE signal strength can provide a rough estimate of the distance of a device, so it can do more than simply tell when you leave home. With multiple Bluetooth proxies around your home, it can even give a reasonably accurate prediction of which room you’re in.
Setting up an ESP32 as a Bluetooth proxy
You may only need one for basic home/away detection
Creating your own Bluetooth presence sensors is remarkably easy. All you need is an ESP32 microcontroller. As long as the board has Bluetooth and Wi-Fi, which is often the case, you can set one up as a Bluetooth proxy in just a matter of minutes.
ESPHome is an open-source platform that lets you build your own custom smart home sensors without having to write a line of complex code. Instead, you create simple YAML configuration files, which ESPHome compiles into firmware for ESP32 chips. The ESPHome site includes ready-made projects with prebuilt configuration files, including one for a Bluetooth proxy.
To make Bluetooth proxies for my home, I connected an ESP32 to my computer, opened the Bluetooth proxy project, selected Generic ESP32, and chose the appropriate port. Clicking Install esphome.bluetooth-proxy installed the firmware, which only takes a couple of minutes.
I was then asked to configure Wi-Fi for the device by choosing my Wi-Fi network and entering the password. Once the setup was complete, there was even a button to add the new Bluetooth proxy to Home Assistant automatically.
Bermuda can give you room-level presence
Track your location (or at least that of your devices)
A Bluetooth proxy can detect nearby BLE devices, but it can’t tell you which room a device is in. That’s why you need additional software that can handle the presence detection. A popular option is Bermuda.
Bermuda is a custom integration you can install via HACS that estimates which Bluetooth proxy is closest to a device. It uses the signal strength reported by the proxies to estimate the distance between the device and each scanner, then uses the Home Assistant area assigned to the closest scanner to determine which room the device is probably in.
Using Bermuda and Bluetooth proxies in different rooms, you can not only determine when you’ve left home, but also estimate which room you’re in. This is really useful for automations, and it’s also incredibly satisfying to be able to ask Assist which room your phone is in when you misplace it.
One small snag is that iPhones and Apple Watches use rotating Bluetooth MAC addresses, which means the visible MAC address can’t be used as a permanent identifier. There’s an integration called Private BLE Device that solves this by using the Identity Resolving Key (IRK) from these devices. When a MAC address is detected, it’s tested against this key, and the integration can confirm that it’s still the same Bluetooth device, despite the MAC address having changed.
Home/Away automations need a little breathing space
Signal loss can happen
There’s one important thing to know here. If you’re setting up automations that are triggered when you leave the house, it’s worth building in a little delay before the automation triggers.
That’s because a device’s Bluetooth signal can temporarily drop out. You might shove the device in a bag, or momentary interference may cause its signal to disappear and trigger your automation.
The more proxies you have and the more devices you track, the less likely it is that every device will disappear at the same time, but it is still possible. Adding a short debounce delay to your automations is worth doing just in case.
An ESP32 is ideal for presence sensing
The beauty of turning an ESP32 into a Bluetooth proxy is that you don’t need any additional hardware, and you don’t even need to write the YAML yourself. It’s one of the easiest things you can do with an ESP32, but it can be incredibly useful.
