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]
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.)
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
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
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.
Just a reminder, the concept of doing this was featured back in 2012:
http://hackaday.com/2012/12/10/transmit-fm-using-raspberry-pi-and-no-additional-hardware
And back then many expressed concern about how this’ll potentially jam or distort other frequencies.
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?
Oops. That wasn’t supposed to be a reply.
FCC in the US. Each country has their own regulatory agencies.
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.
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.
supa !
Step 2
add fifo pipe and ALSA sound card device emulation
;)
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)
That might get you into a lot of trouble, be careful mate.
Please credit the author…
“Developed by Oliver Mattos and Oskar Weigl in 24 hours at a Raspberry Pi Hackathon”
Agreed. This is infuriating.
You inspired me and my buddy to try a kernel mode implementation last year:
https://github.com/spencerwhyte/RPIKMFMAD
It wasn’t great, but we had a lot of fun making it.
We’ve given link to the author now. I provided the download link from the authors site so I thought people would understand.
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.
I got fine quality with mine?
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
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.
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.
Is it possible to extend this to transmit RDS data as well?
yup https://github.com/ChristopheJacquet/PiFmRds
So cool. Thanks! :)
Is this some sort of joke? You guys already featured this story.
http://hackaday.com/2012/12/10/transmit-fm-using-raspberry-pi-and-no-additional-hardware/
“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.
yeah and Make did a video about it too
https://www.youtube.com/watch?v=CBb8BN0dqoQ
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?
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.
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!
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!
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:
http://www.amazon.com/FM-Low-Pass-Filter-Kit/dp/B0002NRJQS
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:
http://mastelectronics.blogspot.fi/2012/01/low-pass-filter-chebyshev-for-88-108-fm.html
https://i.imgur.com/flvnCP6.png
Thanks! Already tried this (without filter) and it was a great fun! I will look into this filter.
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
Is there any possibility to jam high frequency like mobile frequency using raspberry pi..?
Check out my foxhunt transmitter project based on this same concept except using nbfm for ham use instead of pifm.
http://hackaday.com/2014/11/06/fox-hunting-with-a-raspberry-pi/
The vedio is very helpful.You need lot of patience too do that
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.
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.