We’ve all listened to the radio and sang along to the songs, atleast in the car. But have you ever found yourself switching through several channels because you couldn’t find even one song that YOU like? In this article we will learn how to build a FM radio transmitter using your Raspberry Pi. A FM radio transmitter technically broadcasts signals to a standard FM radio over an FM broadcast band frequency. What this mean that is you can then listen to any and all of the songs you like on your radio, by playing them yourself (like a mini RJ).
For this project, the prerequisites are simple – have a Raspberry Pi all setup and a basic understanding of how to navigate through the Pi. If you’ve just unboxed the Pi, feel free to go and check out our introductory articles about what it is, and how to set it up.
Things you need:
- Raspberry Pi
- Power cable
- Keyboard
- Mouse
- HDMI cable
- Monitor
- Internet connection
Setup:
Step 1 – setup your Pi:
For this experiment as discussed earlier it is expected that you have a Raspberry Pi with OS preloaded. Boot the Pi and check if you are running the latest version of Raspbian. To do that, open the terminal and type:
sudo apt-get update
Press enter and wait for the command to execute. Then:
sudo apt-get upgrade
Again, wait for the command to execute, after which you can reboot. To do this, type:
reboot
Step 2 – Create a folder for your project:
mkdir PI_FM
Then open the folder directory to store and access data there in the subsequent steps.
cd PI_FM
Step 3 – Clone the program:
We will now clone the necessary files from git, which is an open repository. If you don’t already have an account you may be asked to create one before you can clone the files, but its quite straightforward either way. This will clone the program into the folder that we have created and opened in the previous step.
sudo git clone https://github.com/markondej/fm_transmitter
Step 4 – Download compilers:
For different programs, depending on the code language we might need to use compilers in order to compile non-Python code on the Raspberry Pi. In this case, we will download and use gcc and g++ as the compilation tools for this program, as it is in C code.
sudo apt-get install gcc g++ make
Step 5 – Compile the project:
First we open the project directory by typing
cd fm_transmitter
and then to compile the project type,
sudo make
Step 6 – Test with an audio file.
If you already have a song in mind that you’d like to transmit first, find that in .wav format; and use the command:
wget http://thewavsite.com/Birthday/bday00.wav
(I’ve used the happy birthday song here)
But otherwise, the program we’ve cloned has a default Star Wars theme file attached to it. Whichever you wish to use, this is the syntax of the command:
sudo ./fm_transmitter -f <frequency> -r <filename>
For my file,
sudo ./fm_transmitter -f 100 -r bday00.wav
The frequency that we use in this example is 100MHz. What that means is, tune into 100MHz frequency on the device you are going to use. You can however go ahead and change that up a bit if you’d like. You should be able to hear the song that you are playing and controlling from your Raspberry Pi. Any song that you like can be used for this purpose, just make sure it is of .wav format. Have fun with this project!