RFRemotech RR2LN 433 mhz rf Protocol
I bought a set of 433mhz controlled remote relay devices from eBay, via a seller called RFRemotech a number of years ago to use in my Home Automation experiments. I've been using these relays successfully for a few years now, controlling my home heating, lights, fans and various other bits of hardware.
My original hack had been to use the original remote control via a Serial based relay control board from Quasar Electronics, but that was ugly, it was time to control it directly via an Arduino.
RFRemotech RR2LN Units
The units I have are from RFRemotech and are their Magic Receiver modules. These are fairly cheap when purchased through their eBay shop but are good quality. The 2-channel versions have two relays, both rated at 10amp at 250 VAC, plenty for most household appliances. The quality of the soldering is excellent and they've been reliable for me for the last 3 or so years - they make a satisfying clunk when engaged.
They can be programmed with a jumper to be momentary or release, and can be re-programmed to respond to various buttons on the remote in different ways. More details about how on their page: http://stores.ebay.co.uk/RFRemotech.
Arduino Based Control
Having read around, it looked like controlling 433mhz RF devices direct from an Arduino is a fairly common approach. I purchased a generic transmitter/receiver pair from DX.com for less than 3 dollars and waited for it to arrive.
This can be driven direct from one of the Arduinos digital out's, but could equally be driven by a Raspberry Pi's GPIO ports too. I decided to use an Arduino.
Wiring up the receiver to the Arduino, I tried a few of the RCSwitch included sketchs to see if I could capture the protocol for the RFRemotech relays, but no luck, it didn't seem to be supported. So the next step was protocol analysis with a logic analyser.
Decoding The 433Mhz ProtocolLogic Analyzer.
After hacking about a bit with it, I managed to get it re-flashed to run with Saleae Logic Analyser software, which made life easier.
Capturing the logic from the DOUT pin on the transmitter was simple enough, the transmitter uses a PT2262 chip, the DOUT pin is second down on the right hand of the chip. With a small session of recording later I'd got the capture in Saleae and could see the timing of the pulses.
Short pulses seemed to be around 0.11ms. Long pulses were always between 0.33ms and 0.32ms.
I'm not too familiar with RF encoding and so, after a lot of reading around and googling for the PT2262 chip info, I happened across Tinkermans excellent page which lead me to realise the encoding.
0 short high + long low + short high + long low 1 long high + short low + long high + short low F short high + long low + long high + short low
Armed with that knowledge I could quickly decode the first two buttons;
It doesn't take a genius to work out where this one is going, so I didn't bother to decode the remaining 8 buttons, I think I can probably guess :)
Triphase Protocol and RCSwitch
The RCSwitch library is available for Arduino and Raspberry Pi and is able to send and receive Triphase encoding as so;
However, when verifying this with the logic analyser the timing looked off, plus I still wasn't able to activate the relay. It needed a little tweaking to the config on the RCSwitch library to get the timing just right;
There's a full piece of example code available on GitHub https://github.com/Siftah/Wiki/blob/master/HAHub.ino which has been coded to work with an Ethernet shield and respond to a udp message sent on port 1337, heat:0 to turn off the relay and heat:1 to enable. More details about how to use this generic controller available on this page.