Smart Window Shades
I picked up this IOT project from R&D. Spencer, our current R&D director, had the hardware (stepper motor, housing for stepper motor, and the stepper motor driver) and asked if someone could do the software by ImagineRIT. I had some ideas for ImagineRIT, but this one seemed more fun than the rest of them. I went into this knowing how to code, specifically in Python, but not having a great understanding of how to incorporate the hardware with the software, including web application integration. I started the project by figuring out how to use RPi.GPIO library by making a simple program with LEDs. Then I started using the stepper motor driver and the stepper motor. This ended up being a hardware problem, not a software one. After countless hours I figured out that I can connect an LED to 2 of the 4 pins of the motor and if the LED lights up upon turning the motor then I have found a pair of wires. From there I had to figure out how stepper motors work in software, which comparatively was not that difficult.
The next part of this project was controlling the motor from a website. I started by reading about Flask and making a quick Hello world application on the IP on the Pi. Since Flask uses python, and so does my code for the shades, I was simply able to combine the two. I learned about HTML and bootstrap while creating the index page for this application.
I now needed a domain that people could type in, because remembering an IP address is only possible when you type it in countless times as the developer. Thankfully, our OpComm director, Steven, helped me out during the OpCommathon by showing me OpenShift. As soon as I ran it up, it crashed. Rpi.GPIO imports can only be run on a Raspberry Pi… I eventually decided to make a second Flask app that would simply run on the CSH domain and link to the IP of the Pi. This, however, was not ideal because every time you changed the height of the shade, the page would reload. That is neither pretty nor efficient. To make the matters worse, the link was to an IP address, and a real world application should not be pointing to an IP address. I asked around, and upon the suggestion of our financial director, Devin, I decided to implement Ajax.
Altogether, this project was a lot of fun. I learned quite a bit, both in the software world and hardware world. ImagineRIT is still weeks from now, and as a result I plan on adding Amazon Alexa Skill to this, or someway of using voice command to perform the same actions.
P.S. For details on wiring components, please visit the GitHub source of this project here.
More blog posts