Tested on:Raspberry Pi 2; Raspberry Pi B+; Python 2.7; Raspbian pre Jessie
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)
Building a simple LED display (optional)
Hardware:2 Raspberry Pi with power source and SD-cards >= 4Gb
433Mhz Sender and Receiver
female jumper cables
a second screen and keyboard

Using pi-switch for easy wireless data transmission with a Raspberry Pi

Sadly, pi-switch is no more continued! Instead, you can use rpi-rf as a well-working replacement, see Triggering rc switches with rpi-rf.

Pi-Switch is a python port of the Arduino rc-switch library for remotely controlling power sockets and wireless data transmission. In the current version, pi-switch also allows wireless data transmission for the Raspberry Pi. Again, my tribute to Alexander Ruedlinger for the port- i’m having a lot of fun with your work!

This tutorial will show how to setup a simple data transmission between two Raspberry Pis; here is another tutorial which explains how to trigger power sockets with pi-switch.

Setup and Installation
Connect one Raspberry Pi to the host computer, either over ethernet or wifi(see prerequisites). Log in and type into the terminal

After the installation is completed, perform the same installation on the second SD card or duplicate the SD card with gnome-disks.

Voltage divider
The 433Mhz Receiver runs on 5 Volt, but a RPi can take no more than 3.3V signal strength at his inputs. Therefore, a voltage divider has to be built. For this, two 4.7k Ohm resistors are attached directly to the reiceiver: one resistor beginning in signal divides the voltage to RPi-Input and GND over the second resistor (in the shrink sleeving).

433MHz receiver

433MHz receiver with voltage divider

Here is a picture of the full setup:

Piswitch Transmission Setup

Pi-switch Transmission Setup

433Mhz Sender/Receiver pairs are cheap and can be bought on Amazon for instance.

Sender wiring
The 433Mhz sender module has three pins: VCC, GND and DATA. Connect VCC to pin 1, GND to pin 6 and DATA to pin 11 of the first Raspberry Pi in BOARD numbering.

Receiver wiring
Connect the receivers VCC to pin 2, GND to pin 6 and DATA over the voltage divider to pin 13 of the second Raspberry Pi, again in BOARD numbering. If unsure which pin is DATA, check the technical specification of the module.

LED display
The display is for demonstration purpose and optional. Have a look at the LED display tutorial from the prerequisites for the assembly instructions.

The two Raspberry Pis need to be controlled independently. In this setup, one of them is attached to a host computer over Ethernet; the other has a screen plus keyboard. The same script, display_piswitch.py, is used for sending and receiving values. The sender will start transmitting values after entering

in its terminal. The sender will transmit a number which is increased by one every second, starting with zero.

Activate the receiver Raspberry Pi by typing

in its terminal. The receiver script will listen and print every received value; if the LED display is attached, the value will be displayed as binary number.
The code is not difficult, just a few lines of code for setting up pi-switch are required.

Potential use
Data transmission with pi-switch could be used to implement some simple state communication protocols without setting up a wifi network. It is very advisable, however, to setup a bidirectional communication with two senders and receivers for validating state transmission. Like in the clip below (which misses a number), transmissions could be lost due to the timing intervals.

The complete script
Click on Full Script to show all of the code.

In action

Home automation with rc switches: http://www.knight-of-pi.org/cheap-home-automation-with-a-raspberry-pi-controlling-rc-switches-with-pi-switch/
Creating disk images with gnome-disks: http://www.knight-of-pi.org/sdisk-images-for-complex-rapberry-pi-projects/
Pi-Switch on GitHub: https://github.com/lexruee/pi-switch-python
Triggering rc switches with rpi-rf: http://www.knight-of-pi.org/home-automation-with-rpi-rf_send-and-rpi-rf_receive-for-433mhz-rc-switches/

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.


Time limit is exhausted. Please reload CAPTCHA.