A system to automatically open the curtains when my cell phone alarm goes off
![] (https://github.com/jerwil/Automated_Curtains/raw/master/Media/Opening_GIF.gif)
##Features
- Uses inexpensive off-the-shelf parts to open curtain
- Seamlessly works with alarm app I already use
- Automatically retracts cord to allow curtains to be closed
##Architecture
![] (https://github.com/jerwil/Automated_Curtains/raw/master/Media/Comms%20Flowchart.png)
My alarm clock app, Sleep as Android, has the ability to interface with IFTTT. This is an awesome system that takes care of API calls for you and talks to hundreds of different services.
Sleep as Android >>> Adafruit IO
When the alarm goes off, Sleep as Android sends "alarm_alert_start" to a Maker channel feed. Using the Sleep as Android documentation, I created an IFTTT recipe that looks for this message, and writes a "1" to an Adafruit IO feed. When the alarm is disabled, "alarm_alert_dismiss" is sent, and a "0" is written to the data feed.
Adafruit IO >>> ESP8266
On the hardware side, I have an ESP8266 checking the Adafruit IO feed. I followed the basics of the Adafruit guide to get set up. When the feed returns a "1" the alarm is sounding, and the ESP8266 then lets the Arduino know it's time to open the curtain.
ESP8266 >>> Arduino
The connection between the ESP8266 and Arduino is very basic, just an on/off digital signal. When it's time to open the curtain, the ESP8266 writes a HIGH value on the digital line connecting the two microcontrollers.
Arduino Code
When the digital input is HIGH, the Arduino operates the servo to open the curtain, pauses, and then retracts the cord so that the curtain can be closed in the evening. The Arduino also has two buttons attached to it that allow the servo to be manually moved in either direction. These buttons also interrupt the automated open/close operation in case anything unexpected occurs.
The Arduino code also has a timeout (2 hours for now) during which no other alarm events will trigger the curtain opening. This avoids snoozing triggering the curtain multiple times in one morning.
![] (https://github.com/jerwil/Automated_Curtains/raw/master/Media/Breadboard%20Labeled.jpg)
See the included Fritzing diagram (.fzz file) for details. Thanks to ydonnelly for the ESP8266 Fritzing part!
![] (https://github.com/jerwil/Automated_Curtains/raw/master/Media/Breadboad.jpg)
![] (https://github.com/jerwil/Automated_Curtains/raw/master/Media/Servo%20Mounted.jpg)
The servo is mounted on the curtain rod, and has an old plastic wheel as a spool. As the servo turns, the spool reels in the string. The string is attached to the end of the curtain, so as it is pulled onto the spool, the curtain is dragged open.
![] (https://github.com/jerwil/Automated_Curtains/raw/master/Media/Progress%20Photos/Servo%20Washers.jpg)
The string has a bunch of washers along it such that there is tension when it unspools. The software will automatically unspool the string a few seconds after the curtain is dragged in so that the curtain can be later closed.
Automated Curtains by Jeremy Wilson is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.