Skip to content
My Account

HomeKit

ESP32-CAM as a HomeKit Camera

A proof of concept: the AI-Thinker ESP32-CAM as a camera accessory in the Apple Home app, with a still image and a stream that is not smooth.

  • ESP32
  • HomeKit
  • Archived
  • 3 min read
No ratings yet, be the first.

Archived project

The GitHub repository for this project is archived: it is read-only and no longer updated. What follows describes the project as it was, so check for a newer alternative before you build it.

A HomeKit camera on an ESP32-CAM: a small board with a camera that shows up as a camera accessory in the Apple Home app. It is a proof of concept. The picture works in the Home app, both as a still image and as a stream, but the stream is not smooth.

The project dates from May 2019. For current ESP32 HomeKit work, start with ESP32 HomeKit Development with ESP-IDF.

What you need

PartDetails
BoardAI-Thinker ESP32-CAM
Flash4 MB, as selected in the build settings
MemoryExternal SPI RAM (PSRAM) enabled in the build settings
USB adapterAn FTDI adapter to flash the board
Build machineA Mac, as the installation scripts in the repository are written for macOS

The repository shows a diagram of the adapter supply measured with a multimeter, which reads 5.0 V. Measure the supply before you connect a board to it.

Diagram of an FTDI adapter with its supply pins connected to a multimeter that reads 5.0 V

Set up the build environment

The repository has two installation scripts. They install the tools for ESP-IDF version 3.2 on a Mac:

  1. one.sh installs pip, downloads the Xtensa ESP32 toolchain (xtensa-esp32-elf 1.22.0-80), clones ESP-IDF v3.2 with its submodules and adds the toolchain to your PATH and IDF_PATH in ~/.zshrc.
  2. two.sh installs the Python packages that ESP-IDF needs from its requirements.txt.

The HomeKit code comes from esp-homekit-demo by Maxim Kulkin, which you build yourself. The camera repository has no source code of its own, only the scripts, the images and one release.

Build settings

The build is set up with make menuconfig. The screenshots in the repository show these settings:

SettingValue
Partition tableCustom partition table CSV, partitions.csv
SPI RAMInitialise SPI RAM when booting the ESP32, external RAM made available through malloc()
HomeKit flash addressSPI flash address for storing HomeKit data, set to 0x3A0000
Camera pinoutESP32-CAM by AI-Thinker
Camera clockXCLK frequency 20000000 (20 MHz)
Flash size4 MB, DIO mode, 40 MHz
The menuconfig Partition Table menu with a custom partition table CSV file selected
The menuconfig SPI RAM config menu with SPI RAM initialisation enabled
The menuconfig dialog for the SPI flash address for storing HomeKit data, set to 0x3A0000
The menuconfig Select Camera Pinout menu with ESP32-CAM by AI-Thinker selected
The menuconfig flash size menu with 4 MB selected

The ESP32 HomeKit Camera menu also holds the WiFi name and password and the LED pin, which is GPIO 1 in the screenshots with the LED active high. Fill in your own WiFi details there.

Build and flash

With the settings saved, build the firmware, flash the board and open the serial monitor in one go:

make flash monitor

The release on GitHub, version v0.0.1 of 21 May 2019, has a prebuilt main.bin and a signature file, main.bin.sig. The way to get the camera running is to build it yourself as described above.

When the board is running, add it in the Home app as a new accessory.

Good to know

  • It is a proof of concept. Expect a stream that is not smooth, and nothing that is ready to use as a security camera.
  • The HomeKit Accessory Protocol specification the firmware follows is the non-commercial version, for accessories you build yourself and do not distribute or sell.
  • The repository is under the MIT licence.

The project is in the esp32-homekit-camera repository on GitHub.

Advertisement
All HomeKit

More HomeKit

Keep building.

Switches, sensors, plugs and blinds: more accessories that you build yourself and add to the Home app.

All HomeKit