Remote Control Switches via 433 Mhz transmitter using RPi.GPIO instead of WiringPi

This page shows the way to control your lights and other devices in your house by using a simple 433 Mhz transmitter connected to the Raspberry Pi.

For more than 10 years I used the WiringPi software from www.wiringpi.com (which was standard software to use at that time and now is deprecated).

I created two scripts (one Bash and one Python) which are independent of the Raspberry Pi model used and OS/Debian version!

The scripts will still work after updates/upgrades of your Raspberry Pi hardware/software!

It's using the RPi.GPIO software which is standard installed.

 

Supported remote switches switches (which will work with this instruction):

- ELRO AB440 S
- Brennenstuhl RCS 1000 N Comfort
(Not tested: BAT RC-3500-A, Intertechno (Silvercrest) PA3-1000, Vivanco FSS 31000W)

NOTE: The ELRO switches are no longer available.. Order (Amazon/Ebay) and use the "Brennenstuhl RCS 1000 N Comfort" which are exactly the same as the ELRO's !

 

Hardware:

- Raspberry Pi

- RF-DRA887TX or DRA888TX or DRA889TX DORJI 433MHZ 10/17dBm ASK TRANSMITTER , DIP PACKAGE => http://www.dorji.com/products.php?CateId=36

PIN used on Raspberry Pi:
4 => 5V ----> +5V RF-Transmitter
6 => GND ----> 0V/GND RF-Transmitter
8 => GPIO for TX ----> Data out RF-Transmitter ==> This is Pin 14 !! See "TRANSMIT_PIN = 14" (in my case this is 14) in the elro.py script.

 

Scripts to create elro & elro.py (and 'chmod 755' on them):

-------------------------- name it: elro ------------------------------------------------------------

#!/bin/bash
 
if [ -z "$3" ]
then
echo "Usage: $0 <SwitchId>"
echo "Example: $0 24 B on"
exit
fi
 
DT=`date +%d-%m-%Y-%H-%M`
 
export ARG1=$1
export ARG2=$2
export ARG3=$3
 
D2B=({0..1}1{0..1}1{0..1}1{0..1}1{0..1}1)
PART1=`echo ${D2B[$ARG1]}|rev`
 
case $ARG2 in
A|a )
PART2=1110101010
;;
B|b )
PART2=1011101010
;;
C|c )
PART2=1010111010
;;
D|d )
PART2=1010101110
;;
E|e )
PART2=1010101011
;;
esac
 
case $ARG3 in
ON|On|on )
PART3=11101
;;
OFF|Off|off )
PART3=10111
;;
esac
 
#echo "${PART1}${PART2}${PART3}"
 
./elro.py ${PART1}${PART2}${PART3}
 
 
exit
-------------------------- end of: elro ------------------------------------------------------------
 
 
-------------------------- name it: elro.py ------------------------------------------------------------
 

#!/usr/bin/python3

import time
import sys
import RPi.GPIO as GPIO

if len(sys.argv) == 1:
   print('no arguments passed')
   print('usage example: elro.py 1010111111010101011..')
   sys.exit()

# Next is for Elro or Brennenstuhl RCS 1000 N Comfort
short_delay = 0.000316
long_delay = 0.00095
extended_delay = 0.0098

NUM_ATTEMPTS = 10
TRANSMIT_PIN = 14

def transmit_code(code):
    '''Transmit a chosen code string using the GPIO transmitter'''
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(TRANSMIT_PIN, GPIO.OUT)
    for t in range(NUM_ATTEMPTS):
        for i in code:
            if i == '1':
                GPIO.output(TRANSMIT_PIN, 1)
                time.sleep(short_delay)
                GPIO.output(TRANSMIT_PIN, 0)
                time.sleep(long_delay)
            elif i == '0':
                GPIO.output(TRANSMIT_PIN, 1)
                time.sleep(long_delay)
                GPIO.output(TRANSMIT_PIN, 0)
                time.sleep(short_delay)
            else:
                continue
        GPIO.output(TRANSMIT_PIN, 0)
        time.sleep(extended_delay)
    GPIO.cleanup()

if __name__ == '__main__':
    for argument in list(sys.argv[1:]):
        exec('transmit_code(argument)')

exit()

# Additional information for other Brands such as Action , Blokker and Kaku (Klik aan en Klik uit)..you or I should do still a bit work on them;-)

#ActionSwitch:periodusec=190 ,567 ,5832
# Action 18_B_on : 1000101000101110101010111
# Action 18_B_off: 1000101000101110101011101
# Action 7_B_off : 0000001010101110101011101
# Action 7_A_on  : 0000001010111010101010111

#BlokkerSwitch:periodusec=228 ,685, 7050
# Blokker 7_A_on : 1100111111111111111111111
# Blokker 2_B_off: 1111000011111111111111111

#KaKuSwitch:periodusec=370 ,1110, 11510
# Kaku M_10_on   : 1111101010111110111010101
# Kaku M_10_off  : 1111101010111110111010111
# Kaku M_7_off   : 1111101011101011111010111
# Kaku G_7_off   : 1110101111101011111010111
# Kaku B_7_off   : 1011111111101011111010111
# Kaku B_2_on    : 1010111110111111111010101
#ActionSwitch(unsigned short pin, unsigned int periodusec=190);
#BlokkerSwitch(unsigned short pin, unsigned int periodusec=230);
#KaKuSwitch(unsigned short pin, unsigned int periodusec=375);
#ElroSwitch(unsigned short pin, unsigned int periodusec=320);

-------------------------- end of: elro.py ------------------------------------------------------------
 

Now simply execute the elro (will also work for Brennenstuhl) command with the correct code.

Like:

./elro 24 D on

./elro 24 D off


Optional CODE information:

ON=1
OFF=0

Switch names
1 2 3 4 5 A B C D E


Values:
1 2 4 8 16 A B C D E

Examples:

0 0 0 1 1 0 0 0 0 1 => 24 E 
0 1 1 1 1 0 1 0 0 0 => 30 B 

 

  If you like my website, feel free to donate via the Paypal button. Thank you!