Guide: DIY Smart window blinds to Home Assistant

For a long time I’ve been wishing for automatic window blinds for my living room. Those three window blinds are always closed and opened at the same time so it’s “too much work” (yes, laziness is the most common motivation for smart home systems).

However, there’s no affordable ready made solutions in market so why not to do it myself? Basically everything needed is an ESP8266, power supply and a servo. Rest of the components can tinkered and boughr from a local hardware stores.

So, here’s a solution/guide how I made my blinds smart. This specific guide might not work for your blinds since there’s a ton of different blinds with different mechanical parts, so please think and experiment first how to connect your blinds into a servo before buying the materials!

DIY Smart Window Blinds in action

My old stupid blinds and the plan

Before going to the business, I’d like to explain how my old blinds works and how did I end up doing control like this.

First plan was actually to install the servos inside the window, but after measuring dimensions I quickly realised that there’s no way I can fit the servo inside. So plan B was to place it out of the window and use the existing mechanical connector.

First problem of outside installation hit me when I tried to figure out how to actually connect the servo to the existing blinds connector. Luckily the rod diameter is almost the same as inside thread of the servo so I could just create outer threads to the rod and tighten it in place with a nut. A diagram of the plan and blinds connector shown below:

Materials needed

Optional (for easier installation):

Software & flashing:

Tools:

Required parts for smart window blinds

Mechanical parts

This is the most important part and depends a lot of your specific window blinds. In this part, you need to find a way to connect your blinds into your servo. This part is written how I did it on my blinds so maybe you will get the idea.

My blinds are using a common nordic blinds connection system. Basically blinds will turn from closed-open-closed by turning the rod around about 360 degrees. I need the servo to be able to do open to closed so 270 degrees will do the trick. The ‘interface’ coming out from inside the window is having a L-shaped connector and there’s spare parts sold by local hardware store.

Connection rod diameter is about 3.4mm so I can cut it into proper length and create a 3mm/0.5 threads with a threading tool into end of the rod. That rod can then be screwed into the servo, because the servo has also 3mm/0.5 outer threads. Just to make sure that the rod itself won’t rotate, we need also to add 3mm nut into our newly created thread and tighten it into proper position at installation state.

After figuring out how to connect the blinds into servo we can move to the electronics part..

Electronics

For electronics: the brains will be in an ESP8266 device (Wemos D1 mini) that will handle all the servos and report it’s state back to Home Assistant.

Electronics – Servos

This servo is working with Dc4.8-6.8v and will draw about 1A per servo when turning so make sure your power supply has enough power to handle all the servos. I found an old power supply from my closet that has 5V/3.5A output so that should give me enough power for all of my three servos and for my Wemos.

First thing to do is to cut the wires in length. So, measure the distance from your servo place to the designed location of controller and make the cut. Make sure the length is not too long to avoid possible power loss or use thicker wire. My longest cable is about three meters long at at least that did not cause any issues with 0.75mm wire thickness.

Next either solder the wires at servo end directly to the servo (cut the servo plug) or use a female servo connector in another end to be able to replace the servo easier if needed. I would have used the female servo connectors myself, but unfortunately I’ve run out of those components. Red = Vcc, Black = Gnd, White = signal

On the other end of the cable (the controller side): peel all the wires and solder dupont connector on the signal wire.

At this point, you should have your servo with a long enough cable and dupont connector on the signal cable at the other end.

Electronics – ESP8266

ESP8266 part is quite simple: it involves lots of wires (depending how many windows you are controlling), but zero extra components. I decided to use two five slot wire splitter to connect the all ground and all VCC lines. The main power is received from the 3.5mm power socket and forwarded to the splitter. From the splitter VCC and GND is then brought to the Wemos and servos.

The servos should be connected to any free Digital I/O pins (I’m using D5, D6 and D7 for my three servos). You just have to remember to setup selected I/O ports in the software prior to flashing.

Software

Software is written using Arduin and can be downloaded from https://github.com/kotope/blinds2mqtt. The software uses MQTT (as might be guessed from the name) so you’ll have to have MQTT broker installed and MQTT integration with Home Assistant.

I presume that you have basic knowledge of Arduino and flashing software. If not, you can find tons of information from the google. If using Wemos D1 mini, the software can directly be flashed using USB connector and no external flashing hardware is needed for that.

After downloading the software and setting up the Arduino environments, open the blinds2mqtt.h file and configure your own variables:

// wifi settings
const char* ssid     = "****"; // Your WiFi SSID
const char* password = "****"; // Your WiFi password

// Servo pins to use (each servo to be placed on it's own IO pin)
const unsigned int servoPins[] = { D7, D6, D5 };

// mqtt server settings
const char* mqtt_server   = "192.168.1.*"; // Your MQTT server address
const int mqtt_port       = 1883; // Your MQTT server port
const char* mqtt_username = "****"; // Your MQTT user
const char* mqtt_password = "****"; // Your MQTT password

// mqtt client settings
const char* client_id                 = "blinds"; // MQTT Client ID (must be unique to the network)

// Home assistant configuration
const String friendly_name = "Blinds";

Rest of the variables should not be changed if using the same hardware specified in this blog post.

Now you are ready to start flashing so flash it, but NEVER connect external power at the same time. It might burn your USB and/or damage your Wemos.

After flashing is done and the device is powered with your external power supply, you should now be able to see some MQTT messages coming through the MQTT gateway. If not, drop a message on comments section and I’ll try to help as much as I can 🙂

The case

To actually be able to install servos in the wall, I’d recommend to download and print the designed case for it from https://www.thingiverse.com/thing:4946890. You might be able to glue the servos in place or create other kind of case for servos, but the easiest way would be to get the case 3D printed.

Wemos and the connectors could be easily installed in standard electronics cases, but again, 3D printed case would be a better choice. Current version of Wemos case is designed to hold stuff for necessary connectors for three servos and Wemos D1 mini.

Installing into the blinds

Installing the blinds next to the window might take some tweaking and precision depending on your blind types.

First that you should do is verify that your blinds open when turning clockwise. After that, power on the controller and turn the servo on close position using MQTT commands or Home Assistant directly (see section ‘Integration to Home Assistant’). Close the blinds on closed bottom position and take out the existing rod. Put the smart blinds rod inside the servo case, screw the nut to the rod, put your servo roughly in place and connect the end of the rod to the existing blinds connector. Tweak the rod within the servo and when you are happy with the position, tighten the 3mm nut inside using narrow pliers.

You might want to test out that the servo opens and closes properly few times when connected to the blinds. If not, do some more tweaking until you’re happy with the result.

When finished, screw the case on the window frame and start installing the next servo (if needed). 🙂

Integration to Home Assistant

This time I decided to do a bit different implementation compared to Vallox ventilation project. The blinds controller is now using MQTT with Home Assistant auto discovery, so all the configured blinds should now automatically appear in your Home Assistant MQTT integrations page as soon as you power up the controller for the first time.

The blinds controller supports commands close, open and stop. Status information is received as open, closed, opening or closing. That’s it (for now).

Hopefully your installation works and if not, please feel free to drop a comment below and I’ll try to help as much as I can.

Bonus: Group the blinds under one entity

If you are using multiple blinds at the same room like I am, it might be better to group all the blinds together. Grouping is not currently supported through Lovelace UI and need to be done directly from configurations.yaml

Here’s an example of the configuration I’m using:

cover:
  - platform: group
    name: Living Room Blinds
    unique_id: living_room_blinds
    entities:
      - cover.living_room_blinds_1
      - cover.living_room_blinds_2
      - cover.living_room_blinds_3
All the Living Room blinds grouped

16 Replies to “Guide: DIY Smart window blinds to Home Assistant”

  1. Working fine 😉
    My two servos are turning at the same direction, but I need one servo to turn opposite direction. How to do that?

    1. Hi,

      Thanks for the comment!
      Actually reversing servo direction is not supported at the moment (something I did not think of).
      Anyhow, very good feature request. I will try to have time to implement it on Sunday so, if you can wait until Sunday evening then it could be supported 😀

      Of course, if you are familiar with Arduino and coding you might want to implement it yourself. If so, then please make a pull request to my repository and I’ll take it to master branch as well 🙂

    2. Hi again,

      Now it’s possible to reverse the turn direction of servo(s).
      Get the latest codes from github and configure proper values in blinds2mqtt.h file.

      You can change the direction of a servo by adding specific servo pin to reversedPins array in the config file. e.g.:
      const unsigned int reversedPins[] = { D7 }; // Array of reversed servo pins. Must be subset of servoPins.

  2. Hi Toni,

    Excellent guide and code even though I only understand some of it.
    I have a different servo than what you are using but I did manage to get it rotating in both directions.
    I am having some trouble, so hoping you can answer my questions:
    1) The rotation does not stop when I press the stop button in Home Assistant, nothing happens, it keeps rotating.
    2) As soon as I plug the power it starts rotating and only stops when I unplug the power (maybe related to my first question?)

    Your code is the only one I found that actually rotates the servo so thanks for that!

    1. Hi and thanks for the comment!

      Your servo pulse ranges might be wrong. Servos I used were 500-2500 pulse ranges (0-270 degrees).
      If using pulses over the ranges the servo might do ‘anything’ e.g. start rotating wildly.
      You can change servo parameters in blinds2mqtt.h file.

      Can you please share the model of the servo and I can try to tell more specific error for you? 🙂

      Br, Toni

      1. My servo model is MG99R Digi Hi Torque. I will try also to find the correct ranges.

        Thanks so much for helping me out!

      2. I bought the same servo as you are using and got my blinds automated perfectly. Thanks again Toni!

  3. When my servo is idle, it is making a loud repetitive clicking sound like the motor is still running. Any idea what that could be?

    1. Good morning!

      What servo(s) are you using? One guy was using TD-8120MG and had the same kind of issues and had to order new set of servos (same that I’m using DS3218MG).

      1. Hi Toni – I am using single “Miuzei 20KG DS3218 Control Angle 270°” servo. I will see if I can find DS3218MG servo exactly like you have. I though DS3218 would be enough but maybe not?

        1. Hi Paul!

          Checked the specifications of your servo and it ‘should’ be ok. However, the ‘Miuzei 20KG DS3218’ servo from amazon.com seems to have model number of MS24-F and does not have the DS3218MG labeled elsewhere except in the title.
          My guess would be that the servo is somewhat bad and does not lock in a required position after moving (i.e. looking for a proper position endlessly)

          Is the servo working ok otherwise?

          1. One thing you could try to do is to comment out ‘detach();’ from file ‘BlindsServo.cpp’ at line 88.
            That would leave the servo in attached state rather than leave it hang idle.

            Usually this detaching is done to actually stop behaviour like your servos, but it could keep the position locked in and stop the clicking sound.

            Most probably won’t help, but worth of a shot I’d say 🙂

  4. Ok, I will try comment out that line. I did receive a DS3218MG servo but that also has the clicking sound and it does not rotate all the way so I think it might be a defective servo – I have ordered another one but in the meantime I will try your suggestion.

    Thanks again for your help Toni!

Leave a Reply

Your email address will not be published. Required fields are marked *