Easily Turn Your Raspberry Pi into an FM Transmitter

RasPi FM Transmitter

Have you ever wanted to be your own radio DJ? [Kevin] has made it easier than ever with his Raspberry Pi FM Transmitter program. The program is written in C. [Kevin] has made source code is available along with a compiled binary.

PIFM allows you to load up any audio file and specify a frequency to transmit. The program will then use PWM to modulate the audio sample through the Pi’s GPIO4 pin. [Kevin] claims that the RasPi alone will only transmit around a 10 cm distance. He says that making a simple antenna out of a jumper wire can increase the distance to around 100 meters. All you have to do is hook up the wire to the GPIO4 pin to drastically increase the range.

The legality of such a transmitter will vary from place to place, so be sure to check out your local regulations before you go transmitting audio on regulated frequencies. If this kind of thing is interesting to you, you may want to investigate ham radio. It’s not all Morse code and old fogies. Some people claim it’s a hacker’s paradise.

[via Reddit]


  1. leomcmartin says:

    I’ve done this with the Raspberry Pi, and even with no antenna I can send a signal from one end of my house to the other quite happily, and with a half-wave dipole I can push that to approximately 120 metres. Quite astounding considering it’s just a GPIO driving it!

    Unfortunately the output signal is horrendous; the Pi will happily put out strong harmonics up to the fifth harmonic, so attaching an antenna without a harmonic filter might not be a wise idea lest you go interfering with something important (such as the 406MHz EPIRB band, which is the 4th harmonic of 101.5MHz.)

  2. Yugin says:

    Just tried a few days ago and it works well!
    I was wondering if there is a way to transmit speakers output on the FM.
    The program allow to get wav from the standard input, so there could be a way to pipe sound to it for example with ffmpeg or such

  3. Sascha says:

    Nice but I’d guess the stray is very high.

    I did something ‘similar’ last week: Fitted a SONY MMR-70 to my ONYKO AV-Receiver. Nearly no audio-delay thus no echo. Nice and cheap for whole-house (and garden) audio with cheap FM radios.

  4. Torque says:

    Just a reminder, the concept of doing this was featured back in 2012:


    And back then many expressed concern about how this’ll potentially jam or distort other frequencies.

  5. fartface says:

    What I worry about is that it will have a LOT of splatter on side bands. it really needs some filtering on the output before it hits the antenna.

    Be a good hardware hacker, dont just shotgun blast radio waves without putting them through filtering to clean everything up.

    • “The legality of such a transmitter will vary from place to place, so be sure to check out your local regulations before you go transmitting audio on regulated frequencies.”

      Who do I check with? I doubt the local PD would know what I’m talking about. Is there a website or something?

    • thantik says:

      As someone who has tried this, there is less “splattering” of the FM bands than one of those cheap FM transmitters you buy at the store. Upon bootup, you’ll notice it kind of wipe through the frequencies real quick but once it’s “warmed up” it’s a very narrow and precise signal.

      • pelrun says:

        You’re talking about frequency stability, which is a different thing.

        The Pi outputs a square wave, which has harmonics all the way up to daylight. So it’s not just putting out energy at the FM frequency, it’s also nuking multiple different frequencies all the way up the spectrum. That’s pretty impolite behaviour (not to mention illegal, even though it’s unintended), and it’s why you should be putting a filter on the output – that absorbs any and all spurious harmonics that are outside the band you’re intending to transmit on.

  6. filespnr says:

    supa !

  7. LOL says:

    Step 2
    add fifo pipe and ALSA sound card device emulation

  8. ijnoag says:

    Already transmitting this http://www.youtube.com/watch?v=sw9ETYHtzis and this http://www.youtube.com/watch?v=A6XcC64Oq_c on a frequency used by ultracatholic Radio Maryja (Poland)

  9. Oliver says:

    Please credit the author…

    “Developed by Oliver Mattos and Oskar Weigl in 24 hours at a Raspberry Pi Hackathon”

  10. kgsws says:

    Nobody here mentioned how terrible audio quality it has, especially stereo. This is caused bevause you get only about 6bits for audio and he has to use oversampling.
    I tried this app some time ago.

    • di0de says:

      I got fine quality with mine?

      • AKA the A says:

        You’d be surprised how little bit depth you can get away with if you avoid the noise floor…6 bits should give you around 36dB of SNR, if you can squish the dynamic range into that, it’ll work ;-)
        While not the 40-50dB dynamic range professional FM radio equipment can give, it’s more then half that :D

        • Oliver says:

          You do indeed get terrible results with stereo mode. Theres some timing feature/bug with the pi which means the time it takes to service a DMA copy request depends on the *value* that is being copied.

          To be fair, the spec doesn’t specify any kind of timing requirements for DMA copies, but it is still a bit wierd, and I can’t seem to find a workaround.

          • kgsws says:

            That is true, i did simple GPSET and GPCLR bit flipping with DMA while using logic analyzer and resulting square had slowdonws. However it was absolutely not value dependent. BTW i did it at full speed, with no PWM / PCM delay.

  11. Nagy István says:

    Is it possible to extend this to transmit RDS data as well?

  12. Average Joe says:

    Is this some sort of joke? You guys already featured this story.


    “The program is written in C. [Kevin] has made source code is available along with a compiled binary.”

    Kevin did not write the source code…. nor did he make it available. In fact, you can clearly see from the wget that he does, that it is being pulled from the original authors website.

    Oliver Mattos and Oskar Weigl created this stuff.

  13. Matouš says:

    What kind of filter would you recommend to cut the worst unwanted frequencies? Would a simple capacitor of a proper value be enough? Are there any other means to make it behave better with a little work?

    • AKA the A says:

      For starters a simple lowpass…better results can be done with a “pi” filter, either single or multiple (Chebishev filter)…
      Because of the low power even the simplest of lowpass filters should get it to behave in an acceptable manner.

      • Matouš says:

        Yeah I know Chebyshev, Butterworth, inverse-Chebyshev and the like, even a bit of digital filtres… I just thought that anyone could suggest a specific capacitor value suitable for the filter as I know all this stuff theoretically, but the practical part begins the next semester for me (I don’t know how to calculate the values for a real circuit) :D Also isn’t Chebyshev like one of the most complex and expensive filters with a bad phase-response and time delay, but great passband? Not sure this is quite suitable for this application.
        So… Should I put a 22pF or a 470uF cap there? Thanks for the answer anyways!

        • rewolff says:

          You want to transmit at 100MHz. Put a simple 1-pole RC filter on the output. You want low-pass, so R “inline” and a capacitor to ground.
          You want the cutoff frequency to be about 150MHz. To have some margin. The time that belongs with that frequency is 6ns. So the product of your RC will have to be on the order of 6ns. There is a factor of pi or pi/2 in there somewhere. I forgot that part from my education. I’d look it up if I really needed that.

          But capacitors in the pF range are scarse. This is because say “1 cm of wire” will have a capacitance of about 1pF. So they don’t sell 0.2pF capacitors: you just put 2mm wire somewhere and there you have it!

          Anyway, I’d recommend say 2pF, 3 Ohms…..

          But…. The output resistance of the raspberry pi GPIO pin is well above the 3 Ohms (about 30). And the capacitance of the trace to your GPIO header is well above 2pF (I’d hazard 4-10).

          So there is that filter that all the theoretical guys said you had to install. It’s already there in parasitic resistances and capacitances!

          • ka1axy says:

            Here’s the REAL problem:
            Aviation frequencies (they use AM – amplitude modulation) are just above the FM band, at 108-137MHz. Interfering with these frequencies is easy (AM is very susceptible to low power interference) and will get you immediate attention from the FCC, because it’s a safety issue (the pilots get upset when they can’t talk to the ground controllers).
            So, you want a good filter. Not a simple single-pole lowpass. Something like this:

  14. 2ftg says:

    Just use a simulator like rfsim99 to design the filter or one of the many calculators online.
    Use this to design the inductors http://hamwaves.com/antennas/inductance.html and choose standard capacitor values from this: http://www.rfcafe.com/references/electrical/capacitor-values.htm

    Here’s also a circuit someone else has designed:


  15. Emerica says:

    Don’t do this.
    The harmonics produced stretch out into bands you don’t want to be messing with.
    And I like to do stuff like this and mod the pifm scripts ages ago. https://github.com/Emerica/pifm
    Check it with a sdr, it’s not a happy transmitter

  16. Shyamsai1234@gmail.com says:

    Is there any possibility to jam high frequency like mobile frequency using raspberry pi..?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 96,614 other followers