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]

41 thoughts on “Easily Turn Your Raspberry Pi Into An FM Transmitter

  1. 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.)

    1. Tune around a bit, I sent mine at 107 and picked it up better on 102 ish and othe stations throughout the band! some receptions better than others. Just scan through till you find the strongest one…it really worked for me

  2. 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. 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. 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.

    1. “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?

    2. 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.

      1. 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.

  5. 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.

      1. 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

        1. 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.

          1. 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.

  6. 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.

  7. 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?

    1. 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.

      1. 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!

        1. 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!

          1. 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:

  8. 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:

  9. Is it possible to transmit the input sound from an iPod with this? If not it would be a great addition that would allow control of the output being transmitted. e.g skip track, next, previous, shuffle, etc.

  10. REALLY DANGEROUS. Just found out the harmonics really are pretty bad and it actually shouldnt interfere with am but even higher bands such as vhf and uhf and shf. DO NOT MESS WITH THIS UNLESS U HAVE A HARMONIC TRANSMITTER. kind of scared i didnt do the research and have been transmitting on 102.1 for a while.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

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