Tested on:RPi 3; Python 3.4; Raspbian Jessie
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)
Hardware:compatible 433MHz rc switch and remote control
0

Home automation with rpi-rf_send and rpi-rf_receive for 433MHz rc switches

So far, i’ve used the Python module pi-switch for controlling rc switches, but it is no longer maintained. rpi-rf (Github) is a very viable alternative.
In this tutorial, you’ll use a 433MHz receiver with rpi-rf_receive for decoding the switching code for a common rc switch, then trigger that switch with a 433MHz sender and rpi-rf_send. Together with e.g. the Python server CherryPy, it’s easy to develop a HTML-based remote control.

Installation
The installation is simple with Pip3:

Voltage divider
Since the 433Mhz receiver runs on 5 Volt, but a RPi can take no more than 3.3V at its inputs. Therefore, a voltage divider needs to be attached. For this, two 4.7k Ohm resistors were attached to the receiver: one resistor from signal divides to the RPi input and to GND over the second resistor (in the shrink sleeve).

433MHz receiver

433MHz receiver with voltage divider

Assembly
The sender is connected to pin 6 (GND), pin 1 (3.3V VCC) and pin 11 (DATA) in BOARD numbering. The receiver is connected to pin 9 (GND), pin 2 (5V VCC) and pin 13 (DATA), again in BOARD numbering.

Setup rpi-rf

Setup rpi-rf

This setup works way better if the sender has an antenna connected to ANT.

Receiving switch codes
Many inexpensive rc switches are controlled by a simple decimal code from the remote, like the ones in this list of compatible devices. Start listening to 433MHz rc commands by entering in the terminal

-g 27 is the GPIO pin the receivers data output is connected to in BCM numbering. Pin 13 in BOARD is pin 27 in BCM. Use the remote to trigger the switch on and off. For this switch, the codes 1381717 for On and 1381716 for Off were received at a pulse length of 437:

RC switch codes

RC switch codes

The signals aren’t necessarily clearly, it may take a few attempts to find the right codes.

Switch a remote
To test the codes, enter in the terminal

with SWITCH_CODE and PULSE_LENGTH from the previous step. -g 17 means the GPIO pin number 17 in BOARD numbering, which is pin 11 on BOARD and the DATA pin of the sender. After executing the command, the switch is triggered accordingly.

Python binding
For using rpi-rf in Python 3, create an instance of RFDevice:

enable_tx() starts the transmission mode. tx_code(...) triggers the switch with SWITCH_CODE for the given PULSE_LENGTH.

Links
Home automation with rc switches: http://www.knight-of-pi.org/cheap-home-automation-with-a-raspberry-pi-controlling-rc-switches-with-pi-switch/
rpi-rf auf GitHub: https://github.com/milaq/rpi-rf
CherryPy: elegant Python server for the Raspberry Pi: http://www.knight-of-pi.org/cherrypy-an-elegant-python-webserver-for-raspberry-pi-remote-controls/
rpi-rf_send kompatible Funksteckdosen: https://github.com/sui77/rc-switch/wiki/List_KnownDevices
rpi-rf_send compatible rc switches: https://github.com/sui77/rc-switch/wiki/List_KnownDevices

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.

Comment

Time limit is exhausted. Please reload CAPTCHA.