Build your own Raspberry Pi Pirate Radio

In this tutorial, we will be showing you the basics of how to set up a Raspberry Pi Pirate Radio utilizing the FM Transmitter software and a piece of wire.

Raspberry Pi Pirate Radio

This piece of software allows you to broadcast an FM signal through your GPIO 4 pin. This broadcast means you can set up your own little radio station.

However, please make note that the sound quality and range will be quite poor due to the signal been limited to mono and that most wires aren’t the best antennas.

Also, please note that there are laws and regulations around broadcasting on FM Frequencies, make sure that you check with the laws of your country before proceeding with this tutorial to ensure you arenโ€™t breaking any laws.

Equipment List

Below are all the bits and pieces that I used for this Raspberry Pi Pirate Radio tutorial, you will need an internet connection to be able to complete this tutorial.



Setting up your Raspberry Pi Pirate Radio

Before we get started with this tutorial, we first need to hook up a wire to the GPIO 4 pin, which is also known as the seventh physical pin. If you are unsure of what GPIO pin we are talking about you can check out our GPIO guide.

This wire will act as our antenna for the Raspberry Pi Pirate Radio. For our tutorial, we just used a simple breadboard wire which isn’t the best antenna, but it is good enough to work as a proof of concept. A 30 cm (11 in) piece of 12 AWG wire should work good enough to broadcast over a small room.

1. Now before we set up our basic pirate radio and install the FM transmitter we need to run an update on the Raspberry Pi by using the following two commands.

sudo apt update
sudo apt upgrade

2. With the update now done, let’s install all the packages we will need to be able to set up our pirate radio.

Run the following install commands on our Raspberry Pi to grab all the packages we need.

sudo apt install -y sox make gcc g++ git libmp3lame-dev

3. Now that we have all the packages we need installed, we can move onto cloning the FM Transmitter software to our Raspberry Pi. This software will allow us to broadcast music through our antenna that’s placed on the GPIO 4 pin.

If you want to learn more about the software head to the FM Transmitter GitHub.

To clone the software run the following commands on your Raspberry Pi.

cd ~
git clone

4. Let’s now compile the software, we can do this by moving into the directory and running make.

Run the following two commands on your Raspberry Pi to do this.

cd ~/fm_transmitter

5. With the FM Transmitter software now compiled onto our Raspberry Pi, and we can now try playing our first music file, of course, to be able to do this we first need a supported file.

Let’s run the following commands to grab a test file from our file server.


The music tracked is titled “Epic Song” and is by Boxcat Games and is available under the creative commons 3.0 license. For this project, the audio has been converted from .mp3 to .wav.

6. Now that we have a supported file downloaded to our Raspberry Pi let’s try running the software to start up our pirate radio. To do this, we can type the following command into terminal to run it.

This command converts the file into a supported format and pipes it to our FM Transmitter software and then plays it on the 100.3 band.

sox /home/pi/fm_transmitter/boxcat_games_epic_song.wav -r 22050 -c 1 -b 16 -t wav - | sudo ./fm_transmitter -f 100.3 -

The arguments for this command do several things. First, we use sox to convert our wav file to ensure we are feeding uncompressed data to the transmitter software.

  • -r defines the sample rate that SOX will convert the file.
  • -c defines the number of channels, due to limitations of the FM Transmitter software we cut it down to a single channel.
  • -b defines the bit rate that the output should be sampled at.
  • -t is used to specify the type of file that Sox should be converting this file to. In our case this should be wav.

We then pipe (|) the converted data from sox directly to the FM transmitter program we compiled earlier so that we can start broadcasting the sound.

With the FM Transmitter command we pass in the frequency we want to transmit on by using the -f option.

7. You can now test to see this is working by tuning to the 100.3 FM band on your radio device. You should hear the music come through if it is successfully working.

Once you are happy that it is working, we can move onto the next segment of this tutorial, and this segment will involve setting it up so our Pirate Radio can also play MP3 files since this is not supported by default.

To achieve this, we will need to compile several pieces of software.

Adding MP3 Support to your Raspberry Pi Pirate Radio

To add MP3 support, we need to compile and install FFMPEG, since FFMPEG is not available through packages for the Raspbian operating system we will have to do all of this manually.

1. To start off let’s first clone and compile x264 support, this is needed to compile the latest versions of FFmpeg. Run the following six commands on your Raspberry Pi to do this.

cd /usr/src
sudo git clone
cd x264
sudo ./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
sudo make
sudo make install

2. With the x264 library now installed we can go into compiling FFmpeg. To do this, we need to run another six commands on our Raspberry Pi.

cd /usr/src
sudo git clone git:// ffmpeg
cd ffmpeg

Raspberry Pi 3 and later:

sudo ./configure --arch=armv7-a --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --extra-cflags='-march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard'

Raspberry Pi 2 and earlier:

sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree

Finally for both run:

sudo make -j4
sudo make install

3. With FFmpeg now compiled and setup we can now actually run MP3 files. To do this, we will make use of the script that is included with the FM Transmitter software.

While we do not have a sample mp3 file handy to get you to download, you can run any mp3 file you want by utilizing the following command, replacing the last segment with the location of the file.

cd ~/fm_transmitter
sudo python ./ -f 100.3 example.mp3

Hopefully, by now you have learned how to set up a basic pirate radio using the FM Transmitter software. This transmitter software will allow you to broadcast any music you want by just using your Raspberry Pi.

Remember though that you need to adhere to your countries radio laws, most countries have a lot of restrictions on what frequencies you can use and the range that you can broadcast.

We hope you have enjoyed learning the basics of how to set up your own Pirate Radio with the Raspberry Pi and just a piece of wire. Drop a comment below if this tutorial helped you out or whether you run into any issues.


  1. Avatar for Paul B
    Paul B on

    I tried to get this working today. Step 6 didn’t work on my Raspberry pi4B.

    sox /home/pi/fm_transmitter/boxcat_games_epic_song.wav -r 22050 -c 1 -b 16 -t wav – | sudo

    after -t wav I assume the it is {space} hypen | {pipe} {space} sudo ???

    1. Avatar for Emmet
      Emmet on

      Hi Paul,

      Sorry about that it looks like there was a mistake in the tutorial where part of the command ended up being stripped out.

      I have now updated the step so that it includes the part where we are piping the result of sox to the FM Transmitter software.

      Let me know if that solves your issues.


  2. Avatar for Patsy Lascano
    Patsy Lascano on

    thanks so much for the instructions! was able to make one yesterday!

    here’s a simple bash script that loops through your mp3 files in a ‘/music/’ folder infinitely for anyone interested ๐Ÿ™‚

    make sure u have mp3info installed:

    while :
    for file in './music/*'
    sudo python ./ -f 100.3 $file &
    sleep 'mp3info -p "%mm %02ss\n" $file' &&
    sudo killall fm_transmitter

  3. Avatar for Chris Ford
    Chris Ford on

    Got a surprise. After work on this project for about 2 hours. and fine-tuning the code. I figured out how to get a live stream from Shoutcast to play through this Pi Radio. The guys who wrote this software are awesome. Need to give them a big shout out. I saved this startup script in file

    sudo sox -t mp3 /home/pi/Music/*.pls -t wav – | sudo /home/ft/PiFmRds/src/pi_fm_rds -freq 95.7 -ps Gators_Radio -audio –

    Change *.pls to whatever you like. But be sure to put the content inside the pls file.below.

    Title1=(#1 – 538/825) – LAID-BACK JAZZ – The Jazz Groove. Ad Free. (West)

    This is a functional Jazz station on Shoutcast.

    Technically, if you have a live broadcast on Shoutcast. Or your own Shoutcast server. You can do live shows or broadcast directly from your PC through the server that converts to a PLS file and play it on your Raspberry Pi Radio Transmitter. I am always willing to help. If you have issues.

    Happy Broadcasting

  4. Avatar for serdun
    serdun on

    How to to play all wav, mp3 files one folder one after another?

  5. Avatar for tstriker
    tstriker on

    What’s the range of this broadcast? Can someone 1 KM away hear it?

    1. Avatar for Gus
      Gus on

      Depends on the antenna you use but typically it will only be able to broadcast 1-2 metres.

    2. Avatar for Lou Palladino
      Lou Palladino on

      We were able to broadcast throughout our entire house with no extra wire/antenna connected. Didn’t try to broadcast to another home.

    3. Avatar for Jim
      Jim on

      When I tried this when it first popped up on another Pi project site, I took a portable radio through my neighborhood.

      I was able to get about 300 meters using an antenna trimmed to a quarter wave and elevated about 3 meters.

      There are a lot of variables including obstructions and even the weather.

  6. Avatar for Louis
    Louis on

    Thanks for a great tutorial, really enjoyed going through it and got it to work perfectly! However, I can’t seem to figure out how to play multiple files, like if you had a full playlist. Is there any way to go about this?

    1. Avatar for d3vCr0w
      d3vCr0w on

      Well, you could make a simple python script that lists all the songs inside a specified directory, then loops over them and for each one executes the fm_transmitter program, you can even add that script to a cron, so that it runs automatically after the pi boots up.

  7. Avatar for Charlie
    Charlie on

    is there anyway to make it brodcast from a usb mic in realtime?

  8. Avatar for Pi_Newbie
    Pi_Newbie on

    Hi and thanks for this post! After I update and upgrade successfully, and when I try to execute step 2 in the first section above, I get an error as shown below. Any ideas? Thanks!

    pi@raspberrypi:~ $ sudo apt-get install -y sox make gcc g++ git arecord libmp3lame-dev
    E: Unable to locate package arecord

    1. Avatar for Gus
      Gus on

      Try using alsa-utils instead of arecord, let me know how you go!

  9. Avatar for Lou Palladino
    Lou Palladino on

    A couple of things wrong with the instructions:

    1. The ‘arecord’ package is provided by ‘alsa-utils’ now so replace the package name as shown:

    sudo apt-get install -y sox make gcc g++ git alsa-utils libmp3lame-dev

    2. Step #6 in the .wav broadcast chopped off the full sudo command. The entire thing should be:

    sox /home/pi/fm_transmitter/star-wars.wav -r 22050 -c 1 -b 16 -t wav - | sudo ./fm_transmitter -f 100.6 -

    Obviously you can change your frequency to whatever.

    Otherwise this is pretty neat ๐Ÿ™‚ I also noticed that I didn’t need to attach a wire to GPIO #4. I have a breadboard attached and attaching the wire didn’t seem to do anything. Shrug.

    Thanks for the article and the site – looking for small projects like this to do with my kids.

    1. Avatar for Gus
      Gus on

      Thanks for that Lou!

  10. Avatar for Regis
    Regis on


    Well… 100.6MHz is not the most interesting channel. As you mentioned, it’s forbidden in most countries as it’s the public FM band with costly licenses… I don’t want the guards to come to my home (being close to a naval base, I *know* they’re listening to everything and that they have the goniometry equipment to locate me in minutes).

    How can I select something else, such as 107.5MHz (or above), or un-listened channels like the 433KHz band, or, even funnier, make a radio system changing frequency every 50th of a second (so only the receiver(s) can re-assemble the broadcast as each packet contains its broadcast timeframe and the curve equation to get the frequency of a block from the time value)?

Leave a Reply

Your email address will not be published. Required fields are marked *