ESP01-Homekit-Switch is an open-source project that allows you to turn an ESP8266 module (such as ESP01 or ESP8266-01S) into a smart home automation switch device that can connect to Apple Homekit.
- Make sure you have Git installed.
- Install Python and the necessary library
esptool
. - Set up the environment for compilation, recommended to use
esp-open-sdk
. - If not compiling on the host machine, use
Docker
.
git clone https://github.com/TaylorLottner/esp01-homekit-switch.git
Set up the SDK environment:
For details, see:esp-open-sdk
cd esp01-homekit-switch
make -C devices/switch all
-
Set Up Docker Environment
Using a Docker container can simplify the environment setup process.docker run -itd --name esp -v /opt/esp01-homekit-switch:/opt/esp01-homekit-switch jedie/esp-open-sdk:latest /bin/bash
-
Enter the Container
Enter the Docker container to execute the compilation commands.docker exec -it esp /bin/bash
-
Compile the Project
Navigate to the root directory of the project within the container and start the compilation.cd /opt/esp01-homekit-switch make -C devices/switch all
After compilation, the switch.bin file will be generated in the /devices/switch/firmware directory.
-
Install esptool
If you haven't installed esptool yet, install it via pip.pip install esptool
-
Prepare Firmware Files
Ensure the /devices/switch/firmware directory contains the rboot.bin, blank_config.bin, and switch.bin files. -
Erase Flash
Use esptool to clear the old firmware from the device.esptool -p [端口] erase_flash
-
Flash New Firmware
Use esptool to flash the new firmware onto the device.esptool -p [端口] -b 115200 write_flash -fs 1MB -fm dout -ff 40m 0x0 rboot.bin 0x1000 blank_config.bin 0x2000 switch.bin
-
Scan QR Code
Connect the device to HomeKit by scanning the provided QR code. -
Manual Input
If you cannot scan the QR code, you can manually add the device with the following steps:- Connect to the device's hotspot H.A.N-XXXXXXX.
- Open the “Home” app on your iPhone.
- Tap the + icon in the upper right corner and select “Add or Scan Accessory”.
- Choose “I Don’t Have a Code or Cannot Scan” option.
- Select the appropriate accessory and enter the pairing code 52101314.
Special thanks toLeeLulin/esp-homekit-direct