OK, so I have a 4 pin 315/433MHz rf reader module which I've connected to my raspberry pi 2. 2 pins are for Voltage and ground, and of the middle two that are for data, one of them goes to a GPIO pin configured as input.

XY-MK-5V is the model number

:  In the image the receiver is on the left
(source: aliimg.com)

I've actually gotten all of this to work just fine. I can read data manually from the GPIO pin just fine, by accessing the file


I can even place a car key next to the receiver press a button, and see the values change between 0 and 1.

The problem is that I cannot figure out how to properly read from the data pin. I cannot figure out if there are supposed to be multiple ones or zeros in a row in the data its reading. There doesn't seem to be any time stamp that I can find to see when the last value was read.

How can I properly read the data the module is receiving?

  • You're not supposed to read the clock, you're supposed to feed it into the clock input of e.g. a shift register.
    – Ignacio Vazquez-Abrams
    Jan 1, 2016 at 5:04
  • 1
    Can you post the link of that module ? Jan 1, 2016 at 5:07
  • @dastaan i00.i.aliimg.com/wsphoto/v0/547433440_1/… mine is on the left
    – Taylor
    Jan 1, 2016 at 5:23
  • What's the name of the module ?? Can you post link from where you bought it ? Also, any additional documentation link helps. Jan 1, 2016 at 5:23
  • @IgnacioVazquez-Abrams What would be a shift register pin on raspberry pi 2, or how do I configure one?
    – Taylor
    Jan 1, 2016 at 5:24

1 Answer 1


That is a radio transceiver working with the OOK (On Off Keying) method.

I believe the transmitter sends carrier to indicate a signal (mark) and no carrier to indicate no signal (space). This is how remote control IR transceivers works as well.

You need to connect a 17 cm wire to both the receiver and transmitter to act as aerials (the actual best length is slightly different, google if you need it).

In the absence of a transmission the receiver will be picking up noise as its automatic gain circuitry searches for a signal. This will go once a transmission bit is receieved.

static versus signal webm video

To get usable data end to end both transmitter and receiver must agree a protocol. I know of several as I have written software for a couple.

VirtualWire is widely used on Arduinos. I have written a Raspberry Pi VirtualWire Python module.

VirtualWire webm video

Another common protocol is the Manchester Encoded strings used by wireless keyfobs to control domestic appliances. Here are Python code and more recent C code examples to read/write wireless keyfob commands.


If you power the receiever with greater than 3V3 (as you would probaly want to do) then use a voltage divider to cut the receiver data line from Vcc to 3V3 before connecting to a Pi GPIO to read.

  • I looked at the C code for Manchester Encoded strings and it works well but it uses the pigpio library that needs 5-6% of my CPU since it queries all pins. Would it be possible/simple(!) to optimize so that I only watch one pin?
    – jwillmer
    May 18, 2018 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.