HomeKey-ESP32 is a free, open source internet of things (iot) project written in C++ and released under MIT. It has 1,116 GitHub stars, 100 forks and 47 open issues, and was last pushed 16 days ago. On this registry it ranks #78 of 99 tracked projects in Internet of Things (IoT), with 5 head-to-head comparisons available. It gained 30 stars over the last 30 tracked days.

What is HomeKey-ESP32?

HomeKey-ESP32 is a reverse-engineered, MIT-licensed C++ firmware project that adds Apple Home Key — Apple's secure NFC-based unlocking — to an ordinary ESP32 development board, so a door can be opened with a tap of an iPhone or Apple Watch instead of a certified commercial smart lock.

What it is

HomeKey-ESP32 is a firmware implementation of Apple Home Key for the ESP32 microcontroller, written in C++ and released under the MIT licence. It brings Apple's secure NFC-based unlocking to an ESP32 module near you, driving a physical lock from the board's GPIO while presenting itself to Apple Home as a HomeKit accessory. The project sits in the home automation ecosystem and connects outward in two directions: HomeKit to Apple Home, and MQTT to a Home Assistant broker.

The concrete problem it solves is hardware lock-in. Apple Home Key shipped only on certified smart locks, which means buying a lock you probably do not want. This project replaces that lock: no proprietary hardware is required, only an ESP32 and one supported NFC module — PN532 over SPI, or PN7161 over SPI and ST25R3916 over I2C, both of which are available in the dev release. That makes it usable in retrofit situations where the existing door hardware and wiring must stay in place.

Key capabilities

  • Apple Home Key unlocking over NFC, with Enhanced Contactless Polling (ECP) listed among the project topics alongside apple-home-key, home-key, and nfc.
  • Native HomeKit accessory behaviour, paired to Apple Home with setup code 466-37-726.
  • MQTT publishing to a Home Assistant broker as a parallel control path beside HomeKit.
  • On-device web interface at http://192.168.4.1, reachable after joining the HomeSpan-Setup WiFi access point with password homespan.
  • Firmware split into ConfigManager, LockManager, NfcManager, HomeKitLock, WebServerManager, and MqttManager.
  • Ethernet support through W5500, DM9051, and KSZ8851, plus RMII chips LAN8720/LAN8710, TLK110, RTL8201, DP83848, KSZ8041, and KSZ8081 on ESP32-WROOM-32 boards only.
  • Prebuilt *.firmware.factory.bin release image containing everything needed, with no compilation required.

Who uses it and how

  • Home automation hobbyists who want Apple Home Key without buying a certified smart lock, wiring a PN532 or ST25R3916 reader to an ESP32 by hand.
  • Home Assistant users who bridge the lock into broader automations over MQTT while Apple Home remains a separate, direct path.
  • Retrofit installs where an existing lock or relay is driven from GPIO and only the reader is added to the door.
  • Wired-network deployments where WiFi is unreliable, using the supported Ethernet chips on ESP32-WROOM-32 boards.
  • Builders comfortable with basic electronics and USB flashing from Windows, Mac, or Linux; the repository ships an esp32.yml CI workflow.

Getting started

Download the latest *.firmware.factory.bin from GitHub Releases and flash it with pip install esptool followed by esptool.py --port /dev/ttyUSB0 write_flash 0x0 firmware.factory.bin, or use the browser-based flasher at espressif.github.io/esptool-js, since no compilation is required. Wiring and update instructions live at https://rednblkx.github.io/HomeKey-ESP32/.

How it compares

This project stands alone in this registry, as no comparable Home Key implementation is named in the source facts. The only adjacent effort mentioned is the author's own forthcoming project built on the Aliro standard, which is not yet public.

When to use it — and when not to

A self-hoster must supply the ESP32 board, an NFC module, the wiring, and a computer to flash over USB, and must be willing to work without a hosted option. Flash memory is not encrypted, a limitation the author documents openly and attributes to the project's origins as a personal build, with encrypted flash promised for a future Aliro-based project rather than for this one. Anyone who needs encryption at rest, a vendor-supported product, or PN7161 and ST25R3916 support outside a dev release should look elsewhere, and 47 open issues indicate development that is active but not fully settled.

project readme (upstream, from github) — read inline
homekey-logo-200x200

HomeKey-ESP32

Discord CI License: MIT

Apple HomeKey functionality for the rest of us

Documentation

What is HomeKey-ESP32?

The project aims to be the easy DIY solution for using Apple's HomeKey feature without the need to purchase a compatible smart lock that you probably don't want. HomeKey-ESP32 brings Apple's secure NFC-based unlocking to an ESP32 module near you, enabling you to unlock doors and whatnot with a simple tap of your iPhone or Apple Watch.

No proprietary hardware required – just an ESP32 and one of the supported NFC modules

[!WARNING] The flash memory is not encrypted as this kinda started as a pet project of mine but a lot of people started using so unfortunately it's stuck like this because migration would be painful and i don't want to be telling people to reconfigure their device if they want to update.

If you care about this, i'm working on a new project implementing the new Aliro standard and flash will be encrypted first thing, however, honestly don't know when that will be public, you can join the Discord server if you want to know as soon as it is available.

Getting Started

[!TIP] A wiki documenting the project can be found at https://rednblkx.github.io/HomeKey-ESP32/

Prerequisites

  • ESP32 Development Board
  • NFC reader - one of:
    • PN532 (SPI)
    • PN7161 (SPI) - available in the dev release
    • ST25R3916 (I2C) - available in the dev release
  • USB Cable (for flashing and power)
  • Computer (Windows, Mac, or Linux)
  • Basic Electronics Knowledge (not a problem if you're new to this, ask away!)
Ethernet

The following chips are supported for Ethernet:

  • W5500
  • DM9051
  • KSZ8851
  • LAN8720 / LAN8710
  • TLK110
  • RTL8201
  • DP83848
  • KSZ8041
  • KSZ8081

[!IMPORTANT]

The following are only supported for ESP32-WROOM-32 boards as other variants lack the internal EMAC needed for the RMII interface:

  • LAN8720 / LAN8710
  • TLK110
  • RTL8201
  • DP83848
  • KSZ8041
  • KSZ8081

Installation Steps

  1. Download Firmware

    • Visit GitHub Releases
    • Download the *.firmware.factory.bin file
    • This contains everything you need - no compilation required!
  2. Connect Your Hardware

    • Wire your chosen NFC module to your ESP32 using the default pins
    • Refer to the detailed wiring guide for your specific setup
  3. Flash the Firmware

    # Install esptool (one-time setup)
    pip install esptool
    
    # Flash the firmware (replace YOUR_PORT)
    esptool.py --port /dev/ttyUSB0 write_flash 0x0 firmware.factory.bin
    

    Prefer a GUI? Use the browser-based flasher - no command line needed!

  4. Initial Setup

    • Connect to the device's WiFi AP (HomeSpan-Setup / homespan)
    • Access the web interface at http://192.168.4.1
    • Configure your WiFi credentials and HomeKit setup code
    • Pair with Apple Home using code: 466-37-726
  5. Start Using HomeKey!

    • Hold your iPhone or Apple Watch near the NFC reader
    • Enjoy instant, secure access to your home! 🎉

Updating

Follow the update in the documentation at: https://rednblkx.github.io/HomeKey-ESP32/updates/

System Architecture

graph TD
    A[iPhone/Apple Watch] -->|RF| B[NFC Module]
    B -->|SPI| C[ESP32]
    C -->|MQTT| D[Home Assistant/Broker]
    C -->|HomeKit| E[Apple Home]
    C -->|HTTP| F[Web Interface]
    C -->|GPIO| G[Physical Lock]
    
    subgraph "HomeKey-ESP32 Core"
        C
        H[ConfigManager]
        I[LockManager]
        J[NfcManager]
        K[HomeKitLock]
        L[WebServerManager]
        M[MqttManager]
    end
    
    style A fill:#1f2937,stroke:#374151,color:#fff
    style C fill:#059669,stroke:#047857,color:#fff
    style B fill:#3b82f6,stroke:#2563eb,color:#fff

✨ Key Features

Apple HomeKey Integration

  • Express Mode: Unlock without waking your device
  • Power Reserve: Unlock even when the device needs to be charged
  • Multi-Device Support: Works with iPhone and Apple Watch
  • Fast Authentication: Sub-300ms unlock times

Smart Home Ready

  • HomeKit Native: Full Apple Home ecosystem integration
  • MQTT Support: Connect to Home Assistant, OpenHAB, and other platforms
  • Home Assistant Discovery: Automatic device detection and configuration
  • Custom States: Support for complex lock states (jamming, unlocking, etc.)

Modern Web Interface

  • Svelte Frontend: Responsive, modern UI built with Svelte 5 + Tailwind CSS
  • Real-time Updates: WebSocket-powered live status updates
  • OTA Updates: Over-the-air firmware updates via web interface
  • Configuration Management: Easy setup without recompiling

Developer Friendly

  • Open Source: MIT licensed, community-driven development
  • Modular Architecture: Clean separation of concerns
  • Event System: Pub/sub architecture for extensibility
  • Comprehensive Logging: Debug and monitor with detailed logs

Development

graph TD
  %% External Systems & Hardware
  subgraph "External World"
      A[iPhone / Apple Watch]
      B[Apple Home]
      C[Web Browser]
      D[MQTT Broker]
      E[Physical Lock, Buttons & LEDs]
  end

  %% Main Application on ESP32
  subgraph "HomeKey-ESP32 Core"
      
      subgraph "Interface Managers (I/O)"
          direction LR
          Nfc[NfcManager]
          HK[HomeKitLock]
          Web[WebServerManager]
          Mqtt[MqttManager]
          Hw[HardwareManager]
      end

      subgraph "Logic Core (State Machine)"
          Lock[LockManager]
      end

      subgraph "Data Services (Persistence)"
          direction LR
          Config[ConfigManager]
          Reader[ReaderDataManager]
          NVS[(NVS Storage)]
      end

      %% High-level Data and Control Flow
      DataServices[Data Services] -- "Provides Config & Reader Data" --> InterfaceManagers[Interface Managers]
      DataServices -- "Provides Config" --> LogicCore[Logic Core]
      Config -- "Reads/Writes" --> NVS
      Reader -- "Reads/Writes" --> NVS
      
      InterfaceManagers -- "State Change Requests (e.g., Unlock)" --> Lock
      Lock -- "Actions & State Updates" --> InterfaceManagers
  end
  
  %% Connections to the External World
  A -- NFC --> Nfc
  B -- HomeKit --> HK
  C -- HTTP/WebSocket --> Web
  D -- MQTT --> Mqtt
  E -- GPIO --> Hw
  
  Hw -- GPIO --> E
  HK -- HomeKit --> B
  Web -- HTTP/WebSocket --> C
  Mqtt -- MQTT --> D

  %% Styling for clarity
  style A fill:#1f2937,stroke:#374151,color:#fff
  style B fill:#1f2937,stroke:#374151,color:#fff
  style C fill:#1f2937,stroke:#374151,color:#fff
  style D fill:#1f2937,stroke:#374151,color:#fff
  style E fill:#1f2937,stroke:#374151,color:#fff

  style Nfc fill:#3b82f6,stroke:#2563eb,color:#fff
  style HK fill:#059669,stroke:#047857,color:#fff
  style Web fill:#f59e0b,stroke:#d97706,color:#fff
  style Mqtt fill:#ef4444,stroke:#dc2626,color:#fff
  style Hw fill:#8b5cf6,stroke:#7c3aed,color:#fff

  style Lock fill:#ec4899,stroke:#db2777,color:#fff
  
  style Config fill:#6b7280,stroke:#4b5563,color:#fff
  style Reader fill:#6b7280,stroke:#4b5563,color:#fff
  style NVS fill:#9ca3af,stroke:#6b7280,color:#fff

Project Structure

HomeKey-ESP32/
├── main/                    # Core ESP32 application
│   ├── main.cpp            # Application entry point
│   ├── ConfigManager.cpp    # Configuration management
│   ├── ReaderDataManager.cpp # Reader data management
│   ├── NfcManager.cpp      # NFC communication
│   ├── Pn532Reader.cpp     # PN532 backend (SPI)
│   ├── Pn7160Reader.cpp    # PN7160 backend
│   ├── St25r3916Reader.cpp # ST25R3916 backend (I2C)
│   ├── HomeKitLock.cpp     # HomeKit integration
│   ├── LockManager.cpp     # Lock state management
│   ├── MqttManager.cpp     # MQTT client
│   ├── WebServerManager.cpp # Web interface
│   ├── WebSocketLogSinker.cpp # WebSocket logging sinker
│   ├── HardwareManager.cpp # Hardware manager
│   └── HKServices.cpp # HomeKit services
├── data/                   # Web interface files
│   ├── src/               # Vue.js application
│   └── index.html         # Web UI entry point
├── components/            # External dependencies
│   ├── HK-HomeKit-Lib/   # HomeKey implementation
│   ├── HomeSpan/         # HomeKit framework
│   └── PN532/            # NFC driver
└── docs/                 # Documentation
    └── content/          # Hugo documentation

Core Components

Component File Purpose
NFC Manager NfcManager.cpp Drives the selected NFC backend and HomeKey authentication
NFC Backends Pn532Reader.cpp / Pn7160Reader.cpp / St25r3916Reader.cpp Reader implementations behind the common INfcReader interface
HomeKit Bridge HomeKitLock.cpp Manages Apple HomeKit integration and pairing
Lock Manager LockManager.cpp Controls lock state transitions and GPIO actions
MQTT Client MqttManager.cpp Enables smart home integration via MQTT
Web Server WebServerManager.cpp Provides configuration UI and OTA updates
Config Manager ConfigManager.cpp Handles persistent configuration storage

Building from Source

# Install dependencies
git submodule update --init --recursive

# Install esp-idf v5.4 or newer -- CI builds against v5.5.4.
# Earlier versions do not compile: the pn7160 and pn532_hal components use
# esp_log_buffer.h and spi_bus_dma_memory_alloc, both introduced in v5.4.
# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#get-started

# Build firmware
idf.py build

# Flash to device
idf.py -p /dev/ttyUSB0 flash

# Monitor output
idf.py monitor

Contributing

Contributions are welcomed! Please see the Contributing Guidelines for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request against the main branch

Support the Project

HomeKey-ESP32 is openly developed and maintained by the community. Your support helps us continue improving the project.

  • Star the repository to show your appreciation
  • Report bugs to help improve stability
  • Suggest features to guide development
  • Share the project with your network
  • Contribute documentation to help others

Credits

  • @kormax: Reverse-engineered the HomeKey NFC protocol and published the foundational PoC implementation
  • @kupa22: Researched the HAP (HomeKit Accessory Protocol) side of HomeKey
  • HomeSpan: Excellent HomeKit framework that powers our integration
  • ESP-IDF: Robust IoT development framework from Espressif

License & Legal

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

Important: This project implements Apple HomeKey functionality through reverse engineering. While we strive for security and compatibility:

  • Not affiliated in any shape or form nor condoned by Apple Inc.
  • Use at your own risk for security-critical applications
  • May lack elements from Apple's private specifications
  • Subject to change as Apple updates their protocols

Trademarks

  • Apple, iPhone, and Apple Watch are trademarks of Apple Inc.
  • ESP32 is a trademark of Espressif Systems (Shanghai) Co., Ltd.
  • Home Assistant is a trademark of Open Home Foundation

Frequently asked questions

Is HomeKey-ESP32 free to use?

HomeKey-ESP32 is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does HomeKey-ESP32 do?

ESP32 HomeKit Lock with support for Apple Home Key (reverse-engineered)

What is HomeKey-ESP32 written in?

HomeKey-ESP32 is primarily written in C++. Its source is publicly available at https://github.com/rednblkx/HomeKey-ESP32, and it has 1,116 GitHub stars.