Skip to content
My Account

HomeKit

ESP8266 HomeKit Button Switch

A small ESP8266 that appears in the Home app as a HomeKit switch, to turn another accessory on or off. A test setup with an ESP-01, three buttons and an FTDI adapter.

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

A small ESP8266 that shows up in the Apple Home app as a HomeKit switch. It is on or off, and that is what makes it useful: switch it from the Home app, or use it as a trigger to turn another accessory on or off through an automation.

This is a test setup, built to check that the code and the hardware work together.

What it does

FeatureDetails
HomeKit switchAppears in the Home app with a plain on and off state
Physical buttonA SWITCH button on the device
UseSwitch another accessory on or off, for example from an automation
UpdatesOver the air, through Life Cycle Manager 2
No cloudControl stays on your own network

Hardware

ComponentNotes
ESP8266 ESP-01 module8 pins, only two usable GPIOs. See the ESP8266-01 pinout
3 push buttonsLabelled RESET, PROGRAM and SWITCH on the diagram
USB-serial (FTDI) adapterFor flashing, and for power in this test setup. Set it to 3.3 V logic
470 µF capacitor, 6.3 VAcross the supply, as drawn. Needed for stable operation when the module is powered from the FTDI adapter
Resistors and a small ceramic capacitorPull-ups on the buttons and a ceramic capacitor across the SWITCH button, as drawn

In this test setup the module is powered from the FTDI adapter. Place the 470 µF capacitor across the supply as drawn, because the setup needs it to run stably. Powering from the FTDI adapter works for testing, but it is not recommended for long-term use.

Wiring

The Fritzing diagram at the top of this page shows the whole build on a breadboard. Reading the wires against the ESP-01 pinout gives this assignment:

PartESP-01 pinPurpose
SWITCH buttonGPIO2The HomeKit switch input
PROGRAM buttonGPIO0Pulls GPIO0 low, which puts the module in flash mode
RESET buttonRSTResets the module
FTDI adapterTXD and RXDSerial connection, crossed over to the adapter
3.3 V supplyVCC and CH_PDCH_PD is tied high to keep the chip enabled

These pins are read from the diagram and are not listed in the repository text, so check them against the diagram before you build. The ESP-01 needs GPIO0 and GPIO2 high at reset for a normal start, which is why the buttons have pull-up resistors. Use an FTDI adapter set to 3.3 V, because a 5 V adapter can damage the module.

Flash and install

The installation is the same as for the other ESP8266 HomeKit accessories on this site. The firmware runs on ESP-Open-RTOS with Life Cycle Manager 2, which sets up the WiFi and installs updates over the air. The three boot files (rboot.bin, blank_config.bin and otaboot.bin) are in the repository, and the full steps, from installing esptool to flashing, joining the LCM- WiFi network and pairing, are in ESP8266 HomeKit Blinds.

In the portal, use these values:

FieldValue
OTA repositoryAchimPieters/ESP8266-HomeKit-Button
OTA binary filemain.bin

When the installation is done, scan the QR code the device generates in the Home app to add it.

Firmware release

VersionDateFiles
0.0.19 May 2019main.bin

The firmware is published as a binary in the release.

Good to know

  • This is a test setup and not a finished product.
  • 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 has the boot files, the diagram and the MIT licence, but no source code.

Everything is in the ESP8266-HomeKit-Button 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