Raspberry Pi Pirate Radio

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

Basically, this piece of software allows you to broadcast a FM signal through your GPIO 4 pin. This means you can setup your own little radio station, however please be noted 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.


Raspberry Pi 2 or 3

Micro SD Card

Ethernet Network Connection

30cm, 12 AWG Wire


Raspberry Pi Case

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 30cm piece of 12 AWG wire should work good enough to broadcast over a small room.

1. Now before we setup 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-get update
sudo apt-get upgrade

2. With the update now done, let’s install all the packages we will need to be able to fully set up our pirate radio. Run the following install commands on our Raspberry Pi to grab all the packages we need.

sudo apt-get install -y sox make gcc g++ git arecord 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 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 https://github.com/somu1795/fm_transmitter.git

4. Let’s now compile the software, we can simply 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 we can actually now try playing our first music file, of course to be able to do this we first need a supported file, lets run the following commands to grab a test file from our file server.

wget https://pimylifeup.com/out/star-wars.wav

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

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

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

The arguments for this command do several things:

-r defines the sample rate that SOX will convert the file.

-c defines the number of channels, due to limitations of FM Transmitter we cut it down to a single channel,

-b defines the bit rate that the output should be sampled at.

7. You can now test to see this is working by tuning to the 100.6 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, 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 of let’s first clone and compile x264 support, this is needed to compile the latest versions of ffmpeg. Run the following 6 commands on your Raspberry Pi to do this.

cd /usr/src
sudo git clone git://git.videolan.org/x264
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 6 commands on our Raspberry Pi.

cd /usr/src
sudo git clone git://source.ffmpeg.org/ffmpeg.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 PiStation.py 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 simply 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 ./PiStation.py -f 100.3 example.mp3

Hopefully by now you have learnt how to setup a basic pirate radio using the FM Transmitter software. This 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 to.

We hope you have enjoyed learning the basics of how to setup 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.

The Raspberry Pi Crash Course

The Raspberry Pi Crash Course

Enter your email address below to get the

Raspberry Pi crash course delivered straight to your inbox

Please check your inbox for a confirmation email!