Skip to content

Instantly share code, notes, and snippets.

@petrica
Created October 17, 2021 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrica/65dbcb2ffd79c7b11e73fef954437757 to your computer and use it in GitHub Desktop.
Save petrica/65dbcb2ffd79c7b11e73fef954437757 to your computer and use it in GitHub Desktop.
Contron Livolo switches from Python using a RaspberryPi and an RF433 module
import time
import RPi.GPIO as GPIO
# BCM Port where the RF module data pin is connected
tx_pin = 24
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(tx_pin, GPIO.OUT)
high = True
def bit_read(value, bit):
return value >> bit & 0x01
def send_pulse(pulse):
if pulse == 1:
GPIO.output(tx_pin, GPIO.HIGH)
time.sleep(.000525) #550
GPIO.output(tx_pin, GPIO.LOW)
elif pulse == 2:
GPIO.output(tx_pin, GPIO.LOW)
time.sleep(.000110) #110
GPIO.output(tx_pin, GPIO.HIGH)
elif pulse == 3:
GPIO.output(tx_pin, GPIO.LOW)
time.sleep(.000303) #303
GPIO.output(tx_pin, GPIO.HIGH)
elif pulse == 4:
GPIO.output(tx_pin, GPIO.HIGH)
time.sleep(.000110) #110
GPIO.output(tx_pin, GPIO.LOW)
elif pulse == 5:
GPIO.output(tx_pin, GPIO.HIGH)
time.sleep(.000290) #290
GPIO.output(tx_pin, GPIO.LOW)
def select_pulse(bit):
global high
if bit == 0:
for i in range(1, 3):
if high == True:
send_pulse(2)
else:
send_pulse(4)
high = not high
if bit == 1:
if high == True:
send_pulse(3)
else:
send_pulse(5)
high = not high
def send_button(remote_id, keycode):
global high
for pulse in range(200):
send_pulse(1)
high = True
for i in range(16, 0, -1):
select_pulse(bit_read(remote_id, i - 1))
for i in range(7, 0, -1):
select_pulse(bit_read(keycode, i - 1))
GPIO.output(tx_pin, GPIO.LOW)
# test with a remote id of 10550 and a button id no of 96
send_button(10550, 96)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment