In this post we are going to see how to copy a 315/433Mhz radio frequency device with a processor like Arduino. A (worryingly) simple process that can be useful on many occasions.
315 or 433 Mhz RF devices are very common, for example, in some wireless remote controls (some air conditioners), lighting control, in cheap sensors and alarms, among others.
Copying a 315/433Mhz RF device can be of interest on multiple occasions, such as being able to act on a machine that has an RF remote control remotely (WiFi), add a timer, or integrate them into a home automation or IoT installation.
Another interest is being able to capture the signals from RF sensors (for example, those from the cheap alarms we have mentioned). These sensors are very cheap and are highly optimized to operate with batteries for several years. Reading them allows us to easily add sensors to our home. For example, we can add a motion sensor, door sensor, or window sensor to turn on a light.
However, we already warn you that it is not going to work with all remotes. In particular, it will not work with those remotes with higher security (for example, garage door remotes) that use security mechanisms like the Rolling Code, precisely, so they cannot be copied.
In some countries, it is illegal to clone RF devices (even if they are your own). Check the current legislation in your country before applying the content of this post.
Cloning a 315/433 RF Device
The procedure for copying a 433Mhz RF device is very simple. We will only need a 1-2€ transmitter and receiver, as we saw in the post Wireless Communication in Arduino with 433Mhz RF modules.
The result will be much better if we use a CC1101 as we saw in this post that operates at 3V3, so it is especially suitable for projects with the ESP8266 and ESP32.
To be able to read the data sent by the RF device we will use the RCSwitch library available at https://github.com/sui77/rc-switch/. For it to work, we must connect the data output of the receiver to pin D2 of Arduino, since the library uses interrupts to detect the code.
We open the ReceiveDemo_Simple example of the RCswitch library and load it into Arduino. Next, we operate the RF device (press the button, trigger the sensor, etc), and we will see the output as follows.
If we have not added an additional antenna (they cost a few cents) we may have to put the receiver very close, less than 10cm.
That’s how easy. That is the code that your device sends when triggered. Now we can create a Sketch that checks the received code with those of our devices, to perform the actions we want when we operate the RF device.
Emulating a 315/433 RF Device
If we now want to “act” like the remote, we just have to load the following Sketch, and change the data for what the RF device has sent in the previous section.
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
// Replace with your code
unsigned long code = XXXXXXXX;
void setup()
{
Serial.begin(9600);
mySwitch.enableTransmit(2);
}
void loop()
{
mySwitch.send(code, 24);
delay(200000);
}
When running the Sketch, the Arduino will send the same code as the original device, and the same actions will be performed. That easy!
As we can see, it is very easy to clone and emulate a 315/433Mhz RF remote with a processor like Arduino (almost scary, right?). And for this reason, one should never trust something that really requires security in these simple 315/433Mhz remotes, anyone can copy them in seconds.
However, it is a very useful functionality when it comes to home automation, converting existing devices into IoT, or adding wireless sensors to your project.
Download the code
All the code from this post is available for download on Github.