Automatic Roller Shutter

As you can read in some other blog posts, we made a trip to Scotland this year.

But before we left, I wanted to give the impression that my house was inhabited (despite my previous anti-theft protection measures).

roller shutter remote control

My plan was to automate the roller shutters, so that they automatically open in the morning, and close in the evening. The solution offered by the vendor is quite expensive (300 € Somfy Tahoma), so I decided to build my own solution with a Raspberry Pi and a spare remote control.

I got my inspiration from a Github project, but my first version doesn’t have to be that fancy (weather control and all). I’m already happy if the roller shutters open and close at a fixed time. I have 3 different roller shutters, but I’ve programmed the remote to control all 3 of them at the same time.

The first step is to open up the remote and do the soldering. The Raspberry Pi can perfectly power the remote control, so you don’t need the battery anymore.

Raspberry Pi connected with roller shutter

After that, I started programming. In the Github project, it is clearly explained how to control your rolled shutters. And for the scheduling, I’ve used the schedule package.

Here’s the code:

import schedule
import time
import datetime
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)

# fixed times, in UTC
# example: 12:20 UTC = 14:20 GMT+1 (Belgian timezone)
SHUTTER_UP_TIME    = "06:05"  #UTC!
SHUTTER_DOWN_TIME = "19:15"   #UTC!

# time interval for normal button presses
BUTTON_HOLD    = 0.1    # seconds
BUTTON_TIMEOUT = 0.2    # seconds

#action on pin
def switch_pin(pin_nr):
        try:
            # Pin ON
            # to turn a button on we just need to set the GPIO to output
            # it will then output low level, which equals a button press
            print("pin {}: ON".format(pin_nr))
            GPIO.setup(pin_nr, GPIO.OUT)
            # delay
            time.sleep(BUTTON_HOLD)

            # Pin OFF
            # accordingly, to turn a button of we configure the GPIO to input
            # the high impetance state equals no button press
            print("pin {}: OFF".format(pin_nr))
            GPIO.setup(pin_nr, GPIO.IN)
            # delay
            time.sleep(BUTTON_TIMEOUT)
        except RuntimeError as ex:
            print("Error controlling GPIOs: " + str(ex))


#control shutters
def shutter_action(direction):
        if direction=="up":
                switch_pin(20)
        else:
                switch_pin(21)

def shutter_up():
    print("Going up...")
    shutter_action("up")

def shutter_down():
    print("And back down...")
    shutter_action("down")

schedule.every().day.at(SHUTTER_UP_TIME).do(shutter_up)
schedule.every().day.at(SHUTTER_DOWN_TIME).do(shutter_down)

while True:
    schedule.run_pending()
    time.sleep(1)

There! From now on, the roller shutters operate automatically. The best thing is that I didn’t have to change anything to my existing setup (no extra cables, no reprogamming of existing remotes, …). If I unplug my Raspberry Pi, everything’s back to normal.

Of course, this is a very basic setup. I could for example automatically close them when it is too hot, or make it weather-dependent. But these are all possible future extensions (I thought about this project just a couple of days before we left for Scotland, so I was a bit in a hurry).

Be sure to check out my other Raspberry Pi projects:

3 thoughts on “Automatic Roller Shutter

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 )

Facebook photo

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

Connecting to %s