Skip to content

Instantly share code, notes, and snippets.

@Stichoza
Last active December 25, 2024 19:14
Show Gist options
  • Save Stichoza/a25a3d29171a6c3a425c382408711029 to your computer and use it in GitHub Desktop.
Save Stichoza/a25a3d29171a6c3a425c382408711029 to your computer and use it in GitHub Desktop.
Flashing Sonoff with HomeKit support

Flashing Sonoff with HomeKit support

Pre-requisites

  1. Install ESP Tool if you don't have it already.
  2. Download fullhaboot.bin file.

Flashing

  1. Connect serial adapter cable:
    1. 3.3v -> 3.3v
    2. RX -> TX
    3. TX -> RX
    4. GND -> GND
  2. Connect with flashing mode: Press and hold device button (or connect GPIO0 to GND), connect serial adapter to computer, release button after ~1 seconds.
  3. esptool.py -p /dev/cu.usbserial-1410 erase_flash
  4. Disconnect adapter and reconnect again with flashing mode as described in Step 3.
  5. esptool.py -p /dev/cu.usbserial-1410 --baud 115200 write_flash -fs 8m -fm dout -ff 40m 0x0 path/to/fullhaaboot.bin (or 1M instead of 8m for some devices).
  6. Disconnect and reconnect without flashing mode.

Configuration

  1. Connect to device hostpot WiFi (HAA-XXXXX).
  2. Go to http://192.168.4.1 or http://192.168.4.1:4567
  3. Enter your JSON config: {"c":{"l":13,"b":[{"g":0,"t":5}]},"a":[{"0":{"r":[{"g":12}]},"1":{"r":[{"g":12,"v":1}]},"b":[{"g":0}]}]} and click Save.
  4. Wait for several minutes and your device should be ready to be added to HomeKit.

Adding to HomeKit

  1. Click + in Home app, then scan the code 021-82-017.
  2. If you get any errors while adding, try clicking "I don't have a code or cannot scan" and you should see your device in the list.

Based on https://github.com/RavenSystem/esp-homekit-devices/wiki/Installation

@ardasoyer
Copy link

Is this JSON config valid for all sonoff devices or BASIC R4 model?

@Stichoza
Copy link
Author

I've tested it only on Basic R4. Might work on other ones too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment