GUIDE - Getting the IRK for iPhone and Apple Watch without MacOS (Maybe also other devices?)

Hi Everyone,

I have seen some people in the community (including myself) struggle to get the IRK for the Private BLE integration.
In the documentation, the documented way is using Keychain on a MacOS device. But not everyone that has an iPhone has access to a MacOS device.

After searching around on the internet I found a way to get the IRK without using MacOS, but with a ESP32.

What do you need?

1. Setting up Arduino IDE
First, download and install the Arduino IDE (Download link).
After installing you want to add support for the ESP32 boards or the M5STACK boards.


  1. Open the Arduino IDE and click the second icon down in the left hand bar.
  2. Search for “esp32” and install the one by “Espressif Systems”.
  3. The IDE is now ready for your device.


  1. Open the Arduino IDE and click “File” in the top left corner and click on “Preferences”.
  2. Paste the following URL in the “Additional boards managers URLs” and click OK: (
  3. Click the second icon down in the left hand bar.
  4. Search for M5STACK and click install.
  5. The IDE is now ready for your device.

2. Installing the software on the device
I found the following code online, This is not my code, i am not responsable if you run this code!

  1. Download the code from Github by pressing the green “Code” button and clicking “download Zip”
  2. Extract the zip, open the folder and rename the folder “get_irk” to “esp32_irk”
  3. Open the “esp32_irk” folder and open the “esp32_irk.ino” file
  4. Connect the ESP32 (or M5STACK atom) to the computer
  5. In the top bar, click on the dropdown and select the port the device is connected to.
    You will now get a prompt to select a board type, for most people it wil be ESP32 Dev Module, otherwise search for the M5STACK Atom.
  6. Click the arrow button in the top left corner, the IDE will start compiling and uploading to your device.
    If the IDE fails, check the instructions for your device on how to upload new code.

3. Getting the IRK

  1. In the top right corner, clck on the magnifying glass, this will open the serial monitor.
  2. Change the baud rate to 115200
  3. Download the Bluetooth Terminal app App Store link
  4. Open the app and connect to “ESP_BLE_SECURITY”
  5. In the serial monitor you wil get the IRK key in the following format:
  6. If you want to get the key for you Apple Watch too, restart the ESP or Atom Stack, open the serial monitor and connect through the Apple Watch app.

4. Converting the value to the correct format

  1. Copy the value from the terminal to a text editor and remove every “,0x” and “IRK:”. You will end up with something like this: “1A1B1C5E87D21D5727144B19AD58CF41”.
    If you want to use the key for ESPrensence reverse the order of the key in pairs of 2, with the example given you will end up with “41CF58AD194B1427571DD2875E1C1B1A”. (Thank you @sota!)
  2. This value is the decimal value of the IRK key, but Home Assistant expects the base64 encoded version of this key. Use the following website to encode the key Base64 encoder
  3. Congratulations, this key can be used in Home Assistant as the Private BLE IRK key!

Thank you. Maybe I’m going blind but I don’t see a link in step 2 to download the zip file.

1 Like

Sorry! I fixed it!

The link just points to this post :upside_down_face: :wink:

I don’t know how that happend, but I fixed it. :sweat_smile:

That works! Thanks :+1:

I followed your instructions and it worked first time, great! In order to use this with ESPHome ESPresence, take the number you have in step 4.1 and reverse the order of each pair of numbers so that you end up with a 32 digit hex number. Using the IRK above you would get 41CF…1B1A.
You can then add that number into the Known BLE identity resolving keys field in ESPresence configuration.

1 Like

I’m struggling to find an option in the Apple Watch app to connect by Bluetooth. Could you point me in the right direction?

Just download the app on AppStore, it has a pairing Apple Watch app which will be automatically installed to your Apple Watch. Thereafter just launch the app on your Apple Watch itself - it can be found in the list of applications.


Did you have to add anything else to the hex number in irk field on espresence config page? My device shows not home and wonder if i’m missing something.

No, just enter the 32 digits. The integration seems to do a sanity check, so it will reject the IRK if it doesn’t see it nearby. You could try enabling debug logging for the integration, and have a look at this github issue for some help.

Hi Martin,

The app that is used on the iPhone is also installed on the Apple Watch.
You can use this app to connect.

Don’t forget to restart the ESP if you connected with your iPhone before!

1 Like

I added this to the instructions!

Awesome, I got it to finally show up in ESPresence but it seems to switch to not home after getting picked up by each room sensor. It will connect for a max of 2 or 3 minutes. Any suggestions?

I use the Private BLE integratation from HA itself. Maybe you can create a new topic on the forum.


For whatever reason the app is not installed on my apple watch after installing on my apple phone. Any ideas what I can do??
I already uninstalled an reinstalled the app on the phone.
Did reboots of both devices.


Hi @james4711, in the Watch app on your iPhone, under the “General” section, there is a setting called “Install apps automaticly”. Is this enabled?

Yes, this is enabled … the app is also not presented to be available to be installed at the very bottom of the app-list in the watch app on the iphone.

Any other ideas??


What is the generation of watch that you are using? I am using a Apple Watch series 3.
Maybe the app is not compatible?

I am using Apple Watch 7.