Raspi and internet-controlled blinds

There has been a recent surge in the availability of Arduino and other inexpensive microcontrollers great for tinkering with. About a year ago, I started playing around with a Raspberry Pi board.  At first I was going to use a Raspbmc distro to run a networked media player using an old laptop LCD screen, but ultimately I decided it would be better used solving a certain problem I’ve been experiencing.

I have these great cordless cellular shades that basically black out the living room when drawn completely closed.  At least, they were great until the mechanism inside that makes them ‘cordless’ stopped working.

It’s still easy to draw them open, but it takes a frustrating amount of time and effort to close/retract them.  You have to jiggle and coax these shades, rapidly pressing and releasing the button that controls cord mechanism inside the frame to get the cord to re-spool.

I took them apart and examined the mechanism without destroying it.  I found that you can simply cut the cord that attaches the internal spool to the plastic slider, tie your own cord to the slider, and control the new cord’s spool with a stepper motor.

blinds open

Blinds – open. Note the position of the white plastic slider (top right).

blinds closed 1

Blinds – closed. Note the white plastic slider has moved to the top left.

blinds closed 2

Blinds – detailed view. I’ve attached a length of black upholstery thread to the white plastic slider and wound it around a spool of thread as a mock-up of the stepper motor spool.

To safely control the stepper motor with Raspi, you need a motor driver board that acts as a sort of relay for Raspi’s low voltage GPIO (multipurpose) pins.  The Easy Driver board provides this function at a nice price.

SONY DSC

Overall wiring diagram, stepper motor pinout, and Raspi GPIO pinout for WiringPi.

SONY DSC

Putting it all together.

motor detail

Stepper motor hardware detail: NEMA 17 stepper motor with stamped L-bracket, Acrobotics 6 mm set screw hub, Acrobotics 1″ smooth pulley

 SONY DSC

Stepper motor installed and connected to blind slider

On the software side, you have to image the SD card with a Raspi distro, install and configure WiringPi to drive the GPIO pins, and install Nginx and PHP and setup a local webserver (I don’t need to control my blinds from outside my home, yet). Chris Rieger’s project was very helpful with software documentation for these steps, but some familiarity with programming UNIX-based systems is required.

A couple of key parameters on the controller script control the speed (and noise) of the stepper motor, as well as its range of rotation.

#motor speed (time between steps)

STEP_PAUSE=0.0001

#motor range ‘DIRECTION, TOTAL NUMBER OF STEPS’
#open

root echo ‘1 2000’ >> /var/www/local/controller_queue” >> $CRON_JOB_PATH

#close

root echo ‘2 2000’ >> /var/www/local/controller_queue” >> $CRON_JOB_PATH

The number of steps it will take your motor to perform the amount of spooling you need will depend on how you wired the EasyDriver, which has setting to split steps into sub-steps, allowing for precision control in applications like 3D printing.

Then when you press the ‘Open’ button on the controller page, the appropriate command is sent and the motor does its job.

blind controller screenshot

Screenshot from controller page

I’ll note that the visualization on the controller page needs to be changed – it’s currently based on vertical blinds, which simply rotate to open.  It’s Java-based, so I will be piecing together a solution in the coming weeks.

It’s all been tested and confirmed working.  I’ll have a brief video of it in action soon.

Unfortunately, I am stuck waiting on wiring connectors for the stepper motor – I got a defective cable and it doesn’t use standard 2.54 mm connectors.  Logistics is a drag for these sorts of projects when you live in a small town.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s