Hi everyone. Today I´m going to show you how you can make a FM transmitter out of your Raspberry Pi.
- Raspberry Pi
- Operating System installed (I used wheezy)
- SSH server up and running (To connect to your Raspberry Pi)
- About 20cm of wire
The first thing you need to do is to run the update command to avoid running into issues:
sudo apt-get update
Next download the file Pifm.tar.gz:
Alternately you can download the Pifm.tar.gz file from here.
Next unzip the downloaded file:
tar -xvf Pifm.tar.gz
Now add about 20cm of wire to the GPIO 4 pin as antenna.
That´s it. Your FM transmitter is ready to go.
To test it run the following command (Please replace 100.1 (MHz) with a free frequency you can use legaly in your country):
sudo ./pifm sound.wav 100.1
You should now hear the sound playing.
Play MP3 files
To play mp3 files you need to do a bit more. First you need to install sox:
sudo apt-get install sox libsox-fmt-all
Now run the following command to play your mp3 file (Please replace 102.3 (MHz) with a free frequency you can use legaly in your country):
sox -t mp3 SomeSong.mp3 -t wav -r 22050 -c 1 - | sudo ./pifm - 102.3
I also created a short script file to make it easier to run mp3 files:
sox -t mp3 $1 -t wav -r 22050 -c 1 - | sudo ./pifm - $2
Now you can simply run the following command to play mp3 files:
./fmplay.sh SomeSong.mp3 102.3
That´s it. You can now use your Raspberry Pi as a FM transmitter to create your own radio sender and to impress your friends. I hope you liked my today´s fun post. See you next time.
Warning: Do not interfere with frequencies used by ambulance, police, radio senders, etc. It is illegal and you might get into big trouble so please be careful and make sure to use only frequencies which are free to use in your country.