rcSwitch-python is a python based script to switch remote controlled sockets via 433 MHz.
This script is based on the following libraries:
- rpi-rf
- RPI.GPPIO
- Raspberry Pi or any other board having digital GPIO
- 433 MHz transmitter (for sending -> send device)
- 433 MHz controlled power socket, e.g. Brennenstuhl RCS 1000 N
- Connect the
VCC-Pinof the 433 MHz transmitter to any 5 V output pin of your board. - The
GND-Pinto a ground pin. - And the
ATAD-PinorData-Pinto anyGPIOpin.

In this example, GPIO 17 is used.
It is recommened to connect a (long) cable to the ANT pin of the 433 Mhz transmitter - this extends the range of the sender.
To define the relevant Codes you have to set the dip switches in the socket.
See picture below:

Lets assume you want to install the library in the following path on you Pi:
/usr/local/bin/python/rcSwitch-python
To install this library there you need to run the following commands:
Create the dir python:
cd /usr/local/bin
sudo mkdir python
cd python
Then install the library:
git clone https://github.com/hasenradball/rcSwitch-python.git
cd rcSwitch-python
git checkout develop
Make sure that you have the latest packages on the Pi.
Do an update:
sudo apt update
sudo apt upgrade
Also make sure that you have installed the rpi-rf library.
python3 -m pip install rpi-rf
Optional:
- to be sure that the library is also available for
rootuser, do this:
sudo -i
python3 -m pip install rpi-rf
exit
Then you should make sure that the current user is in the group of the the gpio users.
sudo usermod -a -G gpio $USER
If you have dose this steps, then you should be able to switch the sockets now.
To Switch the socket you can do this for example via cli like:
# make sure you are in the folder of the repo
cd /usr/local/bin/python/rcSwitch-python
python3 ./switchSocket.py <SystemCode> <ButtonCode> <status>
This could look like this, if we assume the following codes:
SystemCode = 10000, ButtonCode = 10000, status = 1
# using the Button Letter
python3 ./switchSocket.py 10000 A 1
or this way:
# usinf the integer ButtonCode
python3 ./switchSocket.py 10000 16 1
or just like this way:
# using the binary ButtonCode
python3 ./switchSocket.py 10000 10000 1
Where the following correlations for the ButtonCode can be described:
| Letter | int | binary |
|---|---|---|
| A / a | 16 | 10000 |
| B / b | 8 | 01000 |
| C / c | 4 | 00100 |
| D / d | 2 | 00010 |
| E / e | 1 | 00001 |
If you get an Error like:
RuntimeError: No access to /dev/mem. Try running as root!
The user does not belong to the Group of gpio.
Try to run with sudo.
If you want to increase the range of the sender device, there are two possibilities to to that:
- instead of 5 V at
VCC-Pinyou can set up to 12 V to theVCC-Pin - use a long cable instead of the antenna
For discussions see:
https://knx-user-forum.de/forum/supportforen/smarthome-py/39094-logic-und-howto-für-433mhz-steckdosen
- initial version



