FS1000A and XY-MK-5V 433MHz RF modules are very often first choice for cheap and dirty Do It Yourself wireless communication. Pair of those , allowing one way radio communication, const less than 3 dollars or euros. So they are really cheap. Limited range and transmission speed limits their real life usage, but simple assembly and extremely easy programming are additional advantage over more complex solutions. Specially in Arduino world, with VirtualWire library. I will not write about it right now, there is enough on the internet already.

FS1000A and XY-MK-5V 433MHz RF modules for Raspberry Pi

Unfortunately, problems starts when you want to do cross platform communication based on those modules and VirtualWire library. For example with Arduino and Raspberry Pi. I have found exactly one working implementation of VirtualWire library that is written in Python and works well with Raspberry Pi. And it was hidden. So, with some effort I allowed myself to wrap this code into small python library and this is how piVirtualWire was created.

It depends on pigpio library and requires it installed on Raspberry Pi:

wget abyz.co.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make
make install
`</pre>
And running always in the background `sudo /home/pi/PIGPIO/pigpiod`

Then, all you need is code.

## Transmitter module python code example

This code snippet assumes that FS1000A TX module ADAT (DATA) line is connected to GPIO 4 and uses 1000 baud rate. piVirtualWire library is located in piVirtualWire subfolder.
<pre>`import piVirtualWire.piVirtualWire as piVirtualWire
import time
import pigpio

if __name__ == "__main__":

    pi = pigpio.pi()
    tx = virtualwire.tx(pi, 4, 1000) # Set pigpio instance, TX module GPIO pin and baud rate

    msg = 42

    tx.put(msg)
    tx.waitForReady()

    tx.cancel()
    pi.stop()
`</pre>

## Receiver module python code example

This code snippet assumes that XY-MK-5V is connected to GPIO 18 and uses 1000 baud rate.
<pre>`import piVirtualWire.piVirtualWire as piVirtualWire
import time
import pigpio

if __name__ == "__main__":

    pi = pigpio.pi()
    rx = piVirtualWire.rx(pi, 18, 1000) # Set pigpio instance, TX module GPIO pin and baud rate

    while True:

            while rx.ready():
                print(rx.get())

            time.sleep(0.5)

    rx.cancel()
    pi.stop()

Happy Arduino to Raspberry Pi radio transmissions with FS1000A and XY-MK-5V!