Low cost RC power sockets (radio outlets) + Arduino


[Deutsche Version]

For cheap home automation purposes I’d like to present you my new Arduino libary for operating up to 16 low cost 433MHz RC power sockets. I’ve bought this RC switch set for about 10 EUR.

There is a SC5262 chip (datasheet) built in the hand set which – depending on which key is pressed – generates a data telegram and relays it to the actual RC sender. After studying the datasheet and some other resources (1, 2, 3 – sorry, all in german) on similar projects I was able to control the switches using only one I/O pin at the Arduino.

Theory
If you know how the data telegrams look like, you can generate them with the microcontroller and therefore resign the encoder chip from the hand set.

A code bit consists of two on/off states. The important thing are the cronological lengths of these states. You can think of it like morse. There are thre possible code bits at all, that is „0“, „1“ and „F“. Furthermore there is another sync. bit (I’ll call it „S“).

"0" Bit => 1/8 cycles on, 3/8 cycles off, 1/8 cycles An, 3/8 cycles off   -...-...
"1" Bit => 3/8 cycles on, 1/8 cycles off, 3/8 cycles An, 1/8 cycles off   ---.---.
"F" Bit => 1/8 cycles on, 3/8 cycles off, 3/8 cycles An, 1/8 cycles off   -...---.
"S" Bit => 1/8 cycles on, 31/8 cycles off -...............................

A code word consists of 9 address bits, 3 data code bits and one sync. bit. It represents the command (data bits) to a specific switch (address bits).

A code frame consists of 4 code words. Basically every command is repeated 4 times.

The conrad power switches are coded as follows:
4 bits group address + 4 bits switch address + 1 unused adress bit + 1 unused data bit + 2 data/command bits + 1 sync. bit


group address I = "0FFF"
group address II = "F0FF"
group address III = "FF0F"
group address IV = "FFF0"

switch 1 = "0FFF"
switch 2 = "F0FF"
switch 3 = "FF0F"
switch 4 = "FFF0"

unused databits = never mind, could be either "F" or "0"

command on = "FF"
command off = "F0"

So if you want to switch the 3rd switch from the 4th group off, you’ll have to send „FF0FFFF0FFF0S“.

Hardware / Hacking the hand set

Open your hand-held transmitter and solder a wire to the positive pole (+), one to the negative pole (-) of the battery holder and another one to the DOUT Pin of the SC5262S chip.
Altough my transmitter was operated with a 12V battery it also worked with 5V, so I think it’s fine to power it directly from the Arduino (5V and GND). Connect DOUT to any available I/O pin from the Arduino.

Software
Download RCSwitch.zip and extract it to your /Arduino/Libaries directory. The following sketch should be self explaining 🙂

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch(11);  // Sender is connected to Pin #11

void setup() {
}

void loop() {
    mySwitch.switchOn(1, 1);         // Switch 1st socket from 1st group on
    delay(1000);
    mySwitch.switchOff(1, 1);        // Switch 1st socket from 1st group off
    delay(1000);
}

Updates

  • The libary is hosted at google code now (here).
  • New sending methods (other outlet types than described here or raw codes)
  • New functionality to receive and decode signals from your remote hand set


Flattr this

Advertisements

51 Gedanken zu “Low cost RC power sockets (radio outlets) + Arduino

    • Guess it should work but I can’t guarantee. If not, I’m really interested in extending the libary for any new kind of remotes 🙂

      – Is the frequency printed on the outlets or transmitter (should be 433MHz or 868MHz)?

      – Are there switches to configure or does it have a code learning mode?

      – Could you send me a picture of the open transmitter (both sides)?
      mailto: so@instantgallery.de

      If you bother destructing your transmitter you could alternatively get yourself a RF transmitter and receiver module.

      • Hi. I have coded support for sending and recieving Nexa\CoCo in rcswitch. How can I add these changes to rcswitch at google code?

  1. Pics emailed to you…

    1.
    (- Is the frequency printed on the outlets or transmitter (should be 433MHz or 868MHz)?)

    Frequency is 433.92MHz (printed on receiver)

    2.
    (- Are there switches to configure or does it have a code learning mode?)

    I believe the receivers use some sort of code learning mode, you plug in the receiver to the wall socket and a red LED blinks for about 5 seconds. Under that time you program it with the transmitter.

    …Thanks

      • Doesn’t need to know the encoding of the remote control/plugs? what they expect to hear, for example if he use the example above with this transmitter and arduino should work with any RF device?

  2. Great work I am using the WEB server code you posted 2. September and it works just fine.

    I tried to combine the rc-switch code with the Arduino Time library as I want to make a scheduler to turn on and off my lights at different time depending on the time of year and day of the week.

    However it did not work somehow I think that the Time library and the rc-switch code uses the same resource but I cannot see which.

    Anyhow I am thinking of using crontab and wget on my NAS to control the web server if I cannot get the Time library to work with the rc-switch code.

    How do I get the Time library to work with the rc-switch code?

    • I’ve no idea why it should not work together. The RCSwitch::send() methods don’t use any special resources beside the pin you define for the tansmitter and the time library shouldn’t be dependent of any pin. Can you post an example sketch? (or mailto: s(at)sui(dot)li )

  3. Hi, I have an SF04B transmitter, do you think you can provide info about it? Which pin is the DOUT and does your existing code work with that chip?

    Thanks!

      • Another way is to give me some instruction to find which chip resistor is responsible for dout and solder my cable (like your picture). Also that goes to any digital output?

        thanks again

      • OK, I did this http://www.mediafire.com/i/?4y7gm5ndjm7pgmu and in arduino put your example:
        #include

        RCSwitch mySwitch = RCSwitch(11); // Sender is connected to Pin #11

        void setup() {
        }

        void loop() {
        mySwitch.switchOn(1, 1); // Switch 1st socket from 1st group on
        delay(1000);
        mySwitch.switchOff(1, 1); // Switch 1st socket from 1st group off
        delay(1000);
        }

        Also I added in loop some serial.print(„TEST“) in order to check if steps are passed, but it seems that somewhere program stucks and nothing happened.

        Am I missing something?

      • The code:

        #include

        RCSwitch mySwitch = RCSwitch();

        void setup() {

        Serial.begin(9600);

        // Transmitter is connected to Arduino Pin #11
        mySwitch.enableTransmit(11);

        // Optional set pulse length.
        // mySwitch.setPulseLength(320);

        // Optional set number of transmission repetitions.
        // mySwitch.setRepeatTransmit(15);

        }

        void loop() {
        /* See Example: TypeA_WithDIPSwitches */
        mySwitch.switchOn(„11110“, 3);
        Serial.println(„ON“);
        delay(2000);
        mySwitch.switchOff(„11110“, 3);
        Serial.println(„OFF“);
        delay(2000);
        }

        just prints on off but no action in remote control led or socket.

  4. great work! Im going to buy this set from the dutch conrad website too and use it with your library.
    I will also try to make it work over the internet with an ethernet shield.
    i’ll keep you posted 😀
    tnx

  5. Hi there my name is Jason Dalli. I am following this thread/forum and I am finding very interesting. Today I started to work on this project but I am having problems get the outlet/receiver plug working on/off. I am using the same model with the same chip transmitter receiver like you have used in the images using rotary switches. I have connected the DOUT to the corresponding output, also I am seeing the LED flickering when the arduino is send the commands to the transmitter but the outlet is not switching on. Can you please guide me as this is one of my favorite projects I ever wished to do. Thanks in advance

    Jason

  6. I just tested with an 8.3K resistor with DOUT but no succuess. I think I will move on as old times using 5volt relays, transistors and short out the button area! If you have any suggestion regarding this please let me know. I appreciate a lot your help.

    Thanks
    Jason

  7. Hi,
    Thanks for your excellent work.
    I made it work with these UK sockets http://www.amazon.co.uk/Proteam-HO1853-Set-Remote-Sockets/dp/B0029Z9YUQ

    I have also tried to increase the range by supplying 12V to the remote board, and using a small transistor (BC109) circuit between the Arduino and the remote board (because of the 12V).

    Because of the way I used the transistor, I needed to change the programmimg code, so that the pulses were inverted. Actually I added an extra func so that either normal or Inverted pulses can be used. I can send you my code updates, they are very simple 😉

    Using 12V instead of 5V does seem to increase the range slighly, i.e back to the same range the remote control has when operating normally from batteries.

    Contact me if you want my circuit or updated code.

    Cheers

    Roger Clark

  8. Need advice!
    I’ve just got my Transmitter/Receiver Pair (433Mhz RF link kit
    [WLS107B4B]) and wried it as followed:
    Receiver: Ground from Arduino Ethernet Shield Ground, +5V from Arduino Ethernet Shield, Data from Digital Out 9.
    Transmitter: Ground from Arduino Ethernet Shield Ground, +5V from Arduino Ethernet Shield, Data to Digital IN 2 (as needed for Interrupt).

    But i don’t receive anything. And, what makes me begging for help, it seems as i couldn’t send anything. It don’t own any oscilloscope, so i simply attached an LED with 220Ohm resitor insted the transmitter’s Data and i can see it flashing when trying to send.
    Am i missing something or is there any thing i could check???
    Many thanks.

  9. hi, i receive a raw code (like 7115, 925, 600, 925, 600, 925, 600, 430, 1100, 925, 600, etc etc). Now, what i must to do TO send this command as „raw“? thanks. Excuse My band english ( i am Italian boy).

  10. Super Projekt hier. Ich hab mir gerade was gebaut, mit dem ich von einer Webseite (php) ohne Ethernetshield die Dosen an und aus machen kann. Nun habe ich auch noch Intertechno Funksteckdosen hier rum liegen.
    Die Intertechno steuere ich ja so an:

    RCSwitch::switchOn(‚a‘, 1, 2);

    Ich hab mit die Steckdose angesehen, da ist hinten ein Stellrad. Dort kann ich in jeweils 4 Quadranaten (A,B,C,D) jeweils die Zahlen 1 bis 3 einstellen.

    Ich nehme an der Quadrant entspricht dem ersten Parameter in der switchOn funktion, also dem kleinen a. Der zweite der Zahl die ich im Quadranten einstelle, aber was sagt die dritte Zahl aus?

    Vielleicht kann mir da jemand helfen?
    Danke!

  11. Sorry, I don’t speak German, but…

    If you look at RCSwitch.cpp

    void RCSwitch::switchOn(char sFamily, int nGroup, int nDevice)

    3rd parameter is „device“

    However, if your socket only has 1 control e.g. A,B,C or D, perhaps you need to use the switchOn command with just 1 parameter

    Please post the model number and a link to the product.

  12. Its impossible to know what code to send to this socket without either taking it apart or using a reciever module to listen to what data is being sent.

    If you have an eletronics background and can take the socket apart, you could look at the connections to the encoder chip from the „Wheel“ and work out from the data sheet, what data it would send.

    If you have a reciever module, you can use it with the receiver sketch to determine exactly what codes are sent.

    Alternatively, the other way is „trial and error“
    e.g. set the socket to A1, then try

    switchOn(0,0)

    and
    switchOn(1, 1)

    or write a couple of „for“ loops to try all the basic combinations, (waiting 1/2 sec between each),

  13. ok thanks.
    i am going to do a „trial and error“ with „for loops“ making sense.
    I will write another post if i found out that the library is working with this intertechno modul.

  14. Habe ein CRM1000 von Intertechno mit Stellrädern.
    1 Rad für Familie 2. Rad für Device

    Eingestellt habe ich Familie A und Device 1
    Hat schon jemand das zu laufen gebracht.
    Egal was ich sende (‚a‘,1,1) oder (‚a‘,0,0) oder (‚a‘,1)
    Nicht brachte den Erfolg.
    Übrigens benutze ich die Lib 1.21

  15. Jason Dalli :
    I am using the same model with the same chip transmitter receiver like you have used in the images using rotary switches. I have connected the DOUT to the corresponding output, also I am seeing the LED flickering when the arduino is send the commands to the transmitter but the outlet is not switching on.

    Same here. The 5V power coming from the USB/Arduino is too low. I verified by soldering just the power cables to the battery pins, and by pressing the keys on the remote control. It does not work. When I insert the 12V battery, everything is fine. I used the Conrad „Hand Transmitter Model no.: RSL366T“

    I am getting a RF module now, hopefully the 5V are sufficient with that.

  16. Addition: Of course if you insert the battery, remove the USB/Arduino power first in order not to damage the Arduino/USB port!

  17. hi,
    thanx for lot of effort invested in this project.

    i would like to hack int receiving transmissions from Wireless PIR Sensor.
    I found one on eBay: http://www.ebay.com/itm/433Mhz-Wireless-PIR-Motion-Sensor-Detector-1-5M-3-3M-4-7M-for-Alarm-System-/290627751375?pt=BI_Security_Fire_Protection&hash=item43aac38dcf#ht_4456wt_1165

    I managed to find that they are using SC2262 encoder and can clearly see jumpers on the board for sensor ID settings.
    can we hack into receiving end and recognize output of this sensor with your library.
    then it can be used to trigger lights/device on with PIR sensor and as a part of security system with low cost sensors.

    Regards,
    DiNo

    P.S. i am working on netduino and trying to migrate receive part to c#

  18. Hi, I have a question :
    I want to use my raspberry pi to control these sockets but only using high and low outputs. How should I connect the 4 wires to the remote ?
    Thank you very much 🙂

  19. Hi,

    First thanks for a fantastic library. I seem to have switch (aldi australia outdoor powerpoint) that accepts codes that are longer than 32 bits. I have hacked (and I do mean horribly hacked, this bitwise stuff has been long forgotten by me!)

    The remote seems to send
    Deccimal l: 46729617502847 (47Bit) Binary: 01010101000000000010110010000000111001001111111000000000000000000

    The decoding seems to work and I am able to verify it against my manual transcription of the waveform via a sound card.

    0 ————-____________

    1 ————————-_____________

    I would like to resend the code but I am a little confused how the following bit of C could be extended to work with unsigned long long (64bit)

    char* RCSwitch2::dec2binWcharfill(unsigned long Dec, unsigned int bitLength, char fill){
    static char bin[64];
    unsigned int i=0;

    while (Dec > 0) {
    bin[32+i++] = ((Dec & 1) > 0) ? ‚1‘ : fill;
    Dec = Dec >> 1;
    }

    I am sure it’s trivial, but the arcane c syntax has fried my brain! I tried the obvious and replaced 32 with 64 + unsigned long long Dec, this does not produce the expected result (00000000000000000010110010000000111001000100111)

    😦

    • I suspect the issue is that the value it sends is being passed in as unsigned long

      unsigned long Dec

      Which is 32 bits not 64 bits

      Youd need to pass 2 unsigned longs or something else, and then fill in the array in two passes i.e one for each of the 32 bits in the unsigned long

      • Thanks for your suggestions.

        I gave it a go and rewrote to use 64bit long long (this is big enough for my needs) I can’t get my head around the original code but I rewrote it in my simplistic way.

        I am sure it’s nowhere near as efficient (with all my hacks the memory is huge for the modified library) Arduino really does not like unsigned long long for Serial.print.. luckily found a routine to print them.

        The good news everything works! Seeing a lamp switch on & off has never been so exciting:-)

        I will try to tidy everything up & send a copy of the code with my „protocol 4“ added if it would benefit anyone else..

        char* RCSwitch2::dec2binWcharfill2(unsigned long long Dec, unsigned int bitLength, char fill){
        static char bin_string[65];

        for (int i=0;i 0)
        bin_string[bitLength] = ‚1‘;
        else
        bin_string[bitLength] = ‚0‘;
        Dec = Dec >> 1;
        }
        while (Dec != 0);

        return bin_string;
        }


  20. char* RCSwitch2::dec2binWcharfill2(unsigned long long Dec, unsigned int bitLength, char fill){
    static char bin_string[65];

    for (int i=0;i 0)
    bin_string[bitLength] = '1';
    else
    bin_string[bitLength] = '0';
    Dec = Dec >> 1;
    }
    while (Dec != 0);

    return bin_string;
    }

  21. Being extremely Noob but since I happen to have the exact same harware and a Raspberry Pi, I still want to ask you guys if I somehow can use my Pi to control the switch? I would like to have the webcontrol feature. Any ideas, anybody?

  22. Hi

    Im trying to decode or at least replicate a rf signal for a remote to a switch powerplug.

    I have captured the signal with a SDR (tv tuner) with the rtl_433 linux commandline tool.

    but I cant figure out the 4 groups you mentions , 0, 1 , F ,S.

    I have tried the RCswitch and the newremoteswitch, and the remoteswitch but none of these recognize the rf signal.

    here is the output:

    ** signal_start = 573180, signal_end = 721237
    signal_len = 148057, pulses = 282
    Iteration 1. t: 203 min: 94 (134) max: 313 (148) delta 2221
    Iteration 2. t: 203 min: 94 (134) max: 313 (148) delta 0
    Pulse coding: Short pulse length 94 – Long pulse length 313

    Short distance: 215, long distance: 570, packet distance: 1763

    p_limit: 203
    bitbuffer:: Number of rows: 5
    [00] {151} 65 1d b8 32 8e dc 19 47 6e 0c a3 b7 06 51 db 83 28 ed c0
    [01] {33} 2e 0f fa d3 00 : 00101110 00001111 11111010 11010011 0
    [02] {33} 2e 0f fa d3 00 : 00101110 00001111 11111010 11010011 0
    [03] {33} 2e 0f fa d3 00 : 00101110 00001111 11111010 11010011 0
    [04] {32} 2e 0f fa d3 : 00101110 00001111 11111010 11010011

  23. forgot to mention, its measured with a samplerate at 250k.

    and the powerplug is a Sartano 81085 and the remote is a Sartano 50080.
    from the danish Harald-nyborg shop.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s