XMEN BLOGGER: Raspberry Pi - Blind (sunshades) control

Friday, December 23, 2016

Raspberry Pi - Blind (sunshades) control


WiringPi

Software

There ar three pieces of software (wiringPi (from Gordon Henderson), shell script, RaZ-OR function) to be installed, from which the last is optional for use by people that do have the RaZberry plugged in.

WiringPi module

The GPIO pins can be controlled directly from the command prompt. For security reasons that function does require access as root. That is not always convenient. Therefore the WiringPi module should be installed(following Plan B) on the Raspberry. It not only deals with the "root" problem, but it also makes interfacing easier.

$ gpio readall



For this example we use "soft" pin numbers 12,13,14 in the first column named wPi. Those correspond to the physical pin numbers 19,21,23 as you can see in the above table, which was made using the gpio readall command. Check this for your Pi board.

Raspberry Pi pins:

PIN 01 - 3v3 battery (+)
PIN 19 (GPIO12) - down button (+)
PIN 21 (GPIO13) - stop button (+)
PIN 23 (GPIO14) - up button (+)
PIN 25 - ground (-)

Shell script

If you run OpenRemote on the Raspberry Pi, the sunshades can be controlled via the OpenRemote Shell execution protocol with the following script:

#!/bin/sh
PIN=$1
/usr/local/bin/gpio mode $PIN out
/usr/local/bin/gpio write $PIN 1
sleep 0.1
/usr/local/bin/gpio write $PIN 0

If you run on RaspCLI:

/usr/local/bin/gpio mode 19 out
/usr/local/bin/gpio write 19 1

Result is:


If you do not run OpenRemote on the Raspberry, you can control the shades using this script via the RaZ-OR module (see below)

For the further description it is assumed the file is called GPIO.sh. It is called with a single numerical parameter that is interpreted as follows if you use the above wiring diagram and the wiringPi module:

down  : 12
stop  : 13
up    : 14

Then:
/usr/local/bin/gpio mode 14 out
/usr/local/bin/gpio write 14 1
-> Goes up

And:
/usr/local/bin/gpio mode 13 out
/usr/local/bin/gpio write 13 1
-> Goes stop

The script makes the GPIO temporarily go high, which makes the Somfy remote button close for a short while.
In this script the wiringPi PIN numbers are used. See more detail on those pin assignments here.



REFERENCE

Somfy control
http://www.openremote.org/display/docs/OpenRemote+2.0+How+To+-+Control+Sunshades+-+Somfy+with+Raspberry+Pi

blind-control
http://romor.github.io/blind-control/

0 comentarios: