Getting start with rfrpi card v1.0 – rf433 for raspberry pi

rfrpi_2RfRpi card is a RF433 emitter and receiver add-on of Raspberry Pi. This card is based on high quality receiver and transmitter I have selected after tests you can find here and here. This article describes how to get start with this shield.

To buy this shield the best way is to sent me a comment on this post, the price is 60€

The Shield is now working with Raspberry PI B+ and previous versions. The Shield is also working with Raspberry PI 2+. For these two last version you need to compile a kernel driver.

 

1 – Get the shield

You can order this shield contacting me (add a comment to this post)

The shield in V1.2 (for RaspberryPI B+ / A+) looks like this:

Raspberry Pi B+ - RFRPI Shield

Raspberry Pi B+ – RFRPI Shield

The shield in V1.1 (for RaspberryPi A&B) looks looks like this (this photo is not contractual, leds & antenna particularly can differ) :

RFPRI shield - High Quality RF433 for raspberry

RFPRI shield – High Quality RF433 for raspberry

The shield is delivered with an antenna and 3 programmable leds

2 – Plug the shield

The first step is to plug the shield, no need to detail how to do it, if you are not sure, just don’t do it ! It’s you own responsibility to plug and use this shield you do it at your own risk.

Once on the RPI is looks like :

RF433 Raspberry PI shield v1.0

RF433 Raspberry PI shield v1.0

For a model B+, I recommend to use this box :

 

rpi_bplus_case

The shield has been done to fit in a raspberry pi A/B box like this one : cyntech-model-a-raspberry-pi-case-black-1-498x498So you can close it in a such box after having created the needed hole for leds & antenna.

This look like this at the end (depending of the used antenna), this photo is not contractual !

rfrpi_3

3 – Install a Raspbian image

This tutorial is based on 2014-01-07-wheezy-raspbian.zip (be careful, this link is pointing to the latest. It should be work be it should not be the one I used)

The first step is to get the zip file and flash the Sdcard with its content, you can refer to this tutorial for doing it : http://elinux.org/RPi_Easy_SD_Card_Setup

On Mac, but it is also working on Linux, in a terminal type mount (or dmesg) to identify what disk is associated to the Sdcard once plugged in. You can also use the follwoing tool:

In case the SD Card has been mounted automatically you can unmount

Then umount the partition of this disk if they have been auto-mounted.  At end, fire the flash command line :

# dd if=/path/to/the/raspbian.img of=/dev/diskX bs=1m

The flashing procedure is long, by pressing CTRL+T, you can get a status report.

Once done, plug the sdcard, connect HDMI, keyboard then power the raspberry pi.

The next steps are about basic configuration to get started.

  • From the main menu, select expand file system : this is enlarging the file system to the whole sdcard (raspbian per default in 2GB, if your sdcard is larger, this process will allow you to access space over 2GB). Just validate, raspbian will be back to this menu after expending process.
raspi-config main menu

raspi-config main menu

  • From the main menu, configure your keyboard layout (this have to be done if you are not using a standard Qwerty). Select Internationalization Options in the menu
raspi-config - change keybord layout

raspi-config – change keybord layout

Then Change Keyboard layout to match your keyboard entry.

raspi-config : change keyboard layout

raspi-config : change keyboard layout

Select you keyboard type, generally, Generic 105 key is good.

raspi-config : select keyboard layout

raspi-config : select keyboard layout

Select your language (select other for non English)

raspi-config : non english layout

raspi-config : non english layout

Select your language in the list (here french) – you have to adapt to your own language.

raspi-config : select french language

raspi-config : select french language

Now, you have a couple of screens to select specific behavior

raspi-config : select language alternatives

raspi-config : select language alternatives

raspi-config : select AltGR behavior

raspi-config : select AltGR behavior

raspi-config : select Right ALT behavior

raspi-config : select Right ALT behavior

raspi-config : select CTRL+ALT+BSpace behavior

raspi-config : select CTRL+ALT+BSpace behavior

This last step brings you back to the main menu.

 

  • From the main menu, now select Change User Password entry, you will be prompted for a new password.
raspi-config main menu

raspi-config main menu

  • From the main menu, now select Enable Boot to Desktop… entry, to select a console mode only (no need for graphical environment for our purpose)
raspi-conf : configure boot

raspi-conf : configure boot

raspi-config : select Text Console at boot

raspi-config : select Text Console at boot

  • Now, from main menu, select Advanced Options to enable SSH server
raspi-config : Advanced Options

raspi-config : Advanced Options

Then select SSH to activate server

raspi-config : active SSH server

raspi-config : active SSH server

Confirm

raspi-config : confirm SSH server activation

raspi-config : confirm SSH server activation

  • Now, the raspbian is configured, from the main menu, select Finish then reboot.
raspi-config : finishing

raspi-config : finishing

raspi-config : rebooting

raspi-config : rebooting

  •  Once the system have finished reboot, you can see the assigned IP in the console
raspi-config : assigned IP address

raspi-config : assigned IP address

  • Now, you can log to the system in the console or from the network, with default user pi and the password you set.

4 – Install the rfrpi needed libraries

Rfrpi is using wiringPI for accessing GPIO. The installation process is the following, from the raspberry command line:

# ssh -l pi 10.0.0.161
pi@raspberrypi ~ $ git clone git://git.drogon.net/wiringPi
pi@raspberrypi ~ $ cd wiringPi
pi@raspberrypi ~/wiringPi $ ./build

5 – Install the rfrpi software

RfRpi comes with a demonstration program you can fin in this git repository : https://bitbucket.org/disk_91-admin/rfrpi/src

To install it on Pi :

# ssh -l pi 10.0.0.161
pi@raspberrypi ~ $ git clone https://bitbucket.org/disk_91-admin/rfrpi.git
pi@raspberrypi ~ $ cd rfrpi/rfrpi_src

Depending on the type of Rapberry you have, you should modify de file version.h by commenting / uncommenting the needed line.

// For RPI v1
// #define RFRPI_RPI_VERSION       1
// For RPI B+ and RPI 2
#define RFRPI_RPI_VERSION       2

For RPI2 and RPIB+ you also need to compile the kernel driver you will find in the krfrpi folder ; for this, take a look to this post about kernel driver for rf433

If you have a RPI 1 ; you don’t have to care about what it is above.

For all, you need to compile and run !

pi@raspberrypi ~/rfrpi/rfrpi_src $ make

You must run the I/O configuration script on startup by adding the blue line in /etc/rc.local if not doing it, the raspberry will emit continuously noise and disturb other devices.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

/home/pi/rfrpi/rfrpi_src/rfrpi_hwinit.sh
exit 0

Then run it:

pi@raspberrypi ~/rfrpi/rfrpi_src $ sudo ./rfrpi_test

You should got the following result as an example:

pi@raspberrypi ~/rfrpi/rfrpi_src $ sudo ./rfrpi_test 
Singleton::init() - entering 
Singleton::init() - ledManager created 
Singleton::init() - core_433 created 
Singleton::init() - EventManager created 
Singleton::init() - Singleton is ready 
Version (0.1) Branch (beta) Build date(20140223)
EventManager::enqueue() - enqueue ((null))
EventManager::eventLoop() - proceed INIT 
* Core_433::receptionLoop() - received message [RCSW 123456]
EventManager::enqueue() - enqueue (RCSW 123456)
* Core_433::receptionLoop() - received message [RCSW 123456]
EventManager::enqueue() - enqueue (RCSW 123456)
EventManager::eventLoop() - proceed GETSENSORDATA 
[INFO] Welcome message correctly received, Rx/Tx working fine
EventManager::eventLoop() - proceed GETSENSORDATA 
[INFO] Welcome message correctly received, Rx/Tx working fine
* Core_433::receptionLoop() - received message [OSV2 1A2D1002402000842577]
EventManager::enqueue() - enqueue (OSV2 1A2D1002402000842577)
EventManager::eventLoop() - proceed GETSENSORDATA 
 {"datetime": "2014-02-23 20:11:31", "temperature": "20.400000", "humidity": "40.000000", "channel": "1" } 

The part in green is a shield health check procedure, the INIT event is send to the eventManager, this makes the 3 led blinking then emitting a 123456 message to ensure emitter and receiver are working. This part can be removed from main().

The part in blue is an example of message received from a sensor. The behavior can be modified from the eventManager.cpp class.

6 – Let’s Hack it !

Now, you can start working with the library, a couple of explanations :

  • RCSwitch is the lower end driver  listening RF and decoding signals, it is where you can active some new layer 1 decoding protocol.
  • RcOok is the layer 1 decoding system for miscellaneous protocols. It is where you can add you own layer 1 decoding protocol.
  • Core433 is the associated Thread interpreting RF messages and creating the message to the eventManager once a message is received.
  • EventManager is the state machine receiving the messaging and executing the expected actions like extracting and printing sensors data from a RF message. It is where you can add your custom code.
  • Sensor is the layer 2 decoding protocol, at this level we are extracting the sensor measure from the received data, like temperature, humidity … This is where you can add you own sensors definition.
  • LedManager is the led driver allowing functions like on/off/blinking/fast blinking…
  • Singleton is a really bad way, but efficient one to start all the threads and to allow an object sharing across the Threads.

Have fun with this code, do not hesitate to upgrade it and push modification of this code, particularly if you are implementing new sensors, I’m sure all of us will be happy to use it as you can be happy to use the one already in it !

 

38 thoughts on “Getting start with rfrpi card v1.0 – rf433 for raspberry pi

  1. You’ve done a good job! Although I did not order your rfrpi-card, I was able to setup a cheap transmitter and receiver on a breadboard, and test your software. It works! (excluding the LEDs)

    I think your software has potential for becoming the de-facto standard for using 433MHz devices on a Raspberry Pi, especially for receiving signals.

    Keep up the good work!

    • Rfrpi is based on C/C++ ; by-the-way if you are able to execute a procedure on Interrupt and read/write a GPIO with java you can make it work

  2. Hi!

    Your rfrpi shield, is the antenna connected to BOTH the RF433 sender and receiver… or only the RF433 receiver?

    Thanks

  3. Hello,
    I followed your Manual and tried to run the “rfrpi_test”.
    The LEDs blinked, but then the skript stopped and I had to cancel it via “Strg + C”.
    This is the Output I got:

    Singleton::init() – entering
    Singleton::init() – ledManager created
    Singleton::init() – core_433 created
    Singleton::init() – EventManager created
    Singleton::init() – Singleton is ready
    Version (0.1) Branch (beta) Build date(20150324)
    EventManager::enqueue() – enqueue ((null))
    EventManager::eventLoop() – proceed INIT

    Could you tell me what went wrong?

    • It is normal to stop the program with CRTL+C has it listen rf433 in a loop. Test should enqueue a message to send and you should receive it on the receiver.

  4. If anyone has set this software up on a Raspberry pi 2, could you please let me know what percentage of the CPU is used when listening for incoming messages?

    • I’m using it with a Rasp 2 ; the concurrent processing works differently and actually I have some issues as soon as the frame are long and subject to be reschedule. Working on a kernel driver to manage it better.

      • Thanks Paul. Could you keep me up to date regarding the fix? (and the Shield)

        Kind regards
        Simon

  5. Another question.

    I presume the code is written in C++? If so, would you be prepared to write a C++ wrapper to be able to parse the incoming receiver codes to a python script?

  6. Hello Paul,
    this is a very interesting information.
    just to be sure, i’d like to set up my home automation installation using a Raspberry PI 2 + RF433 and ZWave.
    > Did you test communication between your Raspberry+shield and any RF433 module ? any feedback ?
    Then for my installation, i need to be able to combine Razberry shield with yours.
    > Is it possible to change your GPIO connector to a connector duplicating Rasberry ports to be able to plug another shield over it ?

    • 1) I’m connecting the shield with many devices on 433 so no pbm
      2) Yes it would be possible BUT the actual version have some trouble with RPI2 and kernel scheduling evolution. I need to rework on the shield and actually not have time for doing it. So I do not recommend to start any RPI2 stuff with it.

  7. Hello,

    Have you tested it with a raspberry pi 3 and a 301 oregon scientific weather station?

    I might be interested in the weather shield…

  8. Hi Paul –

    This is a fantastic board. Currently I am running Pi 2 and some cheaper 433 TX/RX chips for wall sockets on/off. Can this board do the same on a Pi 3? I do want to purchase one with an antenna.

    Currently I am using this build: https://timleland.com/wireless-power-outlets/

    Let me know how to purchase one.

    Thank you,
    Michael in California

      • Bonjour Paul,

        J’essaie d’utiliser rfrpi pour récupérer les signaux de mon compteur d’énergie OWL 180. J’avais déjà mes émetteurs/transmetteur 433MHz basiques, mais suffisants pour contrôler mes Chacon sur mes radiateurs, qui sont sur protocole DIO.
        Bizarre : les messages que j’émets depuis mon raspberry Pi3 pour piloter mes DIO sont bien reçus par RFRPI, avec le début de message DIO_ qui est interprété.
        Par contre, l’émission depuis la télécommande DIO, ou bien les émissions de mon OWL ne sont pas détectées.
        Je n’ai pas compris ce qu’étaient les RX_ENA et TX_ENA, dois-je ajouter des antennes sur les GPIOs du RPI ou est-ce optionnel ?
        Merci par avance pour tes suggestions,

        Ludovic

      • RX_ENA and TX_ENA allows to control the RF switch as in my board we have one antenna but 1 emitter and 1 receiver so you have to switch to the right mode. As you are using RPI3 I suggest you take a look to my post about kernel module for rfrpi as the way the RPI scheduler works in RPI 2/3 differ from what it was when I built the solution some years ago with RPI1. The way RFRPI works it needs to get realtime interrupt processing what the user mode does not allow.

  9. Thank you for your reply Paul.
    Reloading a new image of raspbian and modify the kernel is a heavy task !
    I would prefer to use an ESP8266 to run rcswitch and decode the received signals, do you think it is realistic ? I would have to convert the pieces of your C code relative to the owl 180 into lua language…
    Rgds,
    Ludovic.

    • I assume that ESP8366 should be able to make it working, you may have some work to port the existing code but not so much.

  10. Hello, I’d be interested in a card if you still make them.
    One quick question, how far does it receive/transmit data? I had almost no luck with a few module found online because they were lacking of a good antenna. If you don’t make them anymore, what is the best alternative solution? My goal is to reach about 50 meters (with some obstacles).
    Thanks in advance

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.