One random weekend morning I went to open the blinds so I can see my wonderful backyard. I thought to myself, wouldn’t it be awesome to just wave my hand and the blinds would just open. Much like some scenes in fantasy movies where wizards use magic to control the lighting in a room. Then when it’s time to close the blinds just wave my hand again.
How to
Before trying to build this yourself, you must make sure the space for the equipment is feasible.First thing was to measure the room inside the blind’s mechanical housing. The goal is to fit everything inside without modification. When looking at potential motors and gears write down the dimensions and make cardboard cutouts. Use the cutouts to help visualize if the pieces would work.Now take out the shutter gearbox control and ensure you can mount a gear on the shutter rod. Measure the rod width to determine the size of gear center shaft size required.I found a stepper motor and control board compatible with raspberry pi listed on Amazon. There wasn’t any documentation provided on how to wire it. Using google superpowers I found guides for setting it up with sample code. Below is the wiring diagram for it.
Download the script for stepper motor control. “steppertest.py”Adjust the script to use 4 step instead of 8 if using the same motor. Run the script (Use 5 ms and 50 steps) and watch the motor spin.Write down the IP address of the Raspberry Pi. You can type ifconfig and get it there. This will be used in the next section for machine learning script.
Next few steps are for setting up hand gesture recognition on the computerFor this portion of the guide I will use Anaconda. This is a great platform for machine learning and easy to share my work to you using predefined environments. Please go to their website and follow the setup guide to get your environment ready.Once you have Anaconda setup we will start by creating a new environment using my template.Download my template from github "blinds.txt" then launch Anaconda command prompt.Type conda env create --file blinds.txtOnce the environment successfully builds, download and copy my code to your preferred location.Activate the anaconda environment.Conda activate blindsOpen the “blindgesture.py” for editing. Change the IP address to the IP address of the Raspberry Pi.
Test the script
Python blindgesture.pyOn the Raspberry pi install dependenciessudo apt-get install -y mosquitto mosquitto-clientspip install paho-mqttYou will see a window popup using the camera from your laptop. With your hands raises slowly move from left to right to open the blinds. If successful you will see the motor start moving. Now move your hands right to left. The motor will now spin the opposite direction.
Now stop the script.
Manual laborNow that the system works, lets build a frame to support the motor. This part is highly custom so I will not go into details of how I did it, but here are some wonderful pictures of my work.
With the motor mounted and fitted with the gear it is now time to test and adjust travel distance.Open blindpi.py and adjust the stepper increment. I started by incrementing 100 steps at a time. Once I started to feel comfortable with the setup and nothing seems to be breaking, I increased the steps faster until my travel of my blinds goes from open to close.Now run the script in Anaconda again and try controlling the blinds to open and close!My build was super slow, but it works.
Comments