You are correct, you need to sniff the codes first. I normally use an Arduino plus receiver for this as many of them are non standard and there are several sniffing programs available. I can paste a Python sample program for the transmit side. They are mostly variants on that but you might have to play around a bit. I have roller blinds with 40 & 41 bit codes. Also I have some Lidl sockets which seem to be non standard which took a bit of work to get right.
Sample Python program below. This was for some B&Q sockets which were subsequently recalled because of fire hazard issues, so I donāt use it any more. As usual I am indebted to others who posted on this in the past but I donāt remember where / who.
# code from usage of library web site below ------------------------------
#!/usr/bin/env python3
import argparse
import logging
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False) # disable an execution waring about channel in use
parser = argparse.ArgumentParser()
parser.add_argument("command", help="A1=A-on, A0=A-off, B1=B-on etc. M1=Master on, M0=Master off")
args = parser.parse_args()
command = args.command
from rpi_rf import RFDevice
BIT1_PULSE = .001000 # microseconds
BIT1_DELAY = .000330 # sort of averages from a few samples
BIT0_PULSE = .000420
BIT0_DELAY = .001020
SYNC_PULSE1 = .000370
SYNC_DELAY1 = .002000
SYNC_PULSE = .000350
SYNC_DELAY = .010840
RF_DATA_PIN = 17
bit_value = "0" # initialise a character string
GPIO.setup(RF_DATA_PIN, GPIO.OUT) # GPIO pin set as output
# these are the bit sequences
# signalA1 = '000101010001010101010111'
# signalA0 = '000101010001010101010100'
# signalB1 = '000101010100010101010111'
# signalB0 = '000101010100010101010100'
# sequence is A1, A0, B1, B0, 1 = on, 0 = off
signals = ['000101010001010101010111',
'000101010001010101010100',
'000101010100010101010111',
'000101010100010101010100',]
def sendSync():
GPIO.output(RF_DATA_PIN, True)
time.sleep(SYNC_PULSE1)
GPIO.output(RF_DATA_PIN, False)
time.sleep(SYNC_DELAY1)
def endSync():
GPIO.output(RF_DATA_PIN,True)
time.sleep(SYNC_PULSE)
GPIO.output(RF_DATA_PIN,False)
time.sleep(SYNC_DELAY)
def activatePlug(signal):
for i in range (0,5): # repeat signal tx at least 4 times - mandatory
# sendSync() # not needed for B&Q sockets
for k in range (0, 24):
bit_value = signal[k:k+1]
# print ("Bit Value = ", bit_value)
if bit_value == '1':
GPIO.output(RF_DATA_PIN,True)
time.sleep(BIT1_PULSE)
GPIO.output(RF_DATA_PIN,False)
time.sleep(BIT1_DELAY)
elif bit_value == '0':
GPIO.output(RF_DATA_PIN,True)
time.sleep(BIT0_PULSE)
GPIO.output(RF_DATA_PIN,False)
time.sleep(BIT0_DELAY)
# print ("sending end sync")
endSync() # clean up after each transmission
# main program
# command parameter should be A1, A0, B1, B0
# program will fail if none of the above supplied as a parameter
command_list = ['A1','A0','B1','B0']
signal_index = command_list.index(command)
signal = signals[signal_index]
# print("Switching ", command, " ", signal)
activatePlug(signal)
# main program ends here
when trying to resolve another issue with RF devices, I had another look at this program and noticed that none of the RPI_RF methods are actually used in the program, so the following line is probably unnecessary:
from rpi_rf import RFDevice
Itās probably just a hangover from an earlier version or different program.
Awesome! Ill give it a try!
So i got the receiver working last night with the doorbell. The problem is the code, pulselenght and protocol are in no way consistent. Wich one is the one i need?
2018-01-04 18:04:28 - [INFO] rpi-rf_receive: Listening for codes on GPIO 27
2018-01-04 18:04:36 - [INFO] rpi-rf_receive: 10 [pulselength 1032, protocol 4]
2018-01-04 18:04:37 - [INFO] rpi-rf_receive: 4 [pulselength 1336, protocol 2]
2018-01-04 18:04:37 - [INFO] rpi-rf_receive: 512 [pulselength 1504, protocol 4]
2018-01-04 18:05:03 - [INFO] rpi-rf_receive: 2 [pulselength 1921, protocol 2]
2018-01-04 18:05:03 - [INFO] rpi-rf_receive: 1 [pulselength 95, protocol 3]
2018-01-04 18:05:10 - [INFO] rpi-rf_receive: 2 [pulselength 2325, protocol 4]
2018-01-04 18:05:10 - [INFO] rpi-rf_receive: 32 [pulselength 1089, protocol 4]
2018-01-04 18:05:10 - [INFO] rpi-rf_receive: 524288 [pulselength 1152, protocol 4]
2018-01-04 18:05:10 - [INFO] rpi-rf_receive: 256 [pulselength 1271, protocol 4]
2018-01-04 18:05:22 - [INFO] rpi-rf_receive: 256 [pulselength 1215, protocol 5]
2018-01-04 18:05:27 - [INFO] rpi-rf_receive: 8 [pulselength 290, protocol 1]
2018-01-04 18:06:12 - [INFO] rpi-rf_receive: 4 [pulselength 745, protocol 2]
2018-01-04 18:53:24 - [INFO] rpi-rf_receive: 33 [pulselength 268, protocol 1]
2018-01-04 18:53:24 - [INFO] rpi-rf_receive: 32 [pulselength 1298, protocol 4]
2018-01-04 18:53:24 - [INFO] rpi-rf_receive: 65 [pulselength 1355, protocol 4]
2018-01-04 18:55:39 - [INFO] rpi-rf_receive: 2 [pulselength 1276, protocol 5]
2018-01-04 18:55:39 - [INFO] rpi-rf_receive: 4 [pulselength 2030, protocol 4]
2018-01-04 18:55:50 - [INFO] rpi-rf_receive: 1 [pulselength 1826, protocol 4]
2018-01-04 18:55:50 - [INFO] rpi-rf_receive: 16 [pulselength 1164, protocol 4]
2018-01-04 18:55:50 - [INFO] rpi-rf_receive: 8 [pulselength 878, protocol 2]
2018-01-04 18:55:58 - [INFO] rpi-rf_receive: 1 [pulselength 930, protocol 4]
2018-01-04 18:55:59 - [INFO] rpi-rf_receive: 8 [pulselength 817, protocol 5]
2018-01-04 18:56:52 - [INFO] rpi-rf_receive: 26 [pulselength 223, protocol 3]
2018-01-04 18:56:52 - [INFO] rpi-rf_receive: 1 [pulselength 101, protocol 3]
2018-01-04 18:56:52 - [INFO] rpi-rf_receive: 1 [pulselength 1206, protocol 4]
2018-01-04 18:56:52 - [INFO] rpi-rf_receive: 2 [pulselength 497, protocol 1]
Found the problem. It was on 3.3v and not 5v. Now ill try again
Iām just receiving RF, no particular need to ring my own doorbellā¦
How are you receiving? What component are you using?
what was on 3.3v and not 5v? Can you please elaborate? (Iām experience a similar problem)
Hi,
The GPIO pins on the Pi!
Hi, i never bought them because i couldnāt get it to work. I do have an other way of listing: sonoff RF bridge, which i have used to listen to rf successfully.
Planning to order them when i have some spare time to test.