Editor’s note: The Raspberry Pi’s broadcast frequency can range between 1Mhz and 250Mhz, which may interfere with government bands. We advise that you limit your transmissions to the standard FM band of 87.5MHz–108.0MHz (see Step 5) and always choose a frequency that’s not already in use, to avoid interference with licensed broadcasters.

pirate radio

Illustration by Jacob Thomas

What better way to celebrate the launch of the tiny, $5 Raspberry Pi Zero than to build a project. The Raspberry Pi Pirate Radio is one of our favorite builds here at Make:, so it was an obvious pick to port to the new board. In case you missed our first crack at Pirate Radio, try it building it while you wait for your Pi Zero to arrive. PiFM was originally written by Oliver Mattos and Oskar Weigl, and revised by Ryan Grassel.

Pirate Radio is an extremely simple build: Cut and solder one wire to the Pi. The software installation and configuration doesn’t take too long either. Here is how we shrunk down the Pirate Radio into into a Pirate Radio throwie.

PiZeroGif

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

Steps

Advertisement

Step #1: Fashion an antenna

PrevNext
$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies
  • In order to get range out of your pirate radio you'll need to add a single piece of wire to your Pi to act as an antenna. Cut a length of wire about 4" long and strip the end bare.
  • Solder the bare end of the wire to pin 4 on the Pi.
  • Trim any excess wire so that it's not protruding too much from the solder joint.

Step #2: Download & install Raspbian

PrevNext
$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies
  • On your laptop or desktop computer, point your web browser to the Raspberry Pi Foundation website and download a copy of Raspbian Linux.
  • The download might take some time, so feel free to read the rest of the project while you wait.
  • Once the Rasbian Linux image is fully downloaded, you'll need to flash the device onto a microSD card. Make sure the card is at least 4GB so you'll have enough room for the audio files.
  • How you flash the microSD card will depend on the operating system running on the machine you are using to flash. Check out eLinux.com for exact steps for Windows, Mac OSX, or Linux.

Step #3: Boot the Pi Zero

PrevNext
$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies
  • Now that the microSD card is burned, remove the card from your laptop and insert it into your Raspberry Pi Zero.
  • Connect the USB OTG cable to the micro USB port labeled USB on the Pi. Then connect the female end of the OTG cable to a USB hub. This will give you enough USB ports to attach a Wi-Fi dongle, keyboard, and mouse. Attach all of those peripherals now.
  • Attach the mini-HDMI cable to the HDMI port on the Pi and the other end of the cable in your monitor.
  • NOTE: Why buy a USB OTG cable when you can make one. Check out our step-by-step guide.
  • TIP: Wi-Fi cards on the Pi can be easily setup using the graphical user interface. Look for the network logo on your desktop and enter in your SSID and password.

Step #4: Install PiFM and MPG123

PrevNext
$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies
  • Open a terminal and type in the command below to duplicate the files in the remote code repository to your home directory on the Pi. git clone https://github.com/rm-hull/pifm
  • Change directories to the pifm. cd pifm
  • Now compile the pifm application by typing the following command, then hitting return. sudo make
  • Next update the package repositories for Raspbian to ensure the next command downloads the latest software. Simply enter in this command: sudo apt-get update
  • Still in the terminal install the command line audio player mpg123 by typing: sudo apt-get install mpg123

Step #5: Run PiFM from the terminal

PrevNext
$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies
  • Download a few of your favorite mp3 files to the Pi, or you can scp them. Make sure to put them in the /home/pi/Music directory.
  • From the command line, type in the following command. The number 88.3 is the frequency the Pi will broadcast at. sudo /usr/bin/mpg123 -4 -s -Z /home/pi/Music/* | sudo /home/pi/pifm/pifm - 88.3
  • Note: If you want to stash your mp3 files in a different directory, simply change the directory path that's underlined in the command above.
  • Caution: Commands and filenames are case sensitive in Linux, so make sure you duplicate the exact capitalization of the previous commands.

Step #6: Test the FM output

PrevNext
$5 Raspberry Pi Zero Pirate Radio Throwies
  • Grab a radio and tune your dial to 88.3 to listen to the audio output of your Pi Zero.
  • 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.

Step #7: Run PiFM at system startup

PrevNext
$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies
  • In order to have PiFM run at boot time, you'll need to create a simple shell script and add it into the init system. This is how Raspbian Linux starts applications at boot.
  • Using your favorite command line text editing program, create a file called pirateRadio.sh in the /etc/init.d/ directory.
  • Cut and paste the following code into your /etc/init.d/pirateRadio.sh file. #!/bin/bash # /etc/init.d/pirateRadio.sh case "$1" in start) echo "StARRRRRRRting Pirate Radio" sudo /usr/bin/mpg123 -4 -s -Z /home/pi/Music/* | sudo /home/pi/pifm/pifm - 88.3 ;; stop) echo "Stopping Pirate Radio" killall pifm ;; *) echo "Usage: /etc/init.d/pirateRadio.sh start|stop" exit 1 ;; esac exit 0
  • Change the permission on the pirateRadio.sh script by typing the following command: sudo chmod 755 /etc/init.d/pirateRadio.sh
  • Finally add the pirateRadio.sh script into the startup scripts default profile. sudo update-rc.d pirateRadio.sh defaults

Step #8: Assemble the case

PrevNext
$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies
  • Trim the belt clip of the battery pack off and sand it flat.
  • Use hot glue to attach some strong magnets to one side of the battery pack, and hook and loop fasteners to attach the Pi to the other.

Step #9: Connect the batteries

PrevNext
$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies$5 Raspberry Pi Zero Pirate Radio Throwies
  • Use a short USB Micro cable to power the Pi from the battery pack, and you’re ready to broadcast.
  • Now all you have to do is switch the Pi on, give it a toss towards a metal structure.
David Scheltema

David Scheltema

I love to tinker and write about electronics. My days are spent building projects and working as a Technical Editor for MAKE.


Tyler Winegarner

Tyler Winegarner

Video producer for Make:, also tinkerer, motorcyclist, gamer. Reads the comments. Uses tools, tells stories. Probably a human. Tweets @photoresistor


  • Nathan Corwin

    first one to incite a bomb scare wins!

    • rally2xs

      Hell, that shouldn’t be hard, this violates the single, remaining law that has replaced all others, “Don’t do anything unusual.” Should be good for an arrest as soon as you’re discovered.

      • Ancientharp

        That applies to photographers as well.

        • rally2xs

          Yep. More and more photographers getting arrested or at least hassled every day.

      • John Daniels

        I can’t see how they would ever track you down if you didn’t leave identifying evidence.

        • rally2xs

          Security cams practically blanket the country.

      • alrui

        And then sue like “clock boy”!

    • Antron Argaiv

      Difficulty: not Boston (too easy)

    • Sean Faulkner

      It’s just a clock.

  • kellydunn

    If you combine this with a wifi distributed network, you can create a fm network that could rival that of major broadcasters. A small solar panel and battery would allow continuous broadcasting over a long range from a single injection point. This would perfectly for major roads and highways, specially if a directional antenna is used.

    • Ryan Burns

      That’s clever, and totally feasible in high population areas like cities and along motorways, cool idea.

  • Anthony Clifton

    Yeah. I would recommend not encouraging people to throw a bomb-looking device onto random steel beams in public.

    • Sean Faulkner

      Boston would love this after the Mooninite incident.

  • s_f

    Too bad radio is dead.

    • Jorma Julian Oikarinen

      Not really , at least here in Europe is used a lot.

      • DO-NOT-MESS_with_USa

        Radio (AM and FM) is becoming soooo clogged up with adverts many are just turning the radio off.
        More have gone USB and make there own playlists.
        BTW: In the Chicago area there’s 5 stations that used to play 5 different eras of Rock. I will flip through the stations and 3 or 4 stations are playing the same tune and adverts. UGGGGggggg

        Ya, commercials are killing the air waves and I can see why this device was sold.

    • webgiant

      NPR has always been there for me, and I enjoy listening to it where ever I happen to be in the country. I too dislike every other kind of radio station, but don’t just say radio is dead because of commercial radio.

  • Jorma Julian Oikarinen

    “The Raspberry Pi’s broadcast frequency can range between 1Mhz and 250Mhz” Ok then, 1mhz=1000khz (This is on the MW radio band) Can we turn the Pi into a MW radio transmitter ?

    • Justin Nelson

      You’d need a much bigger antenna, and I bet power output isn’t flat across that range. Plus the SNR at those frequencies could swamp low-power devices.

      If you want to try, though, you could modify an amplifier like this: http://www.qsl.net/k5bcq/Kits/Kits.html (scroll down)

      and play around with it on the 160m amateur band (assuming, of course, that you have the appropriate license). That’s at 1600Khz-2000Khz. While there is a low-power device regulation for the FM broadcast band, I don’t think there is a similar regulation for the AM broadcast band.

    • yetanothermike

      It would be putting out a frequency- modulated (FM) signal on a band set aside for amplitude-modulated (AM) broadcasts. Depending on how wide a signal this thing put out, this could potentially interfere with other broadcasts, and invite a call from “Uncle Charlie” ( aka the FCC).
      On the other hand, the first generation of cordless home phones ( not cell phones) put out half of their signal ‘just above’ the AM broadcast band, at 1700 Khz. That band had since been expanded to 1710Khz, and the phones booted to 900Mhz and 2.4 Ghz. The other half of the signal was broadcast on the 49Mhz band. Both halves used frequency modulation.

  • Du kan tilogmed drive på med piratradio med en Raspberry Pi.

  • Vedeyn

    I recently made one of these with a raspberry pi a+ and I am getting some very high pitched background noise in my transmission. Any idea what could cause this?

    • brontide

      It’s a horrible design and should not be used without a RF band filter?

    • This is clock noise bleed through from the R-Pi. This is NOT a transmitter… only a novelty item.

  • Leif Burrow

    “We advise that you limit your transmissions to the standard FM band of 87.5MHz–108.0MHz”

    I don’t get it. You seem to be interested in keeping things legal or at least not causing interference. That is a good thing. But… The Raspberry Pi is not deigned for radio transmission. It isn’t outputing a nice clean sine-wave on one specific frequency. It’s a sqare wave. That means, if you are transmitting on one frequency then you are also transmitting on every odd multiple of that frequency.

    So.. say you found that in your area, in the FM Broadcast band 100MHz was a good, open frequency and you chose it. Great. Now you are transmitting on 300MHz, 500MHz, 700MHz, 900MHz, etc… You are interfering with military, police/fire, cellphones and babymonitors among others. The only thing that is likely to save you from getting noticed and prosecuted is the fact that the power level is so low.

    On the other hand… if you add some shielding and a lowpass filter you might have a useful device. I wish more of these articles discussed actually doing that!

    • Peter Hanely

      Indeed. An output filter between the PI and antenna is advisable for cleaner output.

    • Keith Hammond

      You’re right, it’s a noisy transmission but quite low power, just a few hundred feet of range. To clean up the FM signal, we recommend readers build a simple bandpass filter, like this one by Mike Tranchemontagne:
      https://www.youtube.com/watch?v=CuxNGWcftc8
      or this one by Paul Hollings:
      https://www.aareff.com/images/raspbery-pirate-filter-cir.png

      Which one do you all like best? Or how would you do it? Love to hear your ideas.

  • Antron Argaiv

    This is a Very Bad Idea. These transmitters generate a lot of spurious frequencies, in addition to the primary frequency. The output is “dirty” — *totally* unfiltered. Adding even a lowpass filter on the output would improve the design. A bandpass filter around your desired frequency of operation would be even better. An example is here: http://electronics-diy.com/electronic_schematic.php?id=803

    The real problem, however, is that the FCC (or your country’s radio frequency regulator) is going to take an interest if these start showing up. They do not appreciate random interfering transmitters being scattered about, because sooner or later, one will interfere with a licensed or public safety user. The consequences will not be pleasant.

  • Fat Ali

    This would allow a potential radio dead-spot hijack. Put in a tunnel where regular reception is lost it could take over from the silence. Anyone keen on telling everyone to vote for Donald Trump?

    • J Hoffman

      Only those who are getting paid to…

  • Carl Gundel

    What we need is an easy to program interface to Wifi. Then the rasperians can invent the Pipacket Radio replacement for the internet. An independent mesh network which can serve as the beginning of one or more alternate internets.

  • Geoff Gariepy

    What a terrible, stupid, asinine idea.

    First you’re throwing devices that look like bombs onto places that might be hard to retrieve them from. Next you’re causing interference on multiple bands of the radio service.

    What’s next? The Make article on how to build an IED?

    • Aaron Lager

      Bombs only look like that in the movies, or if you’re a Texas school principle…stop the scare mongering!
      Now the talk of RFI and bad quality transmissions are real.

      • Stuart Withers

        Something doesn’t have to look like a real bomb to get in trouble. It just has to look like peoples’ preconceived notions of bombs.

        • Aaron Lager

          By that definition, ANY circuit board is a bomb to the uneducated (Sadly it seems like most of the US falls into this category nowadays). Let’s use our brains people! Maybe I’m biased because I AM educated, I DO use my brain, and I design and program circuit boards for a living! RADIOS ARE NOT BOMBS!

  • IMPORTANT: A resonant quarter wave wire antenna for the FM band is about 30 inches long. Use 30 inches. For any frequency you set it to, use this formula for the wire length: 234 / Freq. in MHZ = length in feet . Ideally, you would add a second wire to the ground on the board and spread the two wires opposite each other. Use two wires of the above calculated length.

    • Andyj

      No Bob. the Pi is not supposed to drive a 37 ohm quarter wave load. (Assuming a flat ground plane). Half wave may be better.

  • mvadu

    You can avoid running it as a root by changing the /dev/mem to /dev/gpiomem

  • Alvaro

    I can’t get it to work with the Raspberry Pi 2. Is the pin different?

  • Steve

    Anyone know how to make this work with a raspberry pi 2?

  • S_in_USA

    ALL this chat about it looking like a bomb….
    PEOPLE PLEASE! GOT TO STOP ALL THIS POLITICAL CORRECTNESS KRAP, IT’S MAKING EVERYONE NUTS!!!!
    ===> PC is another form of government BRAINWASHING. <===
    .
    Go back to being yourselves, THAT'S AMERICAN, BE AMERICAN again.
    .
    Next thing you know some kid will do a science project on how a kitchen blender works and they will think it's a bomb due to its shape.
    SHEEEEEEEEEEEESH
    .

  • Octavio Pescina

    This in North Korea could do wonders!

  • Axel Roest

    The article says solder to ‘pin 4’ (+5V), but the photo clearly shows it is soldered to pin 7 (GPIO4).

    Please use the standard numbering of pins on these type of connectors, to prevent confusion to less experienced tinkerers and prevent blowing up GPIO ports.

    https://www.raspberrypi.org/documentation/usage/gpio/

  • Luis Montenegro Ferrel

    Greetings,
    I need help! I am following the recipe above and using my raspberry pi 2 model B, but for some reason my pi can not broadcast the signal still – which I am using a basic fm radio and I just get static only. I followed every step on flashing the sd card with a new Raspian OS, and updated all possible updates, and the PiFm file, sound.wav, etc – but still no broadcasting. For my area, I am using a vacant fm frequency 99.1, and also 89.7 and none of these are seem to work. I do think that perhaps it has to do with the antenna is not placed on the correct GPIO pin for my model. The above instructions call for the gpio pin number 4, how ever on my model B, that pin as on pin 8. Does anyone have any suggestions.Thanks.

    • Don Pettit

      There are some differences in the pi 2. This works on the 2
      https://github.com/markondej/fm_transmitter

      • Luis Montenegro Ferrel

        Hi Don,
        Thank you for the link! I looked it over, but did not find any steps on installing this in the Rasbian terminal. Is there any documentation on this? Thanks on any feed back!
        Luis Ferrel

  • Ken Stephens

    How about streaming internet radio using the Zero:
    1. Install lynx using sudo apt-get lynx
    2. Issue:
    ~$/usr/bin/lynx -accept_all_cookies -dump http://stream-tx1.redioparadise.com/mp3-128 | /usr/bin/mpg123 -4 -s -Z – | /home/pi/pifm/pifm – 88.7

    Of course your may choose another streaming URL and frequency.

    Enjoy

  • hal

    Creative use of raspi but too many ignorant budding Tesla wanna be’s could interfere with public safety coms. Few experimenters are RF engineers or even technically competent Amateur Radio Operators. Comments about use of low pass filters are positive but how many hobbiests have the test gear and knowledge to design and test appropriate RF filters. And then there is the law. Imagine these devices programmed to deliberatly jam coms. Add an amplifier stage and create a throwie RF jammer.
    Ive been a pirate, a welder, chemist, and moonshiner, and designer, and know the FCC very well. Have fun. My soldering iron is now cold,

    • DO-NOT-MESS_with_USa

      The old adage “give an inch, take a mile” is renewed.
      Give an electro-nave a sine-wave, impending doom from womb
      to tomb.

  • der coo

    as known pi zero have no audio input port
    so what about mod this lib to make the output of pi zero device sound on fm radio ??

  • Justin Clark

    I have a question, when I create the pirateRadio.sh and try to copy paste it in to the .sh file, it will not let me, or even let me save. What do I do???

  • Not that I’m advocating breaking the law (well maybe just a little,) let me relate the following story. When I was a kid in grade school (I’m 51 now) my parents set me up with a CB rig with an antenna on a fifty foot tower. Back then, you had to study and then take a proficiency test to get your operating certificate and call sign. Same thing for marine VHF radio. The FCC would send you a NAL (Notice of Apparent Liability) is you engaged in transgressions like not using your call sign, using it incorrectly, or, God forbid, operating with a linear amplifier, every CBers holy grail.
    Today, you can tell the world on the empty airwaves to go fuck itself. The FCC is a mere shell of its former self when it comes to aberrant signals. So don’t worry about the FCC police breaking down your door. Install that transmitter. Have some fun. Just don’t mention my name. Wayne #wreses .

  • Zeke

    Hey Make, I need some help with the raspberry pi 3 model. I can’t get this to work on the pi 3 for some reason I’m running raspbian 2016.03 . Any ideas as to why it won’t broadcast? My command in running is. Sudo ./pifm sound.wav 108.0 also tried 89.1 and 98.0 no luck.

  • Johnathan

    The thing is that the Raspberry Pi Zero has been almost as elusive as vaporware for a while, it came out in late November and stock sold out early. I look all the time and can only find second hand units or kits for something like $25 bucks, add a battery holder, batteries, and USB cable and it comes out to something more like a “$35 Pirate Radio Throwie”…

  • Larry_T

    What a childish (not to say illegal) piece of crap. That’s just what a bunch of immature “script kiddie” level spoiled brats would do. Make has certainly degenerated over the years.

    • James Craig

      Actually, here in the US, as long as the signal strength is low, it’s perfectly legal. If not, those little devices that let you play your iPod across the FM radio in your car would be illegal.

      I have a friend who is planning to set up something like this at a big event that will allow them to have daily announcements that people can listen to via radio without the intrusiveness of a PA system.

  • Donovan Goodwin

    Got one working with the Raspberry Pi 2 Model B. I used the PiFm Rds(https://github.com/ChristopheJacquet/PiFmRds) library I used this command sox -t wav /home/pi/Music_Wav/* -treble +7 -repeat 50 -t wav - | sudo ./pi_fm_rds -freq 88.5 -audio - -ps "Donovan's Radio Station" -rt "Have fun this is just for us young people:)" and it works flawlessly. I only have one gripe, and that would be that it only accepts Wav music files so you will need to convert your whole audio library over or use an external music player and usb audio card.