The Raspberry Pi (RPi) is an amazing computing platform; it’s small, it’s cheap, it’s fast, and it’s remarkably versatile. So versatile in fact that with practically no additional hardware you can turn one into an FM transmitter …
What you'll need is an Raspberry Pi 1 or 2 running Raspbian, and, optionally, a short length of wire as an antenna. For software you’ll need one of the following:
- PiFm - written in 2012 by Oliver Mattos and Oskar Weigl of the Imperial College Robotics Society PiFm consists of a Python program that loads an executable written in C which does the heavy lifting. Can transmit both mono and stereo audio. Works on all Raspberry Pi 1s.
- PiStation - written by Cody J Heiser in mid’ 2015, is more sophisticated but via an installer, downloads PiFm and uses that code to drive the hardware. Works on all Raspberry Pi 1s.
- PiFMPlay - written by Mikael Jakhelln in August 2014, also uses PiFm. Works on all Raspberry Pi 1s.
- fm_transmitter - written by Marcin Kondej in July 2015, is completely written in C and works on both the Raspberry Pi 1 and Raspberry Pi 2. The sound quality is apparently not as good as the PiFm-based programs and while it can read both mono and stereo audio files can only transmit mono.
- Pi-FM-RDS by Ginkgo23 originally written in 2012 and updated a couple of months ago to support the Raspberry Pi 2, adds RDS (Radio Data System) generated in real time.
According to the PiFm documentation, the RPi FM transmitter is fairly powerful delivering a signal that can be detected at ranges of 50 meters or more. The RF signal is output on GPIO 4 which is pin 7 on both the 26-pin header on the Raspberry Pi 1A and 1B, and the 40-pin header on the Raspberry 1A+, 1B+ and 2B boards.
How does it work? Here’s the explanation for PiFm and all of the other implementations work in much the same way:
The python library calls a C program (provided both precompiled and in source form). The C program maps the Peripheral Bus (0x20000000) in physical memory into virtual address space using /dev/mem and mmap. To do this it needs root access, hence the sudo. Next it sets the clock generator module to enabled and sets it to output on GPIO4 (no other accessible pins can be used). It also sets the frequency to 100.0Mhz (provided from PLLD@500Mhz, divided by 5), which provides a carrier. At this point, radios will stop making a "fuzz" noise, and become silent.
Modulation is done by adjusting the frequency using the fractional divider between 100.025Mhz and 99.975Mhz, which makes the audio signal.
A comment on the Instructables article pointed out:
You do not want to be using this as a long term, stationary FM transmitter. If any of your signals interfere with air traffic control, emergency services (police, ambulance), etc they will come looking for your signal and ultimately you. Looking at a spectrum analyzer with a frequency of 88.7MHz there are harmonics all across the VHF band. Centering on 121.5MHZ, your aviation band emergency frequency, there are harmonics and intermod products all through aviation VHF band (118-136MHz,) and VHF navaids (108-117MHz). If you use this you will splash onto these frequencies. If nobody complains, nobody will come looking for the signal. If this does interfere with aircraft, I guarantee you someone, (FAA in US, Industry Canada in CA) will come by with a DF and find you and you can be charged. Use with caution.
That might be a little pessimistic but you'd still be advised to use a little caution if you're close to an airport, emergency medical services, etc.
Finally, if you’d rather go with an add-on Raspberry PI daughterboard FM transmitter instead of a synthesized one there’s the Adafruit Si4713 FM Radio Transmitter with RDS/RDBS Support ($19.95). To drive this configuration there’s a Python class created by djazz.
If you build one of these systems, let me know how it comes out and if you know of a better implementation, please share.