ESP32 HomeKit for TOTAL Beginners (Docker + ESP-IDF 5.4 + Demo LED Accessory)

by Achim Pieters in Circuits > Apple

41 Views, 0 Favorites, 0 Comments

ESP32 HomeKit for TOTAL Beginners (Docker + ESP-IDF 5.4 + Demo LED Accessory)

for-TOTAL-beginners.png

A slow, friendly, step-by-step guide from zero to a working HomeKit accessory.

This is for you if you feel stuck because other tutorials assume you already know:

  1. what Docker is
  2. how firmware gets onto a microcontroller
  3. what “flashing” means
  4. why Wi-Fi configuration happens before compiling
  5. what an ESP32 really is

By the end you will:

  1. have a working ESP32 dev environment (without installing ESP-IDF manually)
  2. compile firmware inside Docker
  3. flash it to an ESP32-WROOM-32D
  4. add it to Apple Home
  5. understand what you’re doing (not just copy/paste magic)

What we’re building (big picture)

  1. Prepare your computer
  2. Install Docker
  3. Download ready-made ESP32 HomeKit demo code
  4. Configure Wi-Fi
  5. Compile firmware
  6. Flash to ESP32
  7. Add to Apple Home

Supplies

Screenshot 2026-01-14 at 17.32.30.png
Screenshot 2026-01-14 at 17.32.37.png
Screenshot 2026-01-14 at 17.33.51.png

You need one of these:

Option A (recommended / easiest)

  1. ESP32-WROOM-32D development board (USB built in, buttons, beginner-friendly)

Option B (advanced but fine)

  1. Bare ESP-WROOM-32 module
  2. USB programmer / baseboard

Also needed:

  1. USB data cable (not charge-only)
  2. 2.4 GHz Wi-Fi network
  3. iPhone or iPad with Apple Home

Software

We will install:

  1. Docker Desktop
  2. Git
  3. Python 3
  4. esptool.py

We will not manually install ESP-IDF. Docker handles that.

What Is Docker (simple Explanation)

Screenshot 2026-01-14 at 17.34.30.png

Docker is like a pre-built computer inside your computer.

Inside that mini-computer:

  1. ESP32 tools are already installed
  2. correct versions are already chosen
  3. nothing breaks your real system

This avoids hours of beginner pain.

Install Docker Desktop

Screenshot 2026-01-14 at 17.34.58.png

Download

Go to Docker Desktop and download for your OS (Windows/macOS/Linux).

Install

  1. Run installer
  2. Accept defaults
  3. Finish
  4. Restart your computer

After reboot:

  1. open Docker Desktop
  2. log in (free)
  3. wait until it says “Docker is running”

Verify Docker Works

Screenshot 2026-01-14 at 17.35.05.png

Open a terminal:

  1. Windows: PowerShell
  2. macOS: Terminal
  3. Linux: Terminal

Run:

docker --version

Good output looks like:

Docker version 29.x.x

Now run:

docker ps

You’ll likely see an empty list. That’s perfect.

If it errors: Docker Desktop is not running.

Get ESP-IDF Inside Docker (ESP-IDF 5.4)

Screenshot 2026-01-14 at 17.35.10.png
Screenshot 2026-01-14 at 17.35.17.png
Screenshot 2026-01-14 at 17.35.23.png

We use the official Espressif Docker image so everyone builds with the same toolchain.

Download it:

docker pull espressif/idf:v5.4

Verify it exists:

docker images

You should see something like:

REPOSITORY TAG IMAGE ID SIZE
espressif/idf v5.4 xxxxxxxx ~4GB

Nothing is running yet — that’s normal.

If you ever want to remove it later:

docker rmi espressif/idf:v5.4


Install Git (download Code)

Screenshot 2026-01-14 at 17.35.30.png
Screenshot 2026-01-14 at 17.35.36.png

Install Git from the Git website using default options.

Check it works:

git --version

Install Python 3 + Esptool.py (for Flashing)

Screenshot 2026-01-14 at 17.35.47.png
Screenshot 2026-01-14 at 17.35.42.png
Screenshot 2026-01-14 at 17.35.54.png

We build firmware in Docker, but flashing a real ESP32 is easiest from your normal computer.

Check Python:

python3 --version

Good:

Python 3.x.x

Install esptool:

pip3 install esptool

Verify:

esptool.py version

Good:

esptool.py v4.x

Common problems

“pip not found”

python3 -m pip install esptool

Permission errors (macOS/Linux)

pip3 install --user esptool

Windows issues

  1. re-open terminal
  2. ensure Python is in PATH
  3. use:
python -m pip install esptool

Download the HomeKit Demo Code

Screenshot 2026-01-14 at 17.40.34.png
Screenshot 2026-01-14 at 17.40.45.png

In your terminal:

git clone --recursive https://github.com/AchimPieters/esp32-homekit-demo.git

Enter the folder:

cd esp32-homekit-demo

You should see folders like:

  1. examples
  2. components
  3. CMakeLists.txt

Start the ESP-IDF Docker Container

Screenshot 2026-01-14 at 17.40.54.png

Now we “enter the development box”.

macOS / Linux

docker run -it -v ~/esp32-homekit-demo:/project -w /project espressif/idf:v5.4

Windows (example path)

docker run -it -v C:/Users/YOURNAME/esp32-homekit-demo:/project -w /project espressif/idf:v5.4

What this means:

  1. your folder is shared with Docker
  2. Docker can read/write your files
  3. ESP32 tools are now available

Open the LED Example (first HomeKit Project)

Screenshot 2026-01-14 at 17.41.01.png

Inside the Docker terminal:

cd examples/led

Set target (ESP32 family):

idf.py set-target esp32


Configure Wi-Fi (VERY IMPORTANT)

Screenshot 2026-01-14 at 17.41.14.png
Screenshot 2026-01-14 at 17.41.26.png
Screenshot 2026-01-14 at 17.41.32.png

Run:

idf.py menuconfig

In the blue menu, go to:

  1. StudioPieters
  2. set Wi-Fi SSID
  3. set Wi-Fi password
  4. Save and Exit

Build the Firmware

Compile:Type idf.py build and press enter, and wait until it is done.

idf.py build

After building, you should have:

  1. bootloader.bin
  2. partition-table.bin
  3. main.bin

Hardware Setup (wire One LED)

Screenshot 2026-01-14 at 17.44.07.png
Screenshot 2026-01-14 at 17.44.18.png

We’ll connect one LED so you can see the accessory work.

You need

  1. 1 × LED
  2. 1 × resistor (220Ω – 1kΩ)
  3. 2 × jumper wires
  4. breadboard (optional but recommended)

Pin used by the example

The LED example uses GPIO2.

LED polarity

  1. long leg = positive (+)
  2. short leg = negative (–)

If it’s backwards, nothing breaks — it just won’t light.

Wiring

Connect:

  1. GPIO2 → resistor → LED → GND

Erase Flash (clean Start)

Screenshot 2026-01-14 at 17.44.26.png
Screenshot 2026-01-14 at 17.44.33.png

Open a new terminal outside Docker and go to the example folder:

cd esp32-homekit-demo/examples/led

Erase:

esptool.py erase_flash

While erasing, esptool shows the port name. Write it down.

Examples:

  1. macOS: /dev/cu.usbserial-XXXX or /dev/cu.SLAB_USBtoUART
  2. Linux: /dev/ttyUSB0 or /dev/ttyACM0
  3. Windows: COM3, COM4, etc.

If it does NOT connect (common)

  1. Hold BOOT
  2. Press and release RESET
  3. Release BOOT
  4. Run erase again


Flash the Firmware to the ESP32

Screenshot 2026-01-14 at 17.44.41.png
Screenshot-2026-01-13-at-16.30.55.png

Replace the port name (if needed for your system) and run:

python -m esptool --chip esp32 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 2MB --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/main.bin

When it finishes: firmware is on the ESP32.

Watch It Boot (serial Monitor)

Screenshot 2026-01-14 at 17.45.28.png
Screenshot 2026-01-14 at 17.45.33.png

We use a serial monitor to see what the ESP32 is doing.

Start serial monitor (macOS example)

Use the same port you saw earlier:

screen /dev/cu.usbserial-XXXX 115200

If you see nothing, press RESET on the board.

What you should see:

  1. ESP32 boot info
  2. Wi-Fi connection messages
  3. HomeKit startup logs

Example HomeKit logs:

>>> HomeKit: Starting server
>>> HomeKit: Using existing accessory ID: 1F:01:DB:62:5F:6A
>>> HomeKit: Configuring mDNS
>>> homekit_setup_mdns: Accessory Setup ID = 1QJ8
>>> homekit_run_server: Starting HTTP server

Exit screen

  1. CTRL + A

Add the Accessory to Apple Home

Screenshot 2026-01-14 at 17.51.18.png
Screenshot 2026-01-14 at 17.51.01.png
Screenshot 2026-01-14 at 17.50.22.png
Screenshot 2026-01-14 at 17.49.34.png
Screenshot 2026-01-14 at 17.49.28.png

This is a DIY HomeKit accessory, so Apple will show warnings. That’s expected.

Before you start:

  1. ESP32 powered on
  2. connected to Wi-Fi (check serial logs)
  3. iPhone/iPad on the same Wi-Fi network

Steps

  1. Open the Home app
  2. Tap +
  3. Tap Add Accessory
  4. Scan the QR code (or add anyway if prompted)
  5. Select the accessory when it appears
  6. Accept the “uncertified accessory” warning → tap Add Anyway (possibly twice)
  7. Assign room/name (optional)
  8. Test: Tap ON/OFF → LED should respond

Done (and What’s Nex

Screenshot 2026-01-14 at 17.53.24.png

If you reached this point:

  1. ESP32 boots
  2. Wi-Fi connects
  3. HomeKit pairs
  4. LED responds

You built a real HomeKit accessory!


Next ideas:

  1. change the GPIO to another pin
  2. add a relay instead of an LED
  3. build a real accessory (switch, sensor, power plug, etc.)

More homekit projects can be found on studiopieters.nl