Skip to content

Native Apple HomeKit via an ESP32 for the NeoPixel LED Strip or any 5V LED Strip

License

Notifications You must be signed in to change notification settings

oleksiikutuzov/esp32-homekit-led-strip

Repository files navigation

esp32-homekit-led-strip

Native Apple HomeKit via an ESP32 for the NeoPixel LED Strip or any 5V LED Strip

Build sketch

Software is based on HomeSpan library. Supports RGB or RGBW Neopixel strips and optionally can act like a switch for any 5V electronics (Switch accessory in HomeKit can be shown as a Bulb, Socket or Fan).

As usual, don't expect any warranties. I am just a hobbyist, not a professional. It works for me, but you take your own risk using it. I am not liable for any damage to your devices.

Hardware

render

Custom PCB is designed for the project. Currently for regular ESP32 board, however there are plans to do for ESP32-C3, which has smaller footprint.

HomeKit functions

Device has three modes, which can be switched via the Eve app. As they are custim characteristics, they are not visible in the Home app:

  • Manual Control (manually set one single color)
  • Rainbow (the whole strip is changing colors)
  • Color Wheel (strip has different colors "running" along)

Also in the Eve app you can set the number of LEDs in your strip (default is 90). After changing this characteristic, you need to restart the controller for changes to take effect.

Characteristics values are saved to NVS, so they will be restored if device looses power.

At the moment you can enable the Switch device in the sketch by defining the RELAY variable, but in the future this will implemented via custom characteristic as well to be able to enable it when device is running.

Software

Here you can see, which pins are used and pre-defined in the firmware:

 *                ESP-WROOM-32 Utilized pins
 *              ╔═════════════════════════════╗
 *              ║┌─┬─┐  ┌──┐  ┌─┐             ║
 *              ║│ | └──┘  └──┘ |             ║
 *              ║│ |            |             ║
 *              ╠═════════════════════════════╣
 *          +++ ║GND                       GND║ +++
 *          +++ ║3.3V                     IO23║ USED_FOR_NOTHING
 *              ║                         IO22║
 *              ║IO36                      IO1║ TX
 *              ║IO39                      IO3║ RX
 *              ║IO34                     IO21║
 *              ║IO35                         ║ NC
 *      RED_LED ║IO32                     IO19║
 *              ║IO33                     IO18║ RELAY
 *              ║IO25                      IO5║
 *              ║IO26                     IO17║ NEOPIXEL
 *              ║IO27                     IO16║
 *              ║IO14                      IO4║
 *              ║IO12                      IO0║ +++, BUTTON
 *              ╚═════════════════════════════╝

The firmware can be built and flashed using the Arduino IDE.

For this, you will need to add ESP32 support to it.

Furthermore, you will also need to install the following libraries using the Library Manager:

  • HomeSpan

And some libraries manually:

  1. Go to this GitHub repo and download it as a ZIP - AsyncElegantOTA
  2. In Arduino IDE select "Sketch" -> "Include Library" and "Add .ZIP Library..." and select downloaded ZIP
  3. Do previous steps to the following libraries:
  4. Download and open this repository in Arduino IDE (or VSCode with Arduino extension)
  5. Set the upload speed to 115200
  6. Build, flash, and you're done

Instead of Arduino IDE OTA, the webserver update was implemented. You can flash binary at http://[DEVICE IP]/update. There is a reboot link. Opening http://[DEVICE IP]/reboot will force the device to reboot.

The device can also be controlled by the FLASH button on the board. More on HomeSpan docs

Connect to HomeKit

  1. Plug your LED Controller to power.
  2. Press the FLASH button until the LED starts blinking rapidly and release it. Now it is in the configuration mode (More on HomeSpan docs). Press it two more times until the LED starts blinking 3 times in a row. This means mode 3 is chosen. Hold the button for 3-4 seconds once again and the WiFi AP will be started.
  3. Go to WiFi settings on your iPhone/iPad and connect to the "HomeSpan-Setup" WiFi network.
  4. You will choose your WiFi network and set the setup code for the accessory.
  5. Go to your Home app and select "Add Accessory"
  6. Select "More Options" and you should see your LED Controller there.

References and sources