ESP8266 – HomeKit Blinds

I have been working on my HomeKit projects for quite some time now, but this project has given me some restless nights. I’m talking about the HomeKit blinds. in the past I have tried several times to solve practical as well as code related problems. But now I have a working solution. But lets start at the beginning.

HomeKit blinds

The HomeKit blinks aka Windows Covering System comes in different variations. This means that wen you install your Windows Covering System you can choose between these variations.

  • Roller Blinds
  • Venetian Blinds
  • Curtains
  • Roman Blinds
  • Slats
  • Pleated curtain
  • Outside Blinds

Al these Variations have one thing in common and that is they need a motor to move up and down or to open and close.

Electric blinds

Electric blinds (with good light blocking and light-filtering qualities) you can program, they’ll wake you up gently and provide undisturbed sleep. Control the blinds with the attached remote control¹ or use the HomeKit app. Healthy sleep is one of the best ways to contribute to a healthy lifestyle.

With the Windows Covering System, you can control the light from your bed, or somewhere else! Thanks to the included remote control or the HomeKit app, several wireless blinds can be controlled at the same time or individually. It’s convenient and great for all generations. Choose what sort of blind you need. You can choose for a blind that blocks out the light, Or a blind that filters some light through. Let them help you get just the right amount of light and set the best conditions for a good night’s sleep, or gentle waking up!

¹ this feature will be added in the future.

Block out the light and sleep better

With block-out blinds or curtains, you can make sure your much-needed sleep isn’t disturbed by moonlight or street lights, and that you can enjoy a lie-in without the sun waking you up. So let’s start building!


As I already said, this is a project that I’m working on for a long time now. First I tried a to intergrade a 28BYJ-48 5V to see if this would work. This was no success, so I tried a 28BYJ-48 12V. This also didn’t work as it should. Then for a long time I thought of using a stepper motor (eg. Nema 17). Then came the hard part controlling the stepper, there is no Library available for ESP Open RToS. No one has ever tried it, at least in C code. In C++ ( Arduino ) there where some examples available, but they used standard libraries.


To control the stepper I used a DRV8825 Stepper Motor Driver. I used this Stepper motor driver because I had this on lying around, you can also use a A4988 Stepper Motor Driver. This breakout board for Texas instruments DRV8825 micro-stepping bipolar stepper motor driver features adjustable current limiting, over-current and over-temperature protection, and six micro-step resolutions (down to 1/32-step). It operates from 8.2 V to 45 V and can deliver up to approximately 1.5 A per phase without a heat sink or forced air flow (rated for up to 2.2 A per coil with sufficient additional cooling).

The driver has a pin-out and interface that are nearly identical to those of our A4988 stepper motor driver carriers, so it can be used as a higher-performance drop-in replacement for those boards in many applications.

Stepper Motor

At first I used a Nema 17 motor, only for test purpose because it a little bit bulky. This motor Is strong enough to pull the blinds, but it has one downside. When there is no power on the spools the axis of the motor can spin freely. This means that the blind comes bashing down, after it pulled it up all the way.
So I tried using a PM42S-48, this little stepper has quite a punch. But also the same problem as the Nema 17 Motor when there is no power on the spools.

Meanwhile I had figured out how to control the stepper in ESP Open RToS. Then I thought of having a second look at the 28BYJ-48 12V stepper motor. It turned out that it’s quite simple.

Now this kind of motor is not really up-to-date with modern technology. Uni-polar stepper motors are not that common anymore. Bipolar steppers are twice as efficient with the same amount of copper on the internal windings. Even in full stepping mode, a uni-polar stepper still has 2 out of four wires not active all the time. So basically, if there was a way to run current through all windings in the motor at all times, the thing would be stronger and faster. That’s what happens in a bipolar stepper motor. It has only two windings instead of four in a uni-polar stepper. Both windings can be activated all the time, but their polarity is switched in four steps.

Blinds Scheme

As you can see this scheme is a little bit more complex than the average  HomeKit setup. I used a Node MCU V3 Lua ESP-12E WiFi Development Board in this setup, in combination with a DRV8825 Stepper driver module.

Software Preparation

We have to install on our Mac in order to be able to flash our ESP module. To work with, you’ll need either Python 2.7, Python 3.9.1 or a newer Python installation on your system. We recommend using the latest Python version, so go to Python’s website and install it in your computer.

With Python installed, open a Terminal window and install the latest stable release with pip:

pip install esptool

Note: with some Python installations that command may not work and you’ll receive an error. If that’s the case, try to install with:

pip3 install esptool


python -m pip install esptool


pip2 install esptool

After installing, you will have installed into the default Python executables directory and you should be able to run it with the command In your Terminal window, run the following command:

With installed in your computer, you can easily flash your ESP32 or ESP8266 boards with the firmware.

ESP OS Preparation

To run our ESP HomeKit device we need to install Life Cycle Manager2 And ESP Open RToS.

Life Cycle Manager2 

Initial install, WiFi settings and over the air firmware upgrades for any ESP-Open-RToS repository on GitHub.


A community developed open source FreeRTOS-based framework for ESP8266 WiFi-enabled microcontrollers. Intended for use in both commercial and open source projects.Originally based on, but substantially different from, the Espressif IOT RTOS SDK.

Bin Files

At first you need to download three bin files otaboot.bin, rboot.bin and blank_config.bin. The OTAboot.bin contains the Life Cycle Manager2 part. The rboot.bin contains the bootloader for the ESP8266. The blank_config.bin in just a blank config file. Now connect your device to your FTDI adapter in flash-mode.

LifeCycle Manager 2
Version: 2.1.2

Boot loader
Version: 1.4.2

Version: 1.4.2

utting Device Into Flash Mode

To enable ESP8266 firmware flashing GPIO0 pin must be pulled low before the device is reset. Conversely, for a normal boot, GPIO0 must be pulled high or floating. If you have a Node MCU V3 Lua ESP-12E WiFi Development Board, as in this setup, then you don’t need to do anything, as the USB connection can pull GPIO0 low by asserting DTR and reset your board by asserting RTS. If you have an ESP-01 or other device without built-in USB, you will need to enable flashing yourself by pulling GPIO0 low or pressing a “flash” switch, while powering up or resetting the module. for more information looks here.

Go to the directory you made where you put the previously downloaded Root.bin, Blank_config.bin and Otaboot.bin files (e.g Downloads)

Open the Terminal app. Click the Finder icon in your dock. Click Go. Click Utilities. Double-click Terminal. Change to the downloads directory.

cd downloads

Use to flash it in your device. First, erase flash: erase_flash

Normally, your ESPPort will be something like /dev/cu.usbserial-A50285BI. Then, set your device in flash-mode again, and flash the new firmware: -p /dev/cu.usbserial-A50285BI --baud 115200 write_flash -fs 1MB -fm dout -ff 40m 0x0 rboot.bin 0x1000 blank_config.bin 0x2000 otaboot.bin

Note: Size of the SPI flash, given in megabytes. Valid values vary by chip type:

Chip flash_size values
ESP32 detect, 1MB, 2MB, 4MB, 8MB, 16MB
ESP8266 detect, 256KB, 512KB, 1MB, 2MB, 4MB, 2MB-c1, 4MB-c1, 8MB, 16MB

You must configure wifi network and OTA repository. To configure wifi settings, device generates its own Wifi in AP mode. You must connect to it in order to setup your wifi network. Simply take your iOS device, go to Setting -> Wi-Fi, and search a SSIDwith LCM- followed of last MAC address, connect to it, and wait a few seconds until a web appears showing you all wifi networks that the device has found. Select yours, and enter password. Don’t touch Join button yet!!

Software Installation

Now, you must configure OTA repository as well. It’s very important that you configure it right, because you can not change it in the future (If you make a mistake, you must erase and flash device again).

OTA repository:


OTA binary file:


To finish initial setup, click Join button and wait about 7 minutes until process finish (While installation is working, device doesn’t show anything, and buttons don’t work). After that, LED turns on for a couple of seconds and you will be able to add your accessory to your HomeKit ecosystem using Home App. LCM will install your HomeKit device on your ESP.

Now you can add your HomeKit Outlet by scanning the QR code below. To make the connection between your ESP and HomeKit takes a few seconds.

Testing the HomeKit Blinds

3D models for Blinds

Although I going to redesign the 3th model for the housing of my HomeKit blinds, I want to share the models I made so far with you. With these models you can test your setup.

The first model is for a PM42S-48 Stepper motor.

The second model is for  the 28BYJ-48 stepper motor, and is recommended.

Blinds Extra Feature

There is a extra feature build into the Code. As I was writing the code something hit me, I need some kind of calibration. How does HomeKit know where to stat and stop. So how do you calibrate your blinds.

  • Hold the Up button for 4 seconds until the LED Blinks.
  • Use the HomeKit app to move the blinds to the desired position.
  • When you have the desired position, press the Down button 3 times Fast.
  • The LED Blinks and the ESP module will Restart.
  • The calibration is complete.


Note: To produce and sell HomeKit compatible accessories, your company need to be certified for that (, If you’re interested in developing or manufacturing a HomeKit accessory that will be distributed or sold, your company must enroll in the MFi Program.) Espressif have their implementation of HomeKit framework, but it will give you it only if you have MFi certification (notice this text at the bottom of page you mentioned: Please note that the Espressif HomeKit SDK is available to MFi licensees only, and you need to provide the Account Number for verification purposes when requesting the SDK.).This project is a non-commercial implementation of HAP protocol, not meant for commercial use.


Maxim Kulkin, esp-wifi-config (2019), Library to bootstrap WiFi-enabled accessories WiFi config, Paul Sokolovsky, esp-open-sdk (2019), Free and open (as much as possible) integrated SDK for ESP8266/ESP8285 chips, Espressif Systems, esptool (2019), ESP8266 and ESP32 serial bootloader utility, HomeACcessoryKid, life-cycle-manager (2019), Initial install, WiFi settings and over the air firmware upgrades for any esp-open-rtos repository on GitHub,

Scroll to Top