433Mhtz RF communication between Arduino and Raspberry Pi: Arduino as receiver

In a previous post I explained how to communicate between Arduino and Raspberry Pi via 433Mhtz devices. In this previous post, Arduino is used as emitter and Raspberry is used as receiver.

This new post will explain how to use Arduino as receiver and Raspberry Pi as emitter. First clues can be found on another post I did about controlling D.IO devices with Raspberry PI.

Price: Less than $85


Needed Hardware.


Arduino Uno

Price: less than $30 (Amazon)


Raspberry Pi


Price: less than 50$ (Amazon)

Mine is a B Model


433Mhz RF link kit

Price: less than 5$ (Amazon)

Library chosen to use 433Mhtz devices

As explained here I chose to use RCSwitch library because of the Raspberry Version. And this lib is directly compliant with a lot of RF standard devices:

Raspberry connected as emitter

First we have to connect the emitter to the Raspberry Pi. As a receiver has already connected to my Raspberry PI here. Here is the full schema of connection.

RPi copie


System installed on the raspberry is supposed to be  Raspbian system.

You’ll also need to install  wiringPi. This lib allow to manage easily Raspberry GPIO.

pi@raspberrypi ~ $ git clone git://git.drogon.net/wiringPi
pi@raspberrypi ~ $ cd wiringPi/wiringPi
pi@raspberrypi ~/wiringPi/wiringPi $ sudo su
root@raspberrypi:/home/pi/wiringPi/wiringPi# ./build

Now wiring Pi is installed,  you can check the build with a simple command giving state of each Pin on the GPIO:

pi@raspberrypi ~ $ gpio readall
| 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  |

Now you should clone 433Utils project onto your Raspberry:

pi@raspberrypi ~ $ git clone https://github.com/ninjablocks/433Utils.git
pi@raspberrypi ~ $ cd 433Utils/RPi_utils

The interesting part for this tutorial is codeSend.cpp. Here is the code of this program. It sends a code via RF emitter plugged on pin 0 of the Raspberry Pi. look at https://projects.drogon.net/raspberry-pi/wiringpi/pins/ for pin mapping.

 'codesend' hacked from 'send' by @justy
 - The provided rc_switch 'send' command uses the form systemCode, unitCode, command
   which is not suitable for our purposes.  Instead, we call 
   send(code, length); // where length is always 24 and code is simply the code
   we find using the RF_sniffer.ino Arduino sketch.
 Usage: ./codesend decimalcode
 (Use RF_Sniffer.ino to check that RF signals are being produced by the RPi's transmitter)
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
    // This pin is not the first pin on the RPi GPIO header!
    // Consult https://projects.drogon.net/raspberry-pi/wiringpi/pins/
    // for more information.
    int PIN = 0;
    // Parse the firt parameter to this command as an integer
    int code = atoi(argv[1]);
    if (wiringPiSetup () == -1) return 1;
    printf("sending code[%i]\n", code);
    RCSwitch mySwitch = RCSwitch();
    mySwitch.send(code, 24);
    return 0;

Now we need to build the code

pi@raspberrypi ~/433Utils/RPi_utils $ make codesend
g++   RCSwitch.o codesend.o -o codesend -lwiringPi
pi@raspberrypi ~/433Utils/RPi_utils $

Done. We built utility to send code via our RF emitter. Now let’s make the Arduino part


On the Arduino we have to listen on the RF receiver in order to get the command. We plugged data from the receiver to the first interrupt pin : PIN 2



Now it’s time to code onto the Arduino. An exemple is given into 433Mhtz.

  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 inerrupt 0 =&gt; that is pin #2
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() );

Making it work

Now it’s time to send command via the Raspberry pi

pi@raspberrypi ~/433Utils/RPi_utils $ sudo ./codesend 1233434
sending code[1233434]
pi@raspberrypi ~/433Utils/RPi_utils $ sudo ./codesend 128899
sending code[128899]
pi@raspberrypi ~/433Utils/RPi_utils $ sudo ./codesend 34689
sending code[34689]
pi@raspberrypi ~/433Utils/RPi_utils $ sudo ./codesend 390678
sending code[390678]
pi@raspberrypi ~/433Utils/RPi_utils $

And here is the output of the arduino

Received 1233434 / 24bit Protocol: 1
Received 128899 / 24bit Protocol: 1
Received 128899 / 24bit Protocol: 1
Received 128899 / 24bit Protocol: 1
Received 34689 / 24bit Protocol: 1
Received 34689 / 24bit Protocol: 1
Received 34689 / 24bit Protocol: 1
Received 34689 / 24bit Protocol: 1
Received 390678 / 24bit Protocol: 1

Yes done !!!

Capture d’écran 2014-03-02 à 14.32.19







  1. Nice article, i am working on the project which requires the arduino to send data to raspberry pi, but i am using wifi for them as both points are not in line of sight, can you tell me whats the maximum distance i.e. range it can transfer data ?


  2. Hi there, thanks for your nice work. I have a question, what is the maximum distance signal transmission between rasberry pi and arduino with the 433Mhtz RF module?

      • Hi,
        Good tutorial.
        I’ve been transmitting 433 from my pi for a while now but I’m struggling with distance, I’m using only a 5v pin. Do you know the best way I can go about boosting the transmit range? I’ll need to run the transmitter at 12v but not sure how to go about it, If I step up to 12v do I need to step back down again or will my pi handle it?

  3. Hello,

    i want to connect my Arduino UNO with the transmitter and the emitter, and have the following problem, PIN 2 & 10 and some others are in use.
    On which Pins can I still connect them?

    Is the Pins number of the same which i must write in the program?
    Because PIN 2 have in the programm the number 0.


  4. Hii
    I am trying send data from raspberry pi to arduino.
    to achieve this, i tried to clone 433Utils form Github, unfortunately it shows some FATAL error. so i downloaded code from https://code.google.com/p/rc-switch/

    and created a Makefile and codeSend.cpp
    But i got an error that WProgram.h not found. i guess it mean that compiler is not detecting ARDUINO (#if defined(ARDUINO) && ARDUINO >= 100)
    kindly suggest how do i solve this error????

  5. Hi,
    Is it possible to use these chips with a USB into Windows laptop without these boards? Any pointers?
    Apologies for the basic question.

  6. I have tried to implement the above circuit but the arduino shows no output where as the raspberry pi is working. I have tried every thing also changed the receiver module but still the same response. Kindly help me out

  7. Bonjour,

    Sur Raspberry, tout s’install correctement mais lorsque j’envois la commande “sudo ./RFSniffer” dans le repertoire “433Utils/RPi_utils” pour recevoir les codes je n’ai rien qui ce passe, j’ai installer une led sur mon recepteur qui clignote bien lorsque j’envois un signal. Mais je n’ai aucun code qui s’affiche et j’ai mon raspberry qui tourne à 100% CPU obliger de fermer le terminal pour arreter…
    Si qqun as une solution sa serrais vraiment top.
    Je suis sur raspberry B+

  8. Hello,

    On Raspberry , everything is installed correctly but when I mail the command “sudo ./RFSniffer ” in the directory ” 433Utils / RPi_utils ” to receive the codes I have nothing ‘s going on , I install a LED on my receiver flashing good when I mail a signal. But I have no code that appears and I have my raspberry rotating at 100% CPU force to close the terminal to stop …
    If qqun as a solution really gritted his top .
    I’m on raspberry B +

  9. Hy,
    Nice job Vincent!
    But it doesn’t work for me.
    Nothing appears from the Arduino. I have tried with different remote but still not working! The recepter is wiring to the 2 PIns on the arduino.
    I used a Raspberry Pi B+ and a Arduino Mega.
    Is anyone got it working on a B+?
    Arfff!! J avoue que je ne vois pas le bug.
    Merci a toi

  10. Great work, thanks for sharing it!
    Although I have one question, when I look into the ~/433Utils/RPi_utils directory, all I can see is a file with .o extension and I would like to see the .py file. Is there any way to see it?
    Thanks in advance

  11. I wanted to do the same thing but connecting the raspberry pi and a wireless door sensor using an rfm69 module is there any way you could hint me where yo start from?

  12. Hello there
    I succeeding in replicating the above design and it worked perfectly.

    Now i need, to use the commands from within a Python to send commands to the Arduino based on user inputs, but i am not able to do it yet.

    can you please advise what should need to be done from within the Python Shell on the Raspberry in order to send the same commands?

    Can I see a sample code? (libraries needs to be included, how to issue the commands from within the Shell…)


  13. Hi Vincent,
    I’m able to replicate your demo, but the issue is always receive multiple time on Arduino. Like once send 1 message on Raspi, then on Arduino side will receive 3 or 4 message as the same.
    Do you have any idea?

      • Hi Rob,
        I’m just starting to play with the 433MHz Pi to Arduino Nano. I find I have the exact same problem as you and Dai. Pi sends a single integer and the Arduino repeats the integer several times (1 to 4 times).
        Have you found out why this happens?

  14. Hi.

    Im trying to implement convulotional codes in a communication between 2 RPi.

    And im using that 433 modules.

    Is there any possibility the receiver recive any wrong values distorced in channel?


  15. Hello!

    Nice work.. But I’ve got a problem here. Nothing works. I’d like to mail u all the details. Please help me out with this basic.

    I followed each and every step of urs but no luck.

    I’ve got arduino uno and raspberry pi 3.

    The code on raspberry pi terminal works fine. But the arduino displays no output.
    No interruptions detected at arduino’s end.

    Please help.

  16. i want to make a smart plug ,for that i need to connect my smart plugs (more than one arduino ) to raspberry pi board which i need to acts as an hubstation how do i connect it wirelessly

  17. At last!
    I was looking for methods of decoding the unknown RF remote control. Unfortunately, no positive effect. Fortunately, I came here and using this sketch I did it! It works!!
    Thank You!

  18. Hi,
    I´m pretty new to the Raspberry Pi so that I was wondering how or even if the “codesend” code is written on the Pi or the code is just build like you described in the guide?


Leave a Comment.