Introduction: Motorized WiFi IKEA Roller Blind
I confess. I have been sucked in to a home automation addiction. The next thing on my radar was to automate roller blinds. There are commercial products available but the ones I found are surprisingly expensive (about 80 - 90 USD). Since I need a bunch, it was hard to motivate the purchase (and less fun). I decided to design my own.
If you like this Instructable, please vote for it in the Microcontroller contest (press Vote above)!
These were my requirements:
- WiFi capable
- MQTT control (0% - 100%)
- Manual push button operation
- Use low cost standard electronic components and 3D-printable parts
- Persist state on power off
This instructable is a followup to https://www.instructables.com/id/Motorize-IoT-With...
Step 1: Bill of Materials
- NodeMCU 1.0 (aka V2) development board: http://www.gearbest.com/transmitters-receivers-mo...
- Motor shield: http://www.gearbest.com/boards-shields/pp_340732....
- Geared stepper motor 28BYJ-48: http://www.gearbest.com/other-accessories/pp_2311...
- Micro switch: http://www.gearbest.com/development-boards/pp_156.... Please note that if you want to use the printed electronics box you need to get these exact switches or same dimension ones. The lid has a socket modeled after this particular switch.
- M3x8 hex socket allen screws
- MicroUSB-cable for power and programming and any USB phone charger
- 3D printer (or printing service)
- M3 knurled brass inserts M3x5x4: http://www.ebay.com/itm/252468136038
- IKEA roller shade Tupplur (or any roller shade with compatible inner radius): http://www.ikea.com/us/en/catalog/products/603091...
- Some wires, soldering equipment and basic skills
The motor parts add up to about 15-20 USD per unit. The shade itself is 19 USD.
Step 2: Wiring
- Wire the motor to the shield as seen in the pictures. Take note of the colors.
- Solder cables to the micro switch as seen in the picture. If you can, use red, black and white as in the picture.
- Attach the button wires to (GPIO) 5 as seen in the picture
Step 3: Set Up a MQTT Broker
MQTT is a lightweight publish/subscribe protocol suitable for small IoT devices. The devices interact with a message broker which manages the distribution of messages. You can either use a local mqtt broker, e. g. Mosquitto inside your own network or connect to a cloud MQTT broker. Which option is best? It depends on your needs. If you want to be able to connect to the broker from anywhere you may prefer the cloud option. If you prefer to keep your IoT within you network you should use a local broker.
Setting up a cloud broker:
- Register at CludMQTT: https://www.cloudmqtt.com/
- Creat a new broker instance
- Click the instance info and keep the info handy
- For testing purposes, download MQTT.fx: http://mqttfx.jfx4ee.org/
- Add a profile to MQTT.fx with the credentials from your newly created cloud broker.
- Connect. If it works you have successfully tested the connection to your fresh cloud broker.
Step 4: The Software
The ESP8266 on which the NodeMCU development board is a single chip computer with I/O capabilities and WiFi. The chip can be programmed in various ways. The two most popular options are the Arduino IDE and the Lua interpreter. For this project I chose Lua out of convenience. Some of the features in the software are easier in Lua because of the built in file system.
Flash the Lua Firmware
Even if your NodeMCU is pre-flashed with a Lua firmware I recommend that you re-flash it with a new firmware. That way you get a fresh version and can slim the binary to only contain the needed modules.
- Cook a LUA firmware here: https://nodemcu-build.com/ Select the following modules: file, GPIO, MQTT, net, node, PWM, timer, WiFi and optionally enable SSL
- Wait for the email with the firmware download link, then download. It should only take a few minutes. You may want to check your spam filter for it. That's where mine was.
- Download Flash tool: https://github.com/marcelstoer/nodemcu-pyflasher/...
- Flash the firmware using the flash tool
- Run the tool
- Connect the NodeMCU holding the flash button
- Select the serial port
- Select the firmware file
- Press Flash
Install the rollerblind code
- Download the roller blind code here: https://bitbucket.org/ehsmaes/motor_rollerblind/s...
- Download ESPlorer IDE: https://esp8266.ru/esplorer/
- Open Esplorer
- Select the serial port
- Connect
- Open all the lua files
- Edit settings.lua and enter WiFi and MQTT settings
- Upload all lua files (Save to ESP)
- Reset device
Step 5: Dry Run
Now would be a good time to check the software and wiring.
- Open up esplorer and connect
- Run the following command line (see picture). The motor should rotate 1000 steps (about a quarter of a turn.
Step 6: 3D Printed Parts
I designed the parts in Fusion 360.
Download the parts from http://www.thingiverse.com/thing:2065722 and start printing!
Step 7: Assembly
This is what you need to do for assembly (watch video):
- Heat the soldering iron to about 200 degrees C (400 F).
- Embed the nut inserts into the plastics by placing the insert over the tip (so it heats up) and gently push it into the plastic sockets (see picture).
- Remove the lever from the micro switch
- Loosen the plastic hinge on the lid button (gently push it out and back in)
- Push the micro switch in place
- Push the motor shield into place
- Insert the motor
- Screw the plastic parts
Important note on power: I have found that if you have a narrow window or short travel distance you are fine with just USB power (5v) but for wider and longer blinds you need external power (max 9v DC). You attach external power to the motor shield. Make sure you disconnect USB before you do or you are likely to fry something.
Step 8: Mount Rollerblind
Replace the springloaded end mount and insert of the Ikea rollerblind with the printed motor mount and printed insert.
Step 9: Calibration
Windows are of different heights; hence the gadget has to be calibrated. This is how:
- Long press the button (> 2s)
- The shade starts going down
- When the shade reaches desired bottom position, short press
- When the shade reaches derired top position, short press again
- Done!
Step 10: MQTT Control
- Download MQTT.fx from here: http://mqttfx.jfx4ee.org/index.php/download
- Start MQTT.fx
- Create a profile to match the broker you already set up
- Connect
- Subscribe to the topic from config.lua e. g. "/house/masterbedroom/#" wihtout the quotes. If you don't have anything else on your broker bus you can subscribe to everything (e. g. "#")
- You should see heartbeat messages sent out from the device every two minutes
- To control the device, publish to the topic matching config.lua "/house/masterbedroom/rollerblind/0/set"
Of course, this setup is obviously not terribly useful for daily operation but it will help you weed out any potential problems. If you just want to control mqtt devices you can download a MQTT cotrol dashboard on you phone. If you want to use other general home automation software I think you should find that most support MQTT integration.
Step 11: Integration With Openhab (optional)
I will give you an example of integration with the home automation solution I am using. If you have a pre-installed openhab home automation solution or would like to set one up (there are guides on their home page), this is what you should do to integrate the roller blind.
- Install and configure the openhab according to their instructions
- Install MQTT binding
- Configure MQTT binding for your previously configured broker (local or cloud)
- Add the roller blind to your items and sitemap file. See example below.
Item:
Dimmer masterbedr_blind1 "Rullgardin 1" <rollershutter> { mqtt=">[ohab:/house/masterbedroom/rollerblind/0/set:command:*:${command}],<[ohab:/house/masterbedroom/rollerblind/0/status:state:default]" }
Sitemap:
Slider item=masterbedr_blind1

Runner Up in the
Microcontroller Contest 2017
148 Discussions
3 years ago
I have an issue, when the blind goes down, the lights on my stepper driver stay lit. I do not think the power to the coils is being turned off.
When the blind goes up, the lights turn off at the end and the power to the coils stop.
Why would the power to the coils stay on when the blind goes down? I have looked at the code and cannot see any reason why.
In the morning when the motor should open the blind it fails due to being really hot.
Reply 3 years ago
In the original code I left one pin active when the blind is down. The reason was that I was having problems with gravity pulling the blind down further than I wanted if there was no power. In retrospect, keeping it powered was not the best solution. I belive I changed the code in the repo a while back so that it turns all pins off but I'm not sure. There are (at least) two much better ways to fix the gravity problem. 1) cut the blind (at the top) so that when it is down it is all the way out. 2) modify and use the original spring to counteract gravity. This was suggested by another reader. Remove the spring lock and put the spring on the opposite side from the motor.
4 months ago
Hey, did anyone already work on controlling multiple blinds with one esp? i have 4 big windows in a row and think i will have to use an arduino instead esp.
Question 4 months ago
How well does this integrate with Alexa?
Can this be configured in OpenHAB to have different states? Looking to schedule a blind opening and closing at sunrise/sunset.
5 months ago
Anyone have any idea which alternative IKEA roller blinds use this same mechanism? I bought the parts and most of them are here only to see that TUPPLUR is not on the website anymore... (I was waiting for them to get stock again).
Question 5 months ago on Step 1
Awesome write-up :)
Looking to get the parts now and give it a go since I have these blinds already installed.
Any idea if this type of switch will work ok https://www.ebay.ie/itm/Micro-Switch-KW11-3Z-2-5A-125-250V-SPDT-3pin-1-2-5-10pcs/264125944347?hash=item3d7f22121b:g:RjMAAOSwzhFcNdpp
The difference is that is 5A vs 0.5A on the one you have linked but I don't want to wait for China delivery in 2 months so need to find something closer
5 months ago
Pay attention to the presence of the jumper. Delivery goes without it.
If you do not use it, power will not go to the motor and must be supplied separately. This is necessary when you use a power supply for the motor greater than 9v, so as not to spoil the board
8 months ago
Hello everybody,
First of all, thank you to ehsmaes for this nice project. I'm relatively new to this world, and I have two questions:
- I would like to do this project, but since I have an IR-FR (broadlink rm pro) controller, I would like to send the order to the controller by this method. Can you recommend me some alternative to this development board but without wifi?I would like to do it this way because I imagine the power consumption will be lower, and use the other device.
- My blinder model is 2 meters long, and I don't know if this small motor will be able to do the job. Do you think the 12V version will be enough or should I choose another type, like a NEMA 17?.
Thank you in advance for your help.
Reply 5 months ago
Hello,
I tried 1.8 meters, made of polyester. The motor is missing. Tried 5v and 12v. Both in full step and half step mode.
Reply 7 months ago
Curious about this as well
Question 6 months ago
Hello,
I have tried to finish this project, i used Svenn github code and Lua version 1.54. Everything seems to work fine, however when I try to send step_move command, my motor just vibrates instead of moving.
Wiring is connected the same way as on the pictures above. I am using USB cable connected to PC and ESP8266 to power up the setup.
Some advice to fix this?
Answer 5 months ago
Hello,
The first is the wrong motor connection. I also encountered this when I cut the board inside the motor. I tried to make it more powerful, turn it into a bipolar one.
In the code, Svenn prescribed what connects where. Check
stepper_pins = {1,3,2,4} -- (A-)blue, (A+)pink, (B-)yellow, (B+)orange
7 months ago
I managed to get my motor spinning. Im though very uncertain that that small motor will be able to pull my 180cm curtain.. Will try tomorrow. Struggled a lot with the firmware and the fix for me was to use the 1.5 version of lua and not version 2.0
Tip 1 year ago on Step 11
I had sucess with this project, but I struggled big time. Follow this guide, but
1. Use ssvens files
2.Connect a 5 volt external power supply to the sheild.
3.When you make a lua firmware chose the older one 1.50
if you do this you should be good to go
Reply 1 year ago
What did you use for the external 5v power supply to the shield? I've done red to gnd and the motor is still not turning
Reply 1 year ago
I am having the same problem, no motor movement. Did you solve this?
Reply 1 year ago
No not yet
Reply 8 months ago
anyone?
Question 2 years ago on Step 7
Do you have any instructions for hooking up an external power supply on the motor shield? My blinds are quite long and so the motor seems to have not enough power to get the blind back up.
Thanks!
Answer 1 year ago
Did you find any solutions or guides on this? Because I will be having the same problem