Giter Club home page Giter Club logo

esp8266-arduino-homekit-switch's Introduction

ESP8266 Arduino HomeKit Switch

License: MIT semantic-release

Using an ESP8266 as a switch with native Apple HomeKit support

Demo/Preview

demo

Start/Setup

Initial

On the first startup, the ESP8266 creates an open access point with the name ESP_Switch_AP. Further functionalities are blocked at this time.

Connect with your network

Connect to the public access point. A portal appears where you can search for existing Wifi networks and connect with them. Once you have entered the credentials, the ESP8266 will restart and connect as a client to the selected Wifi network. If a connection is not possible, e.g. due to wrong credentials or a timeout, the ESP8266 will restart as an access point again and the connection credentials can be re-entered. At this point the output can now be toggled with the connected/flash button.

Add to HomeKit

As soon as the ESP8266 is connected to the network, the Home app can be opened on the iOS device and be added as a new device.#

Paring Code

For the paring the following code has to be entered: 111-11-111.

Alternatively, the following QR code can be scanned:

qr-paring-code


Wiring

esp8266-breadboard

Pins

Label GPIO Property
D4 GPIO 2 Output
D5 GPIO 14 Input to toggle in parallel to the onboard Flash button

Workspace

Local Development

Required

  • Arduino v1.8.13
    • Additional Board Manager: https://arduino.esp8266.com/stable/package_esp8266com_index.json
    • Libraries:
      • HomeKit-ESP8266 by Mixiaoxiao v1.2.0: https://github.com/Mixiaoxiao/Arduino-HomeKit-ESP8266
      • WifiManager by tzapu v0.16.0: https://github.com/tzapu/WiFiManager
  • Python 3.9
    • pip curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
      • esptool v3.0 pip install esptool
      • pyserial v3.5: pip install pyserial

Optional

  • VSCode
    • (Extension) Arduino v0.3.4: https://github.com/Microsoft/vscode-arduino
      • Update values of inlcudePath in .vscode/arduino.json to match you environment

Further Configuration

In-/Output

The following definitions can be changed to modify the pins of the inputs and outputs.

Keep in mind the basic properties of the pins, because not every pin can be used as input and output.

// switch.ino
#define PIN_BUTTON 14 // D5 Button
// accessory.c
#define PIN_SWITCH 2 // D4 Output to trigger on/off

Additional Inputs

// switch.ino
void homekit_setup() {
  accessory_init();

  pinMode(PIN_BUTTON, INPUT_PULLUP);
  pinMode(PIN_BUTTON_FLASH, INPUT_PULLUP);
+ pinMode(PIN_BUTTON_DX, INPUT_PULLUP);

  ESPButton.add(0, PIN_BUTTON, LOW, true, true);
  ESPButton.add(1, PIN_BUTTON_FLASH, LOW, true, true);
+ ESPButton.add(2, PIN_BUTTON_DX, LOW, true, true);

    ...
}

Paring Code

Change the property .password to use a different paring code

// accessory.c
homekit_server_config_t config = {
    .accessories = accessories,
-    .password = "111-11-111",
+    .password = "123-45-678",
    .setupId = "ABCD"
};

To create a new QR Code the following page can be used: https://github.com/maximkulkin/esp-homekit/tree/master#qr-code-pairing

Requirements:

  • Python 3.9
    • pip: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
      • qrcode v6.1: pip install qrcode

If the accessory category is still a switch, the following terminal command can be entered to execute the Python script and create a new QR code:

# tools/gen_qrcode <accessory category code> <password> <setup id> <output filename>
tools/gen_qrcode 8 123-45-678 ABCD qrcode.png

Verify & Upload

Select the appropriate port (e.g. /dev/tty.usbserial-1234) and Baud Rate 115200 and start the verification and upload in the switch.ino file in VSCode

Author

Simon Golms

Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show Your Support

Give a ⭐️ if this project helped you!

License

Copyright © 2020 Simon Golms.
This project is MIT licensed.

Resources

esp8266-arduino-homekit-switch's People

Contributors

semantic-release-bot avatar simongolms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

tnq22 602293544

esp8266-arduino-homekit-switch's Issues

can not turn off by homekit

all the way followed ur steps. D4 and 3.3v connect LED. D5 and GND to button.
LED light can be controlled by button correctly. but status on Homekit always OFF.
also, homekit can only turn on the LED with status OFF all the time, not able to turn off.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.