How to Make Your Own Pirate Radio Station
Project Steps
- Make the antenna.
- Flash the SD card and add music.
- Edit the config file.
- Start it up!
- How the PiFM software works.
- Going further.
Parts:
- Raspberry Pi single-board computer from the Raspberry Pi Starter Kit, MakerShed #MKRPI5
- SD Card, 4GB or more from the Raspberry Pi Starter Kit
- Female jumper wires MakerShed #MKSEEED3
- Heat-shrink tubing RadioShack #278-1610
- FM radio to tune in and listen to your station, such as RadioShack #12-586. (We also like the looks of #55060408, #55060407, and #55061160, only available online.)
- Battery pack, 4xAA, with USB socket (optional) for portable operation, RadioShack #270-087 (online only)
Tools:
- Computer
- Wire cutters / strippers
- Soldering iron RadioShack #64-053
- Hot glue gun
- Solder RadioShack #64-013
- Wire stripper/cutter RadioShack #64-224
Step #1: Make the antenna.
- Technically, all you need for an antenna is a piece of wire. For an optimal antenna, you could attach a 75cm wire to pin 4, with a 75cm power cable pointed in the other direction. (That would effectively make a half-wave dipole antenna at 100MHz, near the middle of the FM band.) We just used 40cm of 12 AWG solid wire, since things started tipping over when the wire got longer.
- Cut and strip a female jumper wire. Solder it to one end of your antenna, and insulate with heat-shrink tubing.
- Dab hot glue around the joint for support, and stick it on pin 4 of the GPIO pins of your Raspberry Pi. The glue makes the antenna more rigid so it stands up better.
- NOTE: If you have the Raspberry Pi Starter Kit and you're in a hurry, you can just use a male jumper wire plugged into the Cobbler breakout board! (Both are included in the kit.) It will work, but the range will be roughly half of what you'd get with 40cm of 12 AWG solid copper.
Step #2: Flash the SD card and add music.
- To save you time configuring everything, MAKE Labs made a disk image. Download it here. (Advanced users who just want the source can find the link in the intro.)
- The original PiFM code proved the concept with impressive results. The MAKE image takes the work out of partitioning the card into system and data partitions. It also auto-mounts the data partition. It uses a fraction of the CPU of the original code and enables playback from MP3, FLAC, and more. And it runs the PirateRadio.py script on startup, so your music starts broadcasting immediately once the transmitter boots up. Ultimately, this will save you a lot of time. But you can't just drag the files to your SD card; it must be flashed to work.
- Flash the image to your SD card. If you're not familiar with the process, it’s easy. Good tutorials can be found here. You can use Win32DiskImager on Windows, or the Command Line Tools (1) instructions if you're on OSX. I'll assume Linux users have moved on already.
- For OSX and Linux users, simply open up the PirateRadio partition and get started. Windows users, follow our instructions for connecting to your Pi via SSH using WinSCP.
- To add music, simply add your artist or album folders to the root of the “Pirate Radio” partition of the SD card. Your music files can be nested within these folders, so there's no need to dump all your music into one mess on the main directory.
Step #3: Edit the config file.
- You can set the frequency you want to broadcast on in the pirateradio.config file. Open it up in a text editor. You should see something like: [pirateradio] frequency = 88.9 shuffle = True repeat_all = True
- Set frequency to the station you want to broadcast on. Useable FM frequencies are typically from 87.5MHz to 108.0MHz. (108.2 was the highest our test radio could reach, but that's in an aircraft band that you should never interfere with.)
- Set shuffle to True to shuffle files, or to False to play files alphabetically.
- Set repeat_all to True if you want to loop forever through your playlist.
Step #4: Start it up!
Tune your FM radio to your frequency of choice and plug in the Raspberry Pi. It will take about 15 seconds to warm up. Once it does, you should hear your music loud and clear.
Step #5: How the PiFM software works.
- From the PiFM wiki: "It uses the hardware on the Raspberry Pi that is actually meant to generate spread-spectrum clock signals on the GPIO pins to output FM radio energy. This means that all you need to do to turn the Raspberry Pi into a (ridiculously powerful) FM transmitter is to plug in a wire as the antenna (as little as 20cm will do) into GPIO pin 4 and run the code."
- Frequency modulation "is done by adjusting the frequency using the fractional divider." For example, for a target broadcast frequency of 100MHz, the signal is fluctuated between 100.025Mhz and 99.975Mhz, which makes the audio signal.
- The Python code defaults to 87.9 FM with shuffle and repeat turned off. It scans the SD card for music files and builds a playlist based on the options in the config file. It then passes each file along to a decoder based on the filetype. Each file is then re-encoded into a mono format the PiFM radio can handle. This lets you play more than just WAV files: use your MP3, FLAC, M4A, AAC, or WMA files too.
Step #6: Going further.
- Tuck everything in the acrylic case that comes with your Raspberry Pi Starter Kit and you're good to go. Or, if you want something cooler or more subversive, try building an awesome housing of your own. MAKE Labs manager Sam Freeman drew up this little number, a cool radio tower; download it at thingiverse.com/makelabs.
- Add RadioShack's handy USB battery pack so you can carry your station wherever you need to take over the airwaves. (It fits inside the radio tower, too.)
- NOTE: If you have trouble with range, double-check which pin your antenna is plugged into. At MAKE Labs we spent a few hours puzzled by our antenna's performance, only to discover it was one pin over!
- TIP: For a cleaner FM signal, and to reduce any accidental broadcasts outside the FM band, build a simple bandpass filter for your Pirate Radio using just a few components, at makezine.com/go/pirate-bandpass.
Post a Comment