Raspberry Pi FM Transmitter


Hi everyone. Today I´m going to show you how you can make a FM transmitter out of your Raspberry Pi.

Prerequisites:

  • Raspberry Pi
  • Operating System installed (I used wheezy)
  • SSH server up and running (To connect to your Raspberry Pi)
  • About 20cm of wire

Recommended tools:

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:

wget www.icrobotics.co.uk/wiki/images/c/c3/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.

raspberry_pi_gpio

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.

Sources:

http://www.instructables.com/id/Raspberry-Pi-Radio-Transmitter/step3/Using-the-Software/

http://www.maketecheasier.com/run-radio-station-with-raspberry-pi/

http://linux.about.com/od/Bash_Scripting_Solutions/a/How-To-Write-Bash-For-Loops.htm

http://stackoverflow.com/questions/18003370/script-parameters-in-bash

Advertisements
Tagged

One thought on “Raspberry Pi FM Transmitter

  1. Joost van Poppel says:

    Nice tutorial, especially the part about playing MP3!!! Now i’m just wondering: is it somehow possible to shuffle through the different MP3 files I have in a directory?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: