A project that you use the Arduino IDE and load onto a ESP8285/ESP32 Sonoff R2 and it allows you to control it natively with Apple HomeKit.
Go back to Will's Homekit stuff
- Frequent lights toggling randomly
- If WiFi router reboots, lights disconnect and don't reconnect until rebooted
- Talk to each other and seem to toggle each other on and off
As sadi above I have encoutered many issues with the native Homekit library branch, and this code base tries to fix many of those issues with the following:
- The unit will reboot if no HomeKit Clients are found after 2 minutes
- EEPROM storage for lights on/off are in a different location
- WiFi Disconnect / Reconnect if router switches off
- Pin 2 controls a relay that allows for the fan to change states from on to off
- This is for a on/off state switch (No dimming)
- Take Sonoff Unit apart (find the 4 pins on the board for 3v, ground Tx & Rx
- Plug in your USB UART Cable
- Have the Ardunio IDE installed
- Download Ardunio HomeKit Library and ESP8266 Board Manager
- You might also need ESP HomeKit Library / ESP Serial Library
- Download this file and then open the .ino file with Ardunio
- You need to go into wifi_info.h and edit the wifi username and password:
const char *ssid = "WIFI SSID";
const char *password = "WIFI Password";
- You NEED to edit the my_accessory.c file You need to edit the 01 and increase this to 02, 03, 04, 05 etc for EACH switch, no two switches can have the same name.
homekit_characteristic_t cha_name = HOMEKIT_CHARACTERISTIC_(NAME, "Homekit SW 01");
HOMEKIT_CHARACTERISTIC(NAME, "Homekit SW 01"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "Sonoff-Switch-01"),
If you experience inverted switch behavior (ON becomes OFF and vice versa) between different ESP8285 hardware versions:
- For ESP8285 v1.0 units: Set
#define ESP8285_V1_3 falsein the code - For ESP8285 v1.3 units: Set
#define ESP8285_V1_3 truein the code
The difference is due to hardware changes in relay wiring or GPIO pin behavior between versions. The code now includes conditional compilation to handle both hardware versions.