433MHz RF communication from a Raspberry Pi

433MHz RF Communication from a Raspberry Pi

This post will explain how to get up and running with the 433MHz RF Transmitter Receiver modules to send radio frequency (RF) signal-codes from a Raspberry Pi to other connected devices. It will be updated from time to time when I stumble upon more relevant information. If you stumbled upon more relevant information, see mistakes or doesn’t understand anything, please feel free to comment at the end.


A very easy way to ‘physically’ connect the Raspberry Pi to the outside world is using its GPIO pins and the 433MHz RF Transmitter Receiver modules. What is more, it will be wireless! After following this basic tutorial, you will be able to communicate from a Raspberry Pi (connected to a 433MHz RF Transmitter module) with one or multiple devices (connected to a 433MHz RF Receiver module) using specific RF signal-codes, and for example an Arduino (which we will be using for testing purposes) or other Raspberry Pis. This post will show how to do this with a simple command-line which can then be used in Bash or Python.


Because the Raspberry Pi is quite fragile or should be considered that, I was looking for a way to use the GPIO pins without having to open up the case all the time. I ultimately developed a little RF box connected to the Raspberry Pi which can both send and receive signal-codes. This allowed me to do the initial and additional programming without interfering with the hardware. See the Related Topics for related posts.


I would like to thank Vincent Demay from Homeautomation.org for his 433Mhtz RF communication between Arduino and Raspberry Pi: Arduino as receiver article. He saved me a lot of long hours’ research for writing this post.

Requirements & assumptions

First of all, you need a fully functional Raspberry Pi with Raspbian installed. After the setup, we will be using the command line, Bash or a Python script to send the signals. If you don’t have a screen, keyboard and mouse you will need to be on a network and use PuTTY and/or WinSCP for the setup, sending of signal-codes, testing and coding.

You will also need:

These were the parts that were used. Most are available from BangGood and Amazon.com. Some direct links to some of the parts are supplied lower down.

  • At least 2 pairs of 433 MHz Transmitter Receiver units.
  • 433 MHz Spiral Spring Helical Antennas
  • Solderless developing breadboard and  some additional breadboard wiring (Arduino and Raspberry Pi compatible)
  • Functional Arduino connected to a serial monitor. An Arduino Nano was used.

Setting up the Raspberry Pi to transmit RF signals

433MHz RF Transmitter moduleIn this tutorial, the Raspberry Pi will be configured the transmitter. To do so grab the square (vs. longer) module from the 433MHz RF Transmitter Receiver module pair. wiringPi and a modified version of 433Utils will be used.

First of all, very important, get that thang antennaed. Use the official 433 MHz Spiral Spring Helical Antennas or make one by coiling a 25 cm 1 mm solid wire and soldering it into the antennae hole.

When positioning the Raspberry Pi GPIO pins facing up and on the opposite side, i.e. with the USB and Ethernet port on the right, the physical GPIO pin numbering will be as follows:

Raspberry Pi GPIO Layout Model B Plus

The pins on the 433MHz RF Transmitter module is clearly marked.

Before plugging in the Raspberry Pi, connect the breadboard wiring as follows:

  • ATAD (DATA) to physical GPIO pin number 11 (i.e. GPIO17)
  • VCC (5 V) to physical GPIO pin number 2 or 4
  • GND to physical GPIO pin numbers 6, 9 or 14

To install wiringPi git needs to be installed. The following commands can be used from the /home/pi directory:

sudo apt-get install git
git clone git://git.drogon.net/wiringPi
cd wiringPi

After wiringPi is installed, check the build at any time with this command:

gpio readall

which, if correctly installed will give the state of each pin on the GPIO:

| wiringPi | GPIO | Phys | Name   | Mode | Value |
|      0   |  17  |  11  | GPIO 0 | OUT  | Low   |
|      1   |  18  |  12  | GPIO 1 | IN   | Low   |
|      2   |  21  |  13  | GPIO 2 | IN   | Low   |
|      3   |  22  |  15  | GPIO 3 | IN   | Low   |
|      4   |  23  |  16  | GPIO 4 | IN   | Low   |
|      5   |  24  |  18  | GPIO 5 | IN   | Low   |
|      6   |  25  |  22  | GPIO 6 | IN   | Low   |
|      7   |   4  |   7  | GPIO 7 | IN   | Low   |
|      8   |   0  |   3  | SDA    | IN   | High  |
|      9   |   1  |   5  | SCL    | IN   | High  |
|     10   |   8  |  24  | CE0    | IN   | Low   |
|     11   |   7  |  26  | CE1    | IN   | Low   |
|     12   |  10  |  19  | MOSI   | IN   | Low   |
|     13   |   9  |  21  | MISO   | IN   | Low   |
|     14   |  11  |  23  | SCLK   | IN   | Low   |
|     15   |  14  |   8  | TxD    | ALT0 | High  |
|     16   |  15  |  10  | RxD    | ALT0 | High  |

Note how the physical GPIO pin numbers changes. Physical GPIO pin number 11 for example becomes GPIO 0 with wiringPi.

To install (clone) 433Utils onto the Raspberry Pi, go back to the /home/pi directory and use the git clone command again:

cd /home/pi
git clone https://github.com/ninjablocks/433Utils.git
cd 433Utils/RPi_utils

To send RF signals, use codesend.cpp. While in the 433Utils/RPi_utils directory, it can be checked it out by using:

sudo nano codesend.cpp

Nothing should be changed for now. Because the DATA pin of the 433MHz RF Transmitter module is connected, stick to wiringPi’s GPIO 0. Press Ctrl X to exit back to the terminal.

If codesend.cpp was altered in any way, it needs to be compiled again with:

make codesend.cpp

Setting up the Arduino to receive RF signals

433MHz RF Receiver moduleThis will set the Arduino up as the receiver. To do so grab the longer (vs. square) module from the 433MHz RF Transmitter Receiver module pair and get it antennaed again. On the Arduino, the RC Switch library needs to be available in the Libraries directory.

To add this library to the Arduino IDE, select the latest version of the downloaded zip-file from Add .ZIP Library… from the Include Library option under the Sketch menu.

On a Linux system (including Raspbian) the following can be used to clone the latest version of the RC Switch library directly into the Arduino IDE libraries folder:

sudo apt-get install git
cd /home/pi/sketchbook/libraries
git clone https://github.com/sui77/rc-switch.git

To prevent Java errors, rename the rc-switch directory to rcswitch:

mv /home/pi/sketchbook/libraries/rc-switch /home/pi/sketchbook/libraries/rcswitch

The pins on the 433MHz RF Receiver module is once again clearly marked. The receiver module has two DATA pins. As a rule I like to always use the one closest to GND. Connect the breadboard wiring as follows:

  • ATAD (DATA) to the D2 pin of the Arduino
  • VCC (5V) to 5V pin of the Arduino
  • GND to the GND pin of the Arduino

Connect the Arduino to the Arduino Software on a working computer and upload the following sketch to it:


  Hacked from http://code.google.com/p/rc-switch/

  by @justy to provide a handy RF code sniffer

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

void setup() {
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 > pin D2

void loop() {
  if (mySwitch.available()) {
    int value = mySwitch.getReceivedValue();
    if (value == 0) {
      Serial.print("Unknown encoding");
    else {
      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );

As is, this piece of coding makes the Arduino ‘sniff’ for RF code and if it receives it, it will be displayed on the serial monitor. The ‘bit length’ and ‘protocol’ variables will give more information about the code received. Don’t change this code too much until you are comfortable with Arduino code.

Other important things to notice here is the inclusion of the libraries and the setting up of the receiver pin D2.

Testing the communication

On the Raspberry Pi, go back to the /home/pi directory:

cd /home/pi

A code send command can be issued from the terminal by using the absolute destination of codesend:

sudo ./433Utils/RPi_utils/codesend 1233434
sudo ./433Utils/RPi_utils/codesend 4321
sudo ./433Utils/RPi_utils/codesend 9876574


These three commands will send ‘1233434’, ‘4321’ and ‘9876674’ respectively. This should be visible on the Arduino Serial Monitor. If not, try to move the Receiver Arduino closer or further away while issuing the codesend command.

About the author
Renier busies himself with improving his English writing, creative web design and his websites, photoshopping, micro-electronics, multiple genres of music, superhero movies and badass series.
Behind the Scenes is a free, informative website. If you find value in any of our content, please consider making a donation to our cause.
Donate via PayPal

Save, share & discuss

Your comment is important, but don't be a knob. Keep it constructive and polite.

Leave a Reply

Your email address will not be published. Required fields are marked *

More Raspberry Pi related posts