BLE Apple Presence Detection (ESPHome + IRK) — Working Solution

Objective

Detect a specific person carrying an Apple device (iPhone or Apple Watch) to automatically unlock a garden gate. The gate area has sufficient Wi‑Fi coverage, allowing an ESP32 to operate there.

System Architecture

  1. BLE Ownership Detection

    Implemented via ESPHome using the component esp32_ble_tracker.

    Apple devices use MAC randomization, so detection requires the Identity Resolving Key (IRK).

    Once the IRK is known, the ESP32 can reliably identify the device.

  2. PIR Presence Validation

    A short‑range PIR sensor confirms that an actual person is physically near the gate.

    Multiple PIR sensors can determine movement direction (approaching vs. leaving).

  3. Combined Logic

    BLE IRK match → “device belongs to the authorized person”

    PIR trigger → “person physically present”

    Combined condition → gate unlocks

Obtaining the IRK (Mandatory for Apple Devices)

ESPHome cannot extract IRKs. A temporary helper tool is required.

Temporary Tool: ESPresense

see video: “Bluetooth Presence Detection in Home Assistant — The EASY Way!”

  • Flash ESPresense onto a separate ESP32. 
    
  • Open its web interface.
    
  • Navigate to Other Settings → Devices.
    
  • Start Enroll.
    
  • Select device type (iPhone / Apple Watch).
    
  • Allow the Apple device to connect to ESPresense.
    
  • ESPresense displays the IRK.
    
  • Copy the IRK into your ESPHome configuration.
    

After this step, ESPresense is no longer needed.

Returning to ESPHome Only

Once the IRK is known:

ESPHome’s esp32_ble_tracker can identify the Apple device reliably.

The RSSI sensor provides distance estimation.

PIR sensors provide physical presence and direction.

Combined logic enables robust, person‑specific access control.

Result

Reliable identification of a specific person

No cloud services required

Works with Apple devices despite MAC randomization

Direction detection possible with multiple PIR sensors

Fully local, ESPHome‑based automation
1 Like

Why not just stay with using Espresence instead of only temporarily using and then removing it for a far worse option? Im just trying to figure out the logic here and why you’d rather use Esphome when Espresence is a purpose made firmware for doing exactly the same things and in basically all cases it does them excellent and the data/locations are quick to update and very accurate. Are you just using Esphome because you want the logic/automations on the same esp32 or what?

Indeed, bundle with other chores in a single ESP.

To monitor him is actually very simple, you only need to have an old Android tablet or an unplugged Android device at home, at least Android 7 can be perfectly detected, without preparing the device, I successfully and stably implemented this solution, and let a large number of devices be successfully implemented, if possible, you can experience it

Ya, i was basically not in agreement with using Esphome for BT room presence detection.

Normally id agree on that and do that myself normally but, if your intending to do room level detection then there’s really no reason to add additional components because most people dont just use a single esp32 in each room so its not necessary to “bundle it with extra chores” especially when doing BT tracking alone is already very resource intensive and the less non-critical things on there the better off it will be and will operste.

Im not really sure if you’re realizing how much better Espresence is for doing this task and its not just simply about converting rssi sensors into “distance away” sensors.

Is this your first and/or only esp32 BT presence node that you have operating inside/outside of your home?? If not then how many currently and how many will you need total??

To do what exactly? What are they going to use only 1 for and is useful? Are you talking about uaing it solely for the initial setup for creating trackers based on individual devices being detected with it??