Broadcast Your Own FM Radio Station, with a Raspberry Pi
Sick of listening to babbling DJs and want to broadcast your own radio station? Need a quick and easy solution to transmitting MP3s or Internet radio to your archaic in-car stereo system?
Yet again, it is the Raspberry Pi will come to your rescue, with its previously unknown ability to broadcast on the FM band.
Before proceeding, please understand that this is a proof of concept project. Unless you are equipped with the relevant license, you should not be broadcasting on the FM band and you proceed wholly at your own risk.
What You’ll Need for Your Pi FM Project
Begin by downloading the PiFM image, which you will need to flash to your SD card. You can use the PirateRadio.py script if you prefer, installing it to your existing Raspbian installation, but this tutorial is focused on the PiFM image.
You’ll also need a jumper wire, a soldering iron and solder, and a length of 2mm wire, cut to 20-30cm. I’ve used an old coat hanger left over from my digital HDTV antenna project, but you can purchase 2mm wire in rolls from electronic shops; some might even cut it to length for you. While you’re there, purchase some heat shrink tubing, just the right size to slip over the jumper.
You may also need some Sugru or similar putty to secure the antenna, or perhaps a glue gun. With everything assembled, it’s time to put the project together.
Finally, you’ll need a Linux computer other than your Raspberry Pi.
But first, an important question…
How Does a Little Computer Become a Radio Transmitter?
To avoid causing interference with other devices, the Raspberry Pi employs a technique known as spread-spectrum. This reduces the impact from the processor on nearby hardware (by spreading electro-magnetic interference across a wider bandwidth to lessen interference), but the side effect of this is a GPIO array that can be used to broadcast on the FM band!
You can utilize that broadcast power by connecting an antenna to pin 4.
Now as you know, we’re not lawyers. We’re MakeUseOf. So, before proceeding, keep in mind that in the vast majority of countries, broadcasting on the FM band without a license is illegal, and can get you into trouble with fines and jail time.
Building Your Antenna
The most complicated aspect of this project is building the antenna, but if you have the right equipment you should be done in about 10 minutes. With a jumper wire snipped with about 10mm of stripped wire above the connector, proceed by soldering this to your 2mm gauge wire.
When the solder has hardened, slip a 50mm length of heat shrink tubing over the connection and the top of the jumper connector and warm it up for a few minutes with a hairdryer until the connection is insulated and the tubing now tight-fitting.
When you’re done, you can connect this to pin 4 on the GPIO.
Finding GPIO 4
If you haven’t used the GPIO pins before, you probably won’t know where pin 4 is. On both the 26 and 40 pin GPIO versions of the Raspberry Pi, GPIO 4 is the fourth pin in on the innermost row of the array, as pictured here:
Connect your antenna to this pin for the best results (connecting to other pins will also broadcast on FM, but the signal will not be as strong).
Preparing the Playlist
The next step is to prepare your MP3 files. Copy these from your desktop computer to the SD card, dropping them into the /Pirate Radio partition of the card. You’ll probably be unable to do this in Windows, so take this chance to install Linux on your PC as a dual boot. Alternatively, you might be able to transfer the files in a live Linux environment from USB, if you have enough spare USB or SD card slots on your computer.
Next, browse to the pirateradio.config file and open it in your text editor. This offers a collection of options, such as frequency, shuffle, repeat_all and stereo_playback. These last three can be toggled by switching the default true setting to False.
As far as the frequency parameter goes, you’ll need to ensure that you set a value that can be detected using your standard FM radio. For example in the UK the band runs from 87.5 to 108 FM, so you wouldn’t set a frequency of 85 or 110 as the radio will be unable to tune into them.
It’s a good idea to browse through the FM band on your FM radio to find an empty space. Impeding on an occupied frequency is extremely unwise (see above).
Save the pirateradio.config file when you’re done, and close the text editor.
Boot to Broadcast!
With your MP3s saved to the correct folder, safely remove the SD card from your computer, insert it into the Raspberry Pi, and power up. At the same time, grab your FM band radio, and tune it into the frequency you specified in the config file.
In just a few seconds you should hear the first track play, and your radio station will be on air!
You can get an idea of the range by taking your FM radio outside with you, and seeing how far away from your Raspberry Pi you are when the signal breaks up. Around 50-100 feet is the limit, although disabling the stereo_playback option so that you broadcast in mono rather than stereo will increase the range.
Range can also be increased by siting the Raspberry Pi in an elevated position, or using copper wire rather than aluminum (as I have done). You can get could results by making the whole kit easy to carry, perhaps placing it in a jar or similar. I’ve powered mine with six AA batteries, but any compatible external power source will work.
But Really, What Can You Use This For?
Radio broadcast licensing rules are likely to rule out most extensive use of this project, but this shouldn’t stop you from giving it a go. For a start off, you can use it to exercise any fledgling soldering interest you have (checking our soldering starter guide for tips) and gain an understanding of how the addition of a piece of wire can turn a computer into a broadcast radio station.
Meanwhile if you’re a teacher or involved with a school radio project, this is a great project for students to expand appreciation of computing and radio.
Finally, there is scope in this project for citizens of oppressive regimes to use this project to communicate with resistance movements.
Need help with your PiFM project? Life on the open airwaves not quite working out? Tell us about it in the comments.