Remote control key fobs are typically used for garage doors and the like. Also car door opening systems use them. The protocol of these devices seems to be relatively standard. When pushing one of the buttons, series of radio frequency (rf) pulses are sent that are subsequently received by the door opening equipment. These compare the received code sequence with the internally stored code and when equal open or close the door. This principle is also used for controlling lighting, transmitting weather station information, etc.
This little report is on so-called key fob’s as displayed above. These are currently abundantly available on the web. They have the advantage that they have a mechanism by which they can be programmed from another key fob. The procedure is relatively simple but requires some persistence: eventually it will work:
- Push the A and B buttons simultaneously. The LED goes on and after some time it starts to blink fast. This indicates that the key fob is erased and the buttons can be released.
- Now, upon pushing any of the buttons the LED only blinks once very short. This indicates no code is transmitted.
- Let us call this “empty” key fob number 1. The key fob from which we wish to copy is number 2.
- We will now copy the code of button X, either A, B, C or D, from key fob 2 onto key fob 1 button Y (A, B, C, or D).
- Push button X on key fob 2, its LED will burn continuously to indicate it is transmitting the code sequences.
- Push button Y on key fob 1, its LED gives an initial short blink and then remains off.
- Bring the two key fobs, while keeping the buttons pushed, together, usually front to front but other positions may also work, until the LED on key 1 will start to blink. Then the buttons may be released.
- Push now button Y on key fob 1 and the LED should shine continuously to indicate that it is transmitting a code. If everything went well this code also activates the door that was controlled by key fob 2.
- This can be repeated for all four buttons. Identical codes for two different buttons can also be programmed, the key will not complain.
Important to note is that similarly looking key fobs may have different, albeit similar, protocols. Follow the seller’s instructions where necessary.
One may also purchase a control unit that contains two relays that can be controlled from two buttons of an above described key fob. These units also need to be programmed, although they do come with pre-programmed key fobs. The unit has a DIP-selector that sets the control mode. Here we use that a single button switches both on and off. The unit has two LED’s that are next to the relays and indicate the status of the relay: on or off. Close to the control button there is another LED. It blinks upon receipt of a coded rf signal from a key fob.
If one wishes to operate with different codes than encoded from the factory, one proceeds as follows
- The codes are erased by pushing the button until the LED starts blinking.
- Now, the keys cannot switch the relays anymore although the LED may blink to indicate that a code has been received.
- Pushing the button on the unit once brings the unit into programming mode, the LED goes on.
- Push on the key fob first the button that is to control relay A. The LED will blink to indicate reception. Release the button. The LED remains on.
- Push now on the key fob the button that is to control relay B. The LED will blink to indicate reception and go off.
- The unit is now programmed. Pushing the two buttons will now activate relays A and B.
- Note, that pushing twice the same button will only program relay A!
It may be interesting, to use a completely different code with the key fobs and the unit. Such is described for a Raspberry Pi by an instructable written by george7378. Below an example of a trace of a button code.
The rf signal is on during the “high” time, typically about 0.5 ms, and off during the “low” signal, about 1 ms. These sequences are repeated with an interval of about 10 ms so that hundreds of code sequences are sent by pushing the button for a second or so. The code can be easily read, a short high followed by a long low is interpreted as a binary 1 whereas a long high followed by a short low is a binary 0. The binary code sequence thus consists of 25 bits, here 1111 0000 0101 0110 0101 1110 1. There are 225 = 33,554,432 different codes possible with these 25 bits.
With the little Python program described by the above mentioned instructable it is relatively simple to enter ones own code. Using a 17,2 cm antenna on the 433 MHz transmitter makes coding the key fobs quite a lot simpler. Especially if one makes the number of sequence repetitions large, i.e. change NUM_ATTEMPTS from 10 to 100.
There are many different codes possible already with this 25 bit sequence, but if one imagines that the number of bits, the “high” time, the “low” time and the repetition time can all be varied at will one sees why there usually is not too much interference between units and key fobs of various origin. There will be limits on the timing and codes used, but a lot of variation remains for a given set.
A few remarks on the programs described in instructable.
- It uses the same GPIO port for sending and receiving. I found it easier to have different ones so that both units can be connected simultaneously.
- Using on the first line the code
and making it executable by for instance
chmod +x TransmitRF.py
allows one to simpler call the program as
and repeat its operation.
- Rather than using ReceiveRF.py, the program to read the code sequence from key fobs, I prefer to use my Logic 4 Digital+Analog Logic Analyzer from Saleae. It gives much more freedom in analyzing the data.
2 gedachten over “Programming 433 MHz remote control key fobs”
What about cologning this remote from my Chamberlain garage door opener. It is not copying.
The described fobs use a fixed code. Modern fobs use a rolling or hopping code, see https://en.wikipedia.org/wiki/Rolling_code for an explanation.
The above presented method will not work with rolling codes albeit that analyzing the data-stream will allow one to learn whether or not a fixed code is employed.