Decode and Send 433 MHz RF Signals with Arduino

This guide shows how to use an Arduino to decode 433 MHz signals from RF remotes, and send them with an Arduino and a 433 MHz transmitter to remotely control mains switches outlets.

Why Decoding RF Signals?

I’ve tried different methods of controlling the mains voltage, but some of the methods require:

  • Experience dealing with AC voltage
  • Opening holes in your wall/ceiling/switches
  • Modifying the electrical panel
  • Knowing the electrical rules for each country

It’s difficult to come up with a solution that is safe and works for everyone. One of the easiest and safest ways to remotely control appliances connected to mains voltage is using radio frequency (RF) controlled outlets. Why? Using remote controlled outlets have 5 benefits:

  1. Fairly inexpensive
  2. Easy to get
  3. Works with ESP8266 and Arduino
  4. Safe to use
  5. Works in any country

Parts Required

For this tutorial, you need the following parts:

Note: you need to buy remote controlled outlets that operate at a RF of 433MHz. They should say the operating RF either in the product page or in the label.

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Example

Here’s how they look:

Setting the RF Channels

I’ve set my remote control to the I position.

The outlets must be both on the I position. I’ve selected channels 3 and 4 for the outlets (you can use any channel you want).

If you plug them to an outlet, you should be able to control the remote controlled outlets with your remote control.

Installing the RC Switch Library

The RC Switch library provides an easy way of using your ESP8266, ESP32, or Arduino to operate remote radio controlled devices. This will most likely work with all popular low-cost power outlet sockets.

  1. Click here to download the RC Switch library. You should have a .zip folder in your Downloads folder
  2. Unzip the .zip folder and you should get rc-switch-master folder
  3. Rename your folder from rc-switch-master to rc_switch
  4. Move the rc_switch folder to your Arduino IDE installation libraries folder
  5. Then, re-open your Arduino IDE

Opening the Decoder Sketch

You need to decode the signals that your remote control sends, so that the Arduino or ESP8266 can reproduce those signals and ultimately control the outlets.

The library comes with several sketch examples. Within the Arduino IDE software, you need to go to File > Examples > RC_Switch > ReceiveDemo_Advanced. This next sketch opens:

/*
  Example for receiving
  
  https://github.com/sui77/rc-switch/
  
  If you want to visualize a telegram copy the raw data and 
  paste it into http://test.sui.li/oszi/
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
}

void loop() {
  if (mySwitch.available()) {
    output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());
    mySwitch.resetAvailable();
  }
}

View raw code

You must open the example using File > Examples > RC_Switch > ReceiveDemo_Advanced, so it automatically also loads the output file.

Having an Arduino board connected to your computer follow these instructions:

  1. Go to the Tools tab
  2. Select Arduino UNO board
  3. Select the COM port
  4. Press the Upload button.

Decoder – Schematics

After uploading the sketch, connect an 433MHz RF receiver to Digital Pin 2 of your Arduino UNO board:

Decode RF Signals (codes)

Open the Arduino IDE serial monitor and start pressing the buttons. As shown in the video demonstration below:

After pressing each button one time, you can see the binary code for each button (it’s highlighted in red):

Save your binary codes for each button press (you can also use the Decimal or Tri-State codes):

  • Button 3 ON = (24Bit) Binary: 000101010101000101010101
  • Button 3 OFF = (24Bit) Binary: 000101010101000101010100
  • Button 4 ON = (24Bit) Binary: 000101010101010001010101
  • Button 4 OFF = (24Bit) Binary: 000101010101010001010100

Save your Pulse Length: 416 Microseconds and Protocol: 1.

Send the RF Signals (codes)

You’ll need to customize the next sketch with your binary codes, pulse length and protocol:

/*
  Based on the SendDemo example from the RC Switch library
  https://github.com/sui77/rc-switch/
*/

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  
  // Transmitter is connected to Arduino Pin #10  
  mySwitch.enableTransmit(10);

  // Optional set pulse length.
  mySwitch.setPulseLength(REPLACE_WITH_YOUR_PULSE_LENGTH);
  
  // Optional set protocol (default is 1, will work for most outlets)
  mySwitch.setProtocol(REPLACE_WITH_YOUR_PROTOCOL);
  
  // Optional set number of transmission repetitions.
  // mySwitch.setRepeatTransmit(15);
}

void loop() {
  // Binary code - button 3
  mySwitch.send("000101010101000101010101");
  delay(1000);  
  mySwitch.send("000101010101000101010100");
  delay(1000);
  
  // Binary code - button 4
  mySwitch.send("000101010101010001010101");
  delay(1000);  
  mySwitch.send("000101010101010001010100");
  delay(1000);
}

View raw code

In my case, the pulse length and protocol looks like this:

// Optional set pulse length.
mySwitch.setPulseLength(416);
 
// Optional set protocol (default is 1, will work for most outlets)
mySwitch.setProtocol(1);

Here’s a binary sender example (you have to replace with your own binary codes):

mySwitch.send("000101010101000101010101");

Sender Schematics

After uploading the sketch to your Arduino board, assemble this circuit:

Both of your outlets should be turning on and off continuously.

Wrapping Up

I hope you’ve found this guide useful. If you like this post probably you might like my next ones, so make sure you subscribe the RNT blog.

You can use the concepts learned in this tutorial with your ESP8266 or ESP32.

Thanks for reading.



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

54 thoughts on “Decode and Send 433 MHz RF Signals with Arduino”

  1. Thanks for doing all of this work both for this project and all of the other projects you do. It helps the rest of us who don’t know how to do this,but want to learn.
    Again thanks

    Reply
  2. I’ve designed a same circuit and uploaded the program in Arduino UNO which is mentioned above. I am not seeing any output in serial monitor. Could you please tell me the type of receiver you’ve used and what other rf receivers I can use. Thank you… Hope to see your reply soon…

    Reply
    • Hello Ruturaj, some of those inexpensive RF transmitter/receivers don’t work or come defective. Can you try it with a new receiver? If it still doesn’t work, it means that your remote controlled sockets might not be operating at 433MHz or that they aren’t compatible with the RC Switch library…

      Reply
  3. Hi Sara. Thanks for sharing this
    I got the same problem as Frank : “undisplayed signs”?
    Im getting this error: exit status 1
    ‘output’ was not declared in this scope

    Any ideas? Thanks 🙂

    Reply
  4. Ciao e buon anno!
    Articolo interessante, grazie a voi per averlo condiviso. Chiedevo se è possibile copiare anche radiocomandi per apertura garage a 433mhz. Inoltre, chiedevo se questo codice di può usare con nodemcu. Grazie.

    Hello and happy new year!
    Interesting article, thanks to you for sharing it. I asked if you can also copy radio controls for the garage opening at 433mhz. Also, I was wondering if this code can use with nodemcu. Thank you.

    Reply
  5. Hi, im a complete noob at this, but im trying to build a system that works kind of like a garage door, just that instead of opening the garage it just powers a LED light. It’ll work as a visual notification to my deaf grandma, that someone has arrived to visit. Will this work for me? or there is another tutorial more in line with my situation? Also what range is this 433 Mhz functional?
    Thanks, sorry for my long message.

    Reply
  6. Yaay, wonderful! 🙂

    Just tested it with a generic module bought from Jaycar in Australia. I had to set the setPulseLength value to 10 and it was immediately picked up my my Sonoff RF Bridge running Tasmota. This is great. Thank you so much for making your code available to the world!

    Reply
  7. Hi, thanks for this tutorial. I am trying to capture 433MHz codes from remotes that control window blinds. The receiver/transmitter components I have look like the ones in your pictures. I’m pretty sure the receiver is connected correctly, and the sketch is uploading correctly to my Uno device. But nothing registers when I press the buttons on the remote.
    I have been able to grab codes successfully using the exact same receiver connected to a Raspberry Pi (using pigpiod/piscope). But the Arduino sketch isn’t picking anything up.
    As a test I added an “else” to the if statement in the loop to spit out a character on serial every 32760 iterations. It appears continuously.
    Which suggests the board isn’t seeing any output from the receiver. I’ve tried both 5V and 3.3V power (3.3V worked OK on the Pi).
    Any suggestions?

    Reply
    • Hi Mark.
      Without further information, it is very difficult to find out what might be wrong.
      Are you really sure the module is wired correctly? And are you sure that your remotes are powered on and sending the controls?
      Regards,
      Sara

      Reply
      • Sara, thanks for your reply. Yes, I am pretty sure the receiver module is wired correctly. I have tried with either +3.3v or +5V and ground connected to their respective pins on the module, and the signal wire going to pin 2 on the Uno,
        The remotes are unbranded but labelled DC1600 – very similar to or identical to those you can see here: https://fccid.io/2AIDK-DC1600F/User-Manual/User-Manual-3024928 They are controlling blinds rather than remotely switchable sockets, but they definitely operate on 433MHz, so I’m guessing RCSwitch should be able to handle them – or is that an assumption too far?
        I know the remotes are working because the blinds respond when I press the buttons, yet nothing appears on the IDE serial monitor. I know the sketch is loaded because some print statements that I added appear.
        FWIW the signals I was seeing in piscope were like this: pressing each button results in a series of continuously repeated patterns for as long as a button is pressed. Each repetition lasts about 50ms, starting with a LOW of 8.825ms duration, then HIGH approximately 4.75ms, followed by LOW of 1.5ms, Subsequent transitions, which I took to be binary digits 0 and 1, were either short HIGHs of around 0.3ms followed by LOW of 0.78ms; or HIGH of 0.65ms followed by LOW of 0.44ms – I assume these were 0 and 1 respectively. In all there are 40 binary digits in each repetition. (NB my timings may be a bit off, I was using a very old, 1st gen Raspberry Pi.)
        An example of one complete sequence with one of the remotes – an UP command – was 0111 0100 0100 0100 1011 1001 0111 0001 0001 0001. There seem to be 32 bits that characterise the remote, then 8 bits of command, consisting of the same four bits repeated. 0x11 for UP, 0x33 for DOWN, and 0x55 for STOP.

        Reply
        • Mark. Did you manage to get the DOOYA DC1600 to work with this?
          I am facing the exact same problem at the moment and cannot get these remotes to work.

          Reply
  8. Hi and Thanks for sharing this. It is first time I do this and I am totaly new in this , but everething works as it is explained. But how to turn on/off the light with arduino?

    Reply
  9. Hello,

    I am curious if it might be possible to collect data from multiple devices (tipping-bucket rain gauges) from Acurite that work on 433mhz system. If so, would it be possible to identify which device the signal came from and how many devices could be used at one time? I’m wanting to put these out in a grid pattern to monitor irrigation application rate/distribution on turfgrass systems. Any help you might be able to give would be greatly appreciated!

    Thank you!

    Jason

    Reply
  10. Is it possible to make RCSwitch to send only one burst of one code on rising and burst of another on falling interrupt or button high or low. I can make it work, but rc switch keeps sending constantly.

    Reply
  11. I wonder if the plugs you listed have changed, I followed the direction and everything uploaded fine, I can even hear the transmitter sending the signal (from my cheap speakers)
    but the is not turning on or off, it does with the remote.
    the plugs I got were https://www.amazon.com/gp/product/B00DQ2KGNK/ref=ppx_yo_dt_b_asin_image_o02_s00?ie=UTF8&psc=1

    I am using the Arduino Uno R3

    and these are the wireless transmitter/Receivers I got.
    https://www.amazon.com/gp/product/B076Q64MBQ/ref=ppx_yo_dt_b_asin_image_o02_s00?ie=UTF8&psc=1

    Reply
  12. Hi there, first of all, thanks so much for this tutorial. very helpful, and I can have a quick start working with arduino and Raspberry.
    Still, I experience the same problem as Mark Scott. I loaded the sketch, opened the monitor, pressed several buttons on my Klikaanklikuit (Clickonclickoff) but nothing happens.
    Before I had everything hooked up on the RPi 3, and that worked fine. I followed all the steps, and my my transmitter works, as the connected receiver switches the light to ‘on’.

    can you please help me out here?

    Thanks in advance, James

    Reply
  13. Hi there, this is James again.

    I’ve been trying to get my earlier problem solved. I still experience an issue.
    Now it seems that I do get output on the monitor, but with a hugh delay!!
    So the hardware indeed works, an is correctly connected, but there is a delay in presenting the data. Can you please help me out??

    can you please help me out here?

    Thanks in advance, James

    Reply
  14. Hi There,

    I still am stuck on receiving data from the receiver. (that is: getting it displayed in the monitor. As I said before, to make sure the receiver works, I connected all on the RPi 3B, and that works fine. But connected on the Arduino Uno, nothing appears on the monitor.
    Adding some statements to the coding proves, that the boolean remails false! So the receiver actually sends nothing to pin nr. 2

    Please help me out so I can get progress.

    Thanks in advance,

    James.

    Reply
  15. I brought an electric projector screen for my cinema room and have used this successfully to remotely raise and lower the screen

    Good work!!

    Reply
  16. Hello. Nice project and very professional. Thanks for sharing.

    Just a question:

    What is the way to prevent people (hackers) can decode signals from RF transmitters?

    Thanks.

    Reply
  17. Attempting to utilise a key fob . two of the buttons “lock ” & ” unlock ” have the same details apart from the Rawdata.
    To get the Value I use … Serial.print(“Received “);
    Serial.print( mySwitch.getReceivedValue() );
    which gives me the value to compare.
    It does not compile for the raw data….Serial.print(“Rawdata: “);
    Serial.println( mySwitch.getReceivedRawdata() );
    Hope you can help ?

    Reply
      • Obtained no matching function for call to ‘print(unsigned int*)’

        Complete code below…At the end greyed out is a development that will compile but comes back with raw data of 53 for all buttons…..Serial.print(“Raw data: “);…………………………………..

        /*
        Simple example for receiving

        https://github.com/sui77/rc-switch/
        */

        #include <RCSwitch.h>

        RCSwitch mySwitch = RCSwitch();
        unsigned int* raw;//raw
        unsigned int length;
        unsigned int i;
        void setup() {
        Serial.begin(9600);
        mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
        }

        void loop() {
        if (mySwitch.available()) {

        Serial.print("Received ");
        Serial.print( mySwitch.getReceivedValue() );
        Serial.print(" / ");
        Serial.print( mySwitch.getReceivedBitlength() );
        Serial.print("bit ");
        Serial.print("Protocol: ");
        Serial.println( mySwitch.getReceivedProtocol() );

        Serial.print("Delay : ");
        Serial.println( mySwitch.getReceivedDelay() );

        Serial.print(“Raw Data : “);
        Serial.println( mySwitch.getReceivedRawdata() );

        /*

        Serial.print("Raw data: ");

        for ( i=0; i<= length*50; i++) {//2
        Serial.println(raw[i]);//raw
        // Serial.println(“,”);
        */
        mySwitch.resetAvailable();
        }
        }
        }

        Reply
  18. Hi.
    Thank you for your hard work in producing this project. I have been trying to get it to work but with out any success. I have tried with 3 different transmitters using a key fob and a central heating digistat as these are the only RF devices I can find. But neither of them work. My goal is to capture the code of the digistat and use it to program other room thermostats. Presumably, the chipsets of my devices are not compatible with rc-switch. Is there an updated list at all or is there any way around my problem? Also, is there a way of telling if a transmitter is working correctly?
    Thanks again for your hard work and thank you in advance for your help.
    Bob May

    Reply
  19. Hi. I’m trying to make a receiver. I can capture the code from my transmitter and trigger a relay with arduino, but it also triggers when ANY other transmitter is used nearby (neighbours etc). How can I specify that only a certain code will trigger. if(this code){turn on relay;}??

    Reply
  20. Hello,
    I am very interested in trying to find out the information from my 433 MHz remote, but I cannot get this to provide any output in the Serial Monitor. I am using ESP32, I have tried multiple different boards, changed the GPIO pin and the code, used several different receivers and still no luck. Can you please give ideas to get this to work, or does it not function correctly on ESP32?

    Reply
  21. HI Sara Santos,

    I need some help from you it is not wrt to this project , I am building an RF transmitter using Arduino board and 433Mhz FSK RF transmitter. I am sending the binary or bytes which i need to transmit through RF board through Arduino using python. the data I am sending serially is in Manchester fromate. But when i check Tap the RX pin on the Arduino board I am not getting the same data what I am transmitting. ANy suggestion on this will help a lot .

    Reply
  22. This was the fastest I have ever gotten a project to work from a tutorial. Less than 10 minutes from plugging in some wires to having this working perfectly. Thank you!

    Reply
  23. Hello, I have received the binary codes for my remote control using a receiver module, and now I intend to send the binary codes by pressing a button. However, the transmitter is not working. Could the issue be with the code I am using for the transmitter? I want to send the binary codes through the transmitter by pressing the buttons connected to digital pins 4, 5, 6, and 7 on the Arduino board. The code used is as follows:

    #include <RCSwitch.h>

    RCSwitch mySwitch = RCSwitch();

    int button1 = 4;
    int button2 = 5;
    int button3 = 6;
    int button4 = 7;

    int button_status1, button_status2, button_status3, button_status4;

    void setup() {
    Serial.begin(9600);
    mySwitch.enableTransmit(3);
    pinMode(button1, INPUT);
    pinMode(button2, INPUT);
    pinMode(button3, INPUT);
    pinMode(button4, INPUT);
    }

    void loop() {
    button_status1 = digitalRead(button1);
    button_status2 = digitalRead(button2);
    button_status3 = digitalRead(button3);
    button_status4 = digitalRead(button4);

    if (button_status1 == HIGH) {
    mySwitch.send(“001011011010011100011000”);
    } else if (button_status2 == HIGH) {
    mySwitch.send(“001011011010011100010010”);
    } else if (button_status3 == HIGH) { mySwitch.send(“001011011010011100010010”); } else if (button_status4 == HIGH) {
    mySwitch.send(“001011011010011100010010”);
    }
    }

    Reply
  24. Question- Looking for a way to receive/decode a 433 signal and convert that to TCP or OSC message- any suggestions as to where to start reading?

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.