Getting the IRK for your phone

Devices that use Bluetooth randomised mac address security and an IRK (Identity Resolving Key) - which is to say all smartphones - can be tracked by installing the Private BLE Device integration which is part of HA core. You will need to tell the integration the IRK for each of your devices.

This is how to find the IRK for your phone - it works for Android and Apple devices.

Summary:

  1. Install Arduino IDE (Integrated Development Environment) on a desktop or laptop - Windows, Linux or Mac; it will not run on a Chromebook.

  2. Connect the ESP32 device of your choice (in this guide an M5STACK ATOM LITE).

  3. Download esp32_get_irk from GitHub and flash it to your device.

  4. With the ESP32 device still connected to Arduino IDE, pair your phone with it.

  5. The IRK will be displayed in the IDE.

What do you need?

Set up Arduino IDE

  1. On your PC/laptop, download and install the Arduino IDE. The screenshot below is Arduino IDE 2.

  1. Add support for the M5STACK Atom
  • Open the Arduino IDE and click File in the top left corner, then Preferences
  • Paste the following URL into Additional boards managers URLs and click OK
  https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
  • In the left hand toolbar, click the Boards icon (second one down)
  • Search for M5STACK and click install

The IDE is now ready for your device.

This topic is part of the community-driven cookbook where you can find other topics you might be interested in or might like to contribute to.

Flashing the M5STACK

  1. Download the code from Github (click the green “Code” button, then download Zip)

  • Extract the contents of the zip
  • In Arduino IDE - open the extracted esp32_get_irk folder and then open the file esp32_get_irk.ino
  1. Connect the M5STACK atom to the computer
  2. In the top bar of the IDE, click on the dropdown and select the port the device is connected to.
  3. Select the board type (M5STACK Atom)
  4. Click the arrow button in the top left corner, the IDE will start compiling and uploading the package to your device

Getting the IRK

  1. In Arduino IDE
  • In the top right corner, click on the magnifying glass (on windows Tools | Serial Monitor), this will open the serial monitor in a panel at the bottom of the screen.
  • In the top right-hand corner of the serial monitor panel, change the baud rate to 115200
  1. On your phone
  • Go to Bluetooth settings
  • Select pair new device
  • In the available devices list, search for ESP_BLE_SECURITY and pair
  1. In Arduino IDE you will get the IRK key in several foramats:
  • IRK: ,0x1A,0x1B,0x1C,0x5E,0x87,0xD2,0x1D,0x57,0x27,0x14,0x4B,0x19,0xAD,0x58,0xCF,0x41
  • IRK, Base64 encoded for the Home Assistant Private BLE Device service: GhscXofSHVcnFEsZrVjPQQ==
  • IRK, reverse order for Home Assistant ESPrensence: 41CF58AD194B1427571DD2875E1C1B1A

You can now unpair your phone.

This is a simplified version of a post by @legoracers with a couple of screenshots added.


Cookbook Index

3 Likes

I used the PsExec64 method listed for Windows with my iPhone. Was easy to do and did not require flashing anything.

2 Likes

Me too
In Windows is so easy

As long as you can connect your phone to it via Bluetooth. If that is not possible then this guide is a good alternative.

Linux here, so that’s out. :slightly_frowning_face:

One advantage of the Arduino method is that once you’ve flashed your ESP32 device you can use it as many times as you like - getting IRKs for the whole family only takes a few seconds.

1 Like

Me too, with help from Tom.

I used the referenced procedure for an iPhone13 and an iPad Air 3 and it worked fine on a Windows Laptop with an Intel Blueteooth Adapter, but not on a Realtek one. My trials and solution are in that linked thread for anyone who stumbles across this thread.

My question relates to older iPads; I have an iPad 4 and that did not work on my Intel Adapter at all, it gave the same “IRK-free” information in the registry as my failed attempts. Has anyone tried the Windows method with older iOS devices?

[EDIT ] Fixed it myself, see here.