Skip to content

Posts tagged ‘curtains’

6
Jun

Voice-controlled blinds with Amazon Echo

For Christmas, I bought my Dad an Amazon Echo Dot. Its listening capabilities really impressed me, and it got me thinking about what features it offered to developers. After looking into the Alexa Skills API, and seeing how easy it was to get started, I decided I just had to buy one for myself. But I needed to justify it somehow…

A few weeks ago I decided that manually opening and closing my binds every day was simply too much for me to do anymore. Not only did I have to pull the cord to open the blinds, I also had to position myself next to the blinds in order to reach the cord. It was a significant time waster, consuming an estimated 10 seconds of my life each day just simply opening and closing blinds. I did some important calculations and discovered that if I spent 10 seconds a day on the frankly old-fashioned task of opening the blinds myself, I’d be wasting 70 seconds a week. That adds up to approximately 4.6 minutes a month. Which is a whopping hour every year, or 0.0001% of my life. If I live to 90, I’d have spent nearly 80 hours of my life opening and closing blinds, assuming I was opening and closing blinds from the age of 10. Obviously, the only sane thing to do was invest nearly half that into developing some kind of blinds control system. I wouldn’t rest until I’d solved this vitally important problem. The only breaks I took were to open or close my blinds.

Here’s a diagram of the system I designed:
Process overview

Front End

Not strictly speaking a “front end” in the typical sense, but for the purposes of describing the system it makes sense to treat all the “Amazon” stuff as the front end, because there’s not really any development required here. Amazon really shines here by making this step easy to get the hang of. I encourage you to read the documentation, but simply put you create an Alexa Skill and link it to trigger an AWS Lambda function. The general idea here is to use the Alexa Skills Kit portal to configure how you want to interact with Alexa – the key aspects being the “invocation name” (can be thought of as the app name) and the “interaction model” (which is essentially a mapping between what users say to your app and what methods are called on the AWS Lambda function. Easy! (Note, for non-US users, make sure you match the language of the skill to the language you configured for your Echo, otherwise the skill wont show up on your device!)

Relay

This encompasses the AWS Lambda function and my own “relay” server. Quite simple really, the Lambda function just makes a HTTP POST to my relay server. The relay server, you guessed it, relays the request to the Raspberry Pi, where the real magic happens.

Physical Output

By far the hardest part of this project was interfacing between the blinds chain and the motor. Fortunately, I found someone had made a 3D model of a gear which interfaces with my blinds perfectly:

Bead chain gear

https://www.thingiverse.com/thing:467647

I had it printed out by a small 3D printing shop here in London, and after a small modification we were in business. I then had to somehow suspend a motor in the correct place to interface with the gear. Easier said than done, since I didn’t want to drill into any walls. I came up with a frankly hideous solution involving a weight, a wooden plank, 2 clamps and a piece of string. It’s so specific to my situation it’s not even worth talking about, but you can just about see it in the video at the top.

The rest was more or less straightforward. I realised the blinds were a lot heavier than I thought when a stepper motor failed to provide enough torque to pull them up, so I went a bit overkill:

That sends the blinds up and down with ease, though it’s a little bit loud…

The final bit of hardware: something to know where the blinds were. Originally, I was going to put a magnet on the gear and have a reed switch detect how many revolutions the motor made. I’d then calculate the revolutions needed to open and close the blinds, which would allow me to open the blinds halfway. This required a lot more effort to mount the magnet and the reed switch precisely, so I opted for a simpler solution: a simple lever switch mounted at the base. When the binds make contact with the switch, we know we’re at the bottom of the run. I could then time how long it took to open the blinds, and be more or less confident in it’s accuracy, since it would be operating from the exact same point each time, guaranteed by contacting the switch at the bottom. Note: doing away with any kind of feedback loop would be a disaster. If you just timed the up/down travel time, you’d introduce inaccuracies (since the travel time down was not equal to the travel time up). Over the course of opening and closing the blinds a few times, unless you somehow timed with absolute precision and accuracy and there was absolutely no fluctuation in the time taken, you’d quickly find the blinds lose their “home” position and start drifting out of their operating range.

With that sorted, all that was left was the software. I wrote a simple script in Python to control the motor. The control script took the responsibility of knowing where the binds were, so if I asked them to open once then open again, the control script would refuse to open the blinds (actually it was even more simple – if the switch wasn’t currently pressed, the control script would assume the blinds were open and would only close).

That’s it! The code isn’t anything special, so it’s not worth posting. Please ask if you have any questions though!

0+
Fork me on GitHub