Close

Inexpensive DIY Smart Shades

A project log for How to DIY inexpensive smart shades

Inexpensive DIY Smart Shades materials and steps

mark-liuMark Liu 02/17/2022 at 08:400 Comments

Step 1: Connect the Driver to the Microcontroller

This driver has 3 pins that need to be connected to your microcontroller: The DIR input on the driver connects to GPIO4, which is marked as D2 on the node-mcu, The PUL input on the driver connects to GPIO 0 marked as D3 on the node-mcu, the ENA input connects to GPIO13 which is D7, and the OPTO pin needs to be powered by 5V to power the optoisolator LEDS. You’ll also need to make sure that your board and your driver share a common ground.


Since a stepper motor needs to have a relatively large current pulsed rapidly, you’ll also need a stepper motor driver to handle the heavy lifting. I used the DM320T driver from StepperOnline because it can provide controlled current levels at fairly high voltage.


For a microcontroller I used an ESP8266 based node-mcu because I’m very comfortable with them. But any ESP8266 based micro controller would work.

Step 2: Connect the 4 Wires of the Stepper Motor to the Driver

Next you’ll attach the 4 wires of your stepper motor to the driver. The black wire connects to A positive, Green to A negative, Red to B positive and Blue to B negative and attach your 12V power supply to Vdc and Ground. 


Lets talk briefly about the important differences between a stepper motor and a normal DC motor. When you apply current to a DC motor it spins in one direction, raise the voltage and it spins faster, flip the polarity and it spins in the opposite direction. Those are all useful things, but one thing you can’t do with a DC motor is move it to a specific location and lock it in that location. That’s where a stepper motor shines. A stepper motor uses 4 wires instead of 2. Applying current to two of those wires will advance the motor exactly 1 step. If I want it to go the next step I’ll need apply current to the other two wires. The motor we selected has a step angle of .35 degrees, which means every step rotates the shaft by only .35 degrees. This is really useful information when we consider that this will allow us to know the exact amount that our shades have been rolled down at any given time. For this specific case we know that we’ll need to do 1028 steps in order to move 360 degrees without using microstepping.


The decision to use a planetary gears is just as important as the decision to use a stepper motor. Planetary gears allow us to amplify the torque of the stepper motor by a factor of 5 in this case, and that’s important because it means that a less torquey stepper motor will still be able to supply the needed rotational force to roll the shades up and down, but the other reason it is important is that it also makes it 5 times more difficult for the weight of the shades to rotate the shaft of the stepper which will prevent slippage between steps. 

Step 3: Set the Driver Switch and Test

Before we plug it in, lets double check that our dip switches are in the right place. Our stepper motor is rated for 1.68 amps, so we’re going to set the current limiting driver to 1.34 amps RMS just to make sure we don’t overload our motor. We also want to set the resolution to 800 pulses per revolution.
This means our dip switch setup is going to on off off, and off on on.


To test it I’d recommend turning the shaft of the motor manually before you plug it in to line it up with one of the screws we want to make sure that our motor moves in full rotations, so send your motor a command to move 13 full rotations and if it rotates 13 times and ends up in roughly the same position that it started you’re ready to install.

Step 4: Install the Curtain

Mount the brackets loosely on either side of the shade and slide the mounting hub onto the stepper motor shaft. Once everything is in place, slide the brackets closer together to make everything fit nicely, and tighten the mounting bracket screws.


If everything went according to plan you’re done and you should be able to control your shades via MQTT! Test it out by sending different values to the shades.


Let’s talk briefly about the code. My code is fairly simple and utilizes the AH_easydriver library for stepper motors. The code is based off the fact that these shades will go from completely rolled to completely unrolled in 13 full rotations. Because I’m using a stepper motor I’ll be able to precisely control the number of rotations by sending a specific number of steps.


The great part about this code is it won’t get confused if you send it a new value before the old one has finished processing. If you find that your shades are rolling up the wrong way, you can just reverse the + and – wires for each of the A and B motor pairs on your driver and the motor will spin in the opposite direction.


And there you have it, a motorized shade for your smart home at a fraction of the cost of one of the major brands. 

Discussions